oneie 3.7.0 → 3.8.0
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/README.md +9 -9
- package/dist/commands/agent.d.ts +2 -0
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +44 -0
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/bounty.d.ts +4 -0
- package/dist/commands/bounty.d.ts.map +1 -0
- package/dist/commands/bounty.js +24 -0
- package/dist/commands/bounty.js.map +1 -0
- package/dist/commands/capabilities.d.ts +4 -0
- package/dist/commands/capabilities.d.ts.map +1 -0
- package/dist/commands/capabilities.js +18 -0
- package/dist/commands/capabilities.js.map +1 -0
- package/dist/commands/commend.d.ts +4 -0
- package/dist/commands/commend.d.ts.map +1 -0
- package/dist/commands/commend.js +13 -0
- package/dist/commands/commend.js.map +1 -0
- package/dist/commands/completion.d.ts +4 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +49 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +4 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +78 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/doctor.d.ts +4 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +72 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/export.d.ts +4 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +15 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/fade.d.ts.map +1 -1
- package/dist/commands/fade.js +8 -4
- package/dist/commands/fade.js.map +1 -1
- package/dist/commands/flag.d.ts +4 -0
- package/dist/commands/flag.d.ts.map +1 -0
- package/dist/commands/flag.js +13 -0
- package/dist/commands/flag.js.map +1 -0
- package/dist/commands/health.d.ts +4 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +11 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/highways.d.ts.map +1 -1
- package/dist/commands/highways.js +7 -4
- package/dist/commands/highways.js.map +1 -1
- package/dist/commands/hire.d.ts +4 -0
- package/dist/commands/hire.d.ts.map +1 -0
- package/dist/commands/hire.js +16 -0
- package/dist/commands/hire.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +69 -42
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mark.d.ts.map +1 -1
- package/dist/commands/mark.js +7 -7
- package/dist/commands/mark.js.map +1 -1
- package/dist/commands/pay.d.ts +4 -0
- package/dist/commands/pay.d.ts.map +1 -0
- package/dist/commands/pay.js +21 -0
- package/dist/commands/pay.js.map +1 -0
- package/dist/commands/pipe.d.ts +4 -0
- package/dist/commands/pipe.d.ts.map +1 -0
- package/dist/commands/pipe.js +35 -0
- package/dist/commands/pipe.js.map +1 -0
- package/dist/commands/publish.d.ts +4 -0
- package/dist/commands/publish.d.ts.map +1 -0
- package/dist/commands/publish.js +23 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/repl.d.ts +4 -0
- package/dist/commands/repl.d.ts.map +1 -0
- package/dist/commands/repl.js +56 -0
- package/dist/commands/repl.js.map +1 -0
- package/dist/commands/revenue.d.ts +4 -0
- package/dist/commands/revenue.d.ts.map +1 -0
- package/dist/commands/revenue.js +11 -0
- package/dist/commands/revenue.js.map +1 -0
- package/dist/commands/stats.d.ts +4 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +11 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/status.d.ts +4 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +18 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/tail.d.ts +4 -0
- package/dist/commands/tail.d.ts.map +1 -0
- package/dist/commands/tail.js +51 -0
- package/dist/commands/tail.js.map +1 -0
- package/dist/commands/warn.d.ts.map +1 -1
- package/dist/commands/warn.js +6 -6
- package/dist/commands/warn.js.map +1 -1
- package/dist/index.js +61 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/args.d.ts +1 -0
- package/dist/lib/args.d.ts.map +1 -1
- package/dist/lib/args.js +3 -0
- package/dist/lib/args.js.map +1 -1
- package/dist/lib/output.d.ts +5 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +32 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/sdk.d.ts +10 -0
- package/dist/lib/sdk.d.ts.map +1 -0
- package/dist/lib/sdk.js +22 -0
- package/dist/lib/sdk.js.map +1 -0
- package/dist/utils/installation-setup.d.ts +15 -0
- package/dist/utils/installation-setup.d.ts.map +1 -1
- package/dist/utils/installation-setup.js +63 -0
- package/dist/utils/installation-setup.js.map +1 -1
- package/package.json +3 -18
- package/.claude/agents/TROUBLESHOOTING.md +0 -530
- package/.claude/agents/agent-backend.md +0 -574
- package/.claude/agents/agent-builder.md +0 -911
- package/.claude/agents/agent-claude.md +0 -645
- package/.claude/agents/agent-clean.md +0 -477
- package/.claude/agents/agent-clone.md +0 -554
- package/.claude/agents/agent-designer.md +0 -1080
- package/.claude/agents/agent-director.md +0 -2254
- package/.claude/agents/agent-documenter.md +0 -688
- package/.claude/agents/agent-frontend.md +0 -1199
- package/.claude/agents/agent-integrator.md +0 -670
- package/.claude/agents/agent-lawyer.md +0 -1320
- package/.claude/agents/agent-news.md +0 -363
- package/.claude/agents/agent-onboard.md +0 -613
- package/.claude/agents/agent-ontology.md +0 -585
- package/.claude/agents/agent-ops.md +0 -1275
- package/.claude/agents/agent-problem-solver.md +0 -669
- package/.claude/agents/agent-quality.md +0 -1042
- package/.claude/agents/agent-sales.md +0 -507
- package/.claude/agents/agent-writer.md +0 -1068
- package/.claude/commands/cascade.md +0 -742
- package/.claude/commands/chat.md +0 -728
- package/.claude/commands/commit.md +0 -95
- package/.claude/commands/create.md +0 -544
- package/.claude/commands/deploy.md +0 -309
- package/.claude/commands/fast.md +0 -636
- package/.claude/commands/mcp-on.md +0 -191
- package/.claude/commands/media-upload.md +0 -186
- package/.claude/commands/news.md +0 -274
- package/.claude/commands/onboard.md +0 -440
- package/.claude/commands/one.md +0 -398
- package/.claude/commands/optimize.md +0 -74
- package/.claude/commands/plan.md +0 -719
- package/.claude/commands/push.md +0 -214
- package/.claude/commands/release.md +0 -105
- package/.claude/commands/review.md +0 -99
- package/.claude/commands/server.md +0 -487
- package/.claude/commands/start.md +0 -227
- package/.claude/commands/test.md +0 -197
- package/.claude/commands/validate.md +0 -140
- package/.claude/hooks/.last-news-context +0 -1
- package/.claude/hooks/PULL-BEFORE-PUSH-GUIDE.md +0 -473
- package/.claude/hooks/README-knowledge-hooks.md +0 -451
- package/.claude/hooks/README-news-generation.md +0 -364
- package/.claude/hooks/README-root-cleanup.md +0 -200
- package/.claude/hooks/README.md +0 -284
- package/.claude/hooks/__pycache__/todo.cpython-312.pyc +0 -0
- package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
- package/.claude/hooks/auto-format.sh +0 -106
- package/.claude/hooks/check-filenames.py +0 -177
- package/.claude/hooks/clean-post.py +0 -468
- package/.claude/hooks/clean-pre.py +0 -393
- package/.claude/hooks/clean-root-markdown.sh +0 -73
- package/.claude/hooks/commit-push.sh +0 -95
- package/.claude/hooks/done.py +0 -236
- package/.claude/hooks/format-hook.sh +0 -163
- package/.claude/hooks/formatting.py +0 -187
- package/.claude/hooks/hook-logger.sh +0 -173
- package/.claude/hooks/knowledge-post.py +0 -355
- package/.claude/hooks/knowledge-pre.py +0 -245
- package/.claude/hooks/mcp-on.sh +0 -134
- package/.claude/hooks/notification-hook.sh +0 -279
- package/.claude/hooks/ontology-validation.py +0 -255
- package/.claude/hooks/push.sh +0 -153
- package/.claude/hooks/release-cli.sh +0 -205
- package/.claude/hooks/root-cleanup.py +0 -217
- package/.claude/hooks/security-hook.sh +0 -397
- package/.claude/hooks/tag-all-docs.py +0 -464
- package/.claude/hooks/test-validate-ontology.sh +0 -170
- package/.claude/hooks/todo.py +0 -368
- package/.claude/hooks/track-changes.sh +0 -101
- package/.claude/hooks/validate-imports.py +0 -182
- package/.claude/hooks/validate-ontology-structure-summary.md +0 -243
- package/.claude/hooks/validate-ontology-structure.py +0 -558
- package/.claude/hooks/validate-ontology-structure.py.backup +0 -518
- package/.claude/hooks/validate-ontology.py +0 -140
- package/.claude/hooks/write-news.sh +0 -194
- package/.claude/skills/INDEX.md +0 -523
- package/.claude/skills/REGISTRY.md +0 -529
- package/.claude/skills/agent-backend-create-mutation.md +0 -319
- package/.claude/skills/agent-designer-create-wireframe.md +0 -341
- package/.claude/skills/agent-frontend-create-page.md +0 -413
- package/.claude/skills/agents/README.md +0 -238
- package/.claude/skills/astro/add-content-collection.md +0 -30
- package/.claude/skills/astro/check-build.md +0 -29
- package/.claude/skills/astro/create-component.md +0 -29
- package/.claude/skills/astro/create-page.md +0 -30
- package/.claude/skills/astro/optimize-performance.md +0 -21
- package/.claude/skills/convex/check-deployment.md +0 -46
- package/.claude/skills/convex/create-mutation.md +0 -405
- package/.claude/skills/convex/create-query.md +0 -52
- package/.claude/skills/convex/read-schema.md +0 -373
- package/.claude/skills/convex/test-function.md +0 -50
- package/.claude/skills/deployment/check-deployment-health.md +0 -20
- package/.claude/skills/deployment/create-release.md +0 -21
- package/.claude/skills/deployment/deploy-cloudflare.md +0 -31
- package/.claude/skills/deployment/deploy-convex.md +0 -30
- package/.claude/skills/deployment/sync-repositories.md +0 -19
- package/.claude/skills/design/check-accessibility.md +0 -21
- package/.claude/skills/design/create-component-spec.md +0 -27
- package/.claude/skills/design/generate-design-tokens.md +0 -24
- package/.claude/skills/design/generate-wireframe.md +0 -30
- package/.claude/skills/documentation/create-migration-guide.md +0 -20
- package/.claude/skills/documentation/generate-api-docs.md +0 -27
- package/.claude/skills/documentation/generate-readme.md +0 -22
- package/.claude/skills/documentation/update-knowledge.md +0 -20
- package/.claude/skills/integration/connect-external-system.md +0 -21
- package/.claude/skills/integration/implement-a2a.md +0 -20
- package/.claude/skills/integration/implement-acp.md +0 -20
- package/.claude/skills/integration/verify-integration.md +0 -20
- package/.claude/skills/ontology/README.md +0 -255
- package/.claude/skills/ontology/check-dimension.md +0 -307
- package/.claude/skills/ontology/generate-entity-type.md +0 -339
- package/.claude/skills/ontology/validate-schema.md +0 -229
- package/.claude/skills/ontology/verify-relationships.md +0 -310
- package/.claude/skills/problem-solving/analyze-test-failure.md +0 -21
- package/.claude/skills/problem-solving/identify-root-cause.md +0 -20
- package/.claude/skills/problem-solving/propose-solution.md +0 -29
- package/.claude/skills/problem-solving/verify-fix.md +0 -21
- package/.claude/skills/sales/generate-demo-script.md +0 -21
- package/.claude/skills/sales/qualify-lead.md +0 -30
- package/.claude/skills/sales/track-trial.md +0 -20
- package/.claude/skills/sales/verify-kyc.md +0 -20
- package/.claude/skills/testing/analyze-coverage.md +0 -24
- package/.claude/skills/testing/generate-tests.md +0 -24
- package/.claude/skills/testing/run-tests.md +0 -27
- package/.claude/skills/testing/validate-e2e.md +0 -25
- package/AGENTS.md +0 -60
- package/CLAUDE.md +0 -130
- package/CREATE-WEBSITE.md +0 -458
- package/SECURITY.md +0 -31
- package/folders.yaml +0 -92
- package/one/README.md +0 -760
- package/one/actors/anthony-o-connell.md +0 -469
- package/one/actors/people.md +0 -590
- package/one/events/0-changes.md +0 -2764
- package/one/events/1-PROJECTS-START-HERE.md +0 -384
- package/one/events/1-projects-developer-quickstart.md +0 -620
- package/one/events/1-projects-feature.md +0 -2047
- package/one/events/1-projects-team-briefing.md +0 -583
- package/one/events/2024-10-14-deployment-plan.md +0 -330
- package/one/events/2024-10-14-deployment-success.md +0 -447
- package/one/events/2024-10-14-final-sync-complete.md +0 -250
- package/one/events/2024-10-14-release-v2.0.6.md +0 -414
- package/one/events/2024-10-15-agent-clean-v2-summary.md +0 -495
- package/one/events/2024-10-15-handoff-to-clean.md +0 -347
- package/one/events/2024-10-15-package-manager-tests.md +0 -442
- package/one/events/2024-10-15-release-command-complete.md +0 -416
- package/one/events/2025-10-15-private-files-secured.md +0 -359
- package/one/events/2025-10-15-unignore-public-group-docs.md +0 -298
- package/one/events/2025-11-08-backend-claude-refactor.md +0 -242
- package/one/events/2025-11-08-parallel-agent-implementation.md +0 -620
- package/one/events/2025-11-10-ai-integration-status-report.md +0 -241
- package/one/events/ACCESSIBILITY_CHECKLIST.md +0 -275
- package/one/events/ACCESSIBILITY_FIXES_SUMMARY.md +0 -293
- package/one/events/ALIGNMENT_REPORT_PROBLEM_SOLVER.md +0 -335
- package/one/events/ALIGNMENT_SUMMARY.md +0 -280
- package/one/events/API_ROUTES_FIXES_SUMMARY.md +0 -280
- package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +0 -654
- package/one/events/AUDIT-ONTOLOGY-ALIGNMENT.md +0 -598
- package/one/events/AUDIT_PLAN_COMPLETION-20251108-125555.md +0 -262
- package/one/events/BEFORE_AFTER_COMPARISON.md +0 -978
- package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +0 -372
- package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +0 -430
- package/one/events/CHARTS-READY-TO-USE-20251106-080939.md +0 -184
- package/one/events/CHARTS-SUMMARY-20251106-080938.md +0 -196
- package/one/events/CLAUDE copy.md +0 -897
- package/one/events/CLEANUP-RELEASE-V2.0.8.md +0 -308
- package/one/events/CLOUDFLARE-FS-FIX-20251106-100516.md +0 -75
- package/one/events/COMPONENT_SHOWCASE-20251106-080938.md +0 -629
- package/one/events/CONNECTIONS_DEMO.md +0 -519
- package/one/events/CREATE-WEBSITE.md +0 -460
- package/one/events/CRITICAL-FIXES-COMPLETE.md +0 -571
- package/one/events/CUSTOM-DOMAIN.md +0 -375
- package/one/events/DELIVERABLES.md +0 -450
- package/one/events/DELIVERABLES.txt +0 -273
- package/one/events/DEMO-GROUPS-PAGE.md +0 -410
- package/one/events/DEMO-TESTING-SUMMARY.md +0 -536
- package/one/events/DEMO_COMPONENTS.md +0 -505
- package/one/events/DEMO_HOOKS_INDEX.md +0 -352
- package/one/events/DEMO_INFRASTRUCTURE.md +0 -923
- package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +0 -588
- package/one/events/DEMO_INTEGRATION_CHECKLIST.md +0 -449
- package/one/events/DEMO_QUICK_REFERENCE.md +0 -459
- package/one/events/DEMO_SETUP.md +0 -494
- package/one/events/DEPLOYMENT copy.md +0 -444
- package/one/events/DEPLOYMENT.md +0 -196
- package/one/events/DESIGN-DELIVERABLES-20251106-080938.md +0 -557
- package/one/events/DESIGN-EXECUTIVE-SUMMARY-20251106-080938.md +0 -484
- package/one/events/DOCS-SYSTEM-GUIDE-20251105-142103.md +0 -458
- package/one/events/DOCUMENTER-DELIVERY-SUMMARY.md +0 -481
- package/one/events/DOCUMENTER-EXECUTION-GUIDE.md +0 -394
- package/one/events/DOCUMENTER-TASK-BREAKDOWN.md +0 -783
- package/one/events/ECOMMERCE-BEFORE-AFTER.md +0 -267
- package/one/events/ECOMMERCE-DEMO-PLAN.md +0 -243
- package/one/events/ECOMMERCE-ENHANCEMENTS.md +0 -594
- package/one/events/ECOMMERCE-HIGH-CONVERTING-ELEMENTS.md +0 -439
- package/one/events/ECOMMERCE-LIVE-DEMO.md +0 -381
- package/one/events/ECOMMERCE-QUICKSTART.md +0 -376
- package/one/events/ECOMMERCE-README.md +0 -354
- package/one/events/ECOMMERCE-REFACTOR-SUMMARY.md +0 -214
- package/one/events/ECOMMERCE-SETUP-SUMMARY.md +0 -414
- package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +0 -753
- package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +0 -941
- package/one/events/EFFECT_TS_API_PATTERN.md +0 -496
- package/one/events/EXECUTION-READY.md +0 -359
- package/one/events/EXECUTION-SUMMARY.md +0 -478
- package/one/events/FEATURE-2-4-COMPLETE.md +0 -320
- package/one/events/FEATURE_2_3_COMPLETE.md +0 -593
- package/one/events/FILE-REFERENCE-20251105-142103.md +0 -325
- package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +0 -241
- package/one/events/GROUPS-MIGRATION.md +0 -643
- package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +0 -432
- package/one/events/HANDOFF.md +0 -331
- package/one/events/HOOKS-DEMO.md +0 -459
- package/one/events/IMPLEMENTATION-CHECKLIST-20251105-142103.md +0 -274
- package/one/events/IMPLEMENTATION-REPORT-DOCS-20251105-142102.md +0 -394
- package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +0 -568
- package/one/events/IMPLEMENTATION_SUMMARY-20251106-080938.md +0 -571
- package/one/events/IMPLEMENTATION_SUMMARY.md +0 -547
- package/one/events/INDEX-ALL-AGENTS.md +0 -190
- package/one/events/INDEX-FRONTEND-TESTING.md +0 -524
- package/one/events/INDEX-PROBLEM-SOLVER.md +0 -488
- package/one/events/INDEX-QUALITY-AGENT-INFER65.md +0 -455
- package/one/events/INDEX.md +0 -295
- package/one/events/INDEX_QUICK_START_REDESIGN-20251106-080939.md +0 -342
- package/one/events/INSTALL-TESTS.md +0 -311
- package/one/events/INSTALLATION_FOLDERS.md +0 -534
- package/one/events/INSTALLATION_FOLDERS_FILES.md +0 -223
- package/one/events/INSTALLATION_FOLDERS_SUMMARY.md +0 -437
- package/one/events/INTEGRATION-ARCHITECTURE.md +0 -579
- package/one/events/INTEGRATION-CHECKLIST.md +0 -1252
- package/one/events/INTEGRATION-ORCHESTRATION.md +0 -2641
- package/one/events/INTEGRATION-SUMMARY.md +0 -671
- package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +0 -684
- package/one/events/LANDING-PAGE-IMPLEMENTATION.md +0 -660
- package/one/events/LANDING-PAGE-QUICKSTART.md +0 -425
- package/one/events/LICENSE.md +0 -107
- package/one/events/MASTER-COORDINATION-PLAN.md +0 -613
- package/one/events/MASTER-ORCHESTRATION-INFER65.md +0 -441
- package/one/events/MASTER-PLAN-SUMMARY.md +0 -309
- package/one/events/MCP-CONFIGURATION.md +0 -354
- package/one/events/MCP-SETUP-COMPLETE.md +0 -223
- package/one/events/MIGRATION-REPORT.md +0 -453
- package/one/events/MIGRATION.md +0 -87
- package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +0 -1663
- package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +0 -643
- package/one/events/NEWS-COMMANDS.md +0 -506
- package/one/events/NEWS-SYSTEM-SUMMARY.md +0 -480
- package/one/events/NODE-UPGRADE.md +0 -129
- package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +0 -416
- package/one/events/ONTOLOGY-HOOKS-README.md +0 -718
- package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +0 -383
- package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +0 -569
- package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +0 -491
- package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +0 -504
- package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +0 -221
- package/one/events/PACKAGE-STRUCTURE.md +0 -328
- package/one/events/PLAN-COMPLETE.md +0 -429
- package/one/events/PLAYBOOK-SETUP-SUMMARY.md +0 -349
- package/one/events/PROBLEM-SOLVER-EXECUTIVE-SUMMARY.md +0 -484
- package/one/events/PROBLEM-SOLVER-QUICKSTART.md +0 -420
- package/one/events/PROJECTS-PLAN-SUMMARY.md +0 -480
- package/one/events/PROMPT_FIX_FRONTEND_ONLY.md +0 -585
- package/one/events/QA-CHECKLIST.md +0 -692
- package/one/events/QUALITY-AGENT-SUMMARY.md +0 -334
- package/one/events/QUALITY-EXECUTION-CHECKLIST.md +0 -593
- package/one/events/QUICK-REFERENCE-FRONTEND-TESTING.md +0 -475
- package/one/events/QUICK-START-ONTOLOGY.md +0 -426
- package/one/events/QUICK_START_REDESIGN-20251106-080938.md +0 -400
- package/one/events/README-PROBLEM-SOLVER.md +0 -394
- package/one/events/README-archived.md +0 -537
- package/one/events/README_QUICK_START_REDESIGN-20251106-080938.md +0 -484
- package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +0 -657
- package/one/events/SEARCH_DEMO_DELIVERY.md +0 -433
- package/one/events/SEARCH_DEMO_SUMMARY.md +0 -321
- package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +0 -399
- package/one/events/SECURITY-AUDIT-FIXES.md +0 -394
- package/one/events/SECURITY-SCAN-COMPLETE.md +0 -299
- package/one/events/SHOP-BUILD-STATUS.md +0 -132
- package/one/events/SHOP-PREMIUM-UPDATE.md +0 -165
- package/one/events/SIMPLE_FIX_FRONTEND_ONLY.md +0 -280
- package/one/events/SITE-WIDE-GRADIENT-FIX.md +0 -317
- package/one/events/SPECIALIST-QUICK-REFERENCE.md +0 -678
- package/one/events/STORE-PRODUCTION-READY-STATUS.md +0 -377
- package/one/events/STRIPE-INTEGRATION.md +0 -432
- package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +0 -447
- package/one/events/STRIPE-SETUP-GUIDE.md +0 -480
- package/one/events/TEST-PLAN-INDEX.md +0 -364
- package/one/events/TEST-PLAN.md +0 -1435
- package/one/events/TEST-SUMMARY.md +0 -411
- package/one/events/TESTING-DELIVERY.txt +0 -372
- package/one/events/TESTS-QUICK-REF.md +0 -280
- package/one/events/TRANSITIONS-QUICK-START.md +0 -159
- package/one/events/TRANSPARENCY-FIXES.md +0 -293
- package/one/events/TYPESCRIPT_FIXES.md +0 -170
- package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +0 -412
- package/one/events/TYPESCRIPT_FIXES_INDEX.md +0 -359
- package/one/events/VERIFICATION_CHECKLIST-20251106-080938.md +0 -326
- package/one/events/VIEW-TRANSITIONS.md +0 -446
- package/one/events/agent-command-implementation.md +0 -305
- package/one/events/agent-director-enhancement-summary.md +0 -404
- package/one/events/agent-director-routing-update.md +0 -214
- package/one/events/agent-onboard-implementation-summary.md +0 -475
- package/one/events/agent-ontology-alignment-completion.md +0 -263
- package/one/events/ai-integration-complete.md +0 -294
- package/one/events/ai-integration-lessons-learned.md +0 -511
- package/one/events/backend-integration-tests.md +0 -624
- package/one/events/backend-structure-diagram.txt +0 -393
- package/one/events/backend-structure-summary.txt +0 -269
- package/one/events/bullfm-video-podcast-analysis.md +0 -319
- package/one/events/clean-agent-ontology-cleanup-report.md +0 -371
- package/one/events/clean-agent-todo-analysis-summary.md +0 -336
- package/one/events/cloudflare-automation-complete.md +0 -350
- package/one/events/cloudflare-pages-infrastructure-setup.md +0 -282
- package/one/events/contact-page-complete.md +0 -316
- package/one/events/convex-analysis-index.md +0 -322
- package/one/events/convex-structure-analysis.md +0 -718
- package/one/events/creation-instructions-9-todos.md +0 -906
- package/one/events/cycle-3-video-player-port-20251108.md +0 -368
- package/one/events/cycle-3-video-player-port-complete-20251108.md +0 -334
- package/one/events/deployment-installation-folders.md +0 -178
- package/one/events/deployment-ops-summary.md +0 -386
- package/one/events/deployment-verification.md +0 -366
- package/one/events/design-spec-complete.md +0 -226
- package/one/events/documentation-audit-index.md +0 -473
- package/one/events/documentation-audit-summary.md +0 -417
- package/one/events/documentation-improvement-roadmap.md +0 -906
- package/one/events/documentation-standards-compliance-report.md +0 -538
- package/one/events/documentation-updates.md +0 -370
- package/one/events/events.md +0 -563
- package/one/events/fix-product-hydration-20251106.md +0 -211
- package/one/events/frontend-effects-complete.md +0 -584
- package/one/events/frontend-effects-orchestration.md +0 -1356
- package/one/events/frontend-effects-risk-register.md +0 -1055
- package/one/events/frontend-effects-week1-assignments.md +0 -1594
- package/one/events/hook-ontology-alignment-summary.md +0 -528
- package/one/events/installation-folders-workflow-integration.md +0 -458
- package/one/events/landing-page-generator.md +0 -476
- package/one/events/legal-assessment-2025-10-16.md +0 -1917
- package/one/events/master-coordination-plan.json +0 -1078
- package/one/events/master-plan-9-todos.md +0 -900
- package/one/events/mobile-performance-optimization.md +0 -179
- package/one/events/onboarding-implementation-complete.md +0 -523
- package/one/events/ontology-audit-agent-clone.md +0 -323
- package/one/events/ontology-test-examples.md +0 -580
- package/one/events/phase1-backend-implementation-complete.md +0 -536
- package/one/events/plan-completion-audit.md +0 -707
- package/one/events/plan-files-updated.md +0 -273
- package/one/events/production-readiness-plan.md +0 -389
- package/one/events/readme.md +0 -100
- package/one/events/release.md +0 -272
- package/one/events/root-cleanup-alignment-report.md +0 -265
- package/one/events/security-fixes-2025-01-15.md +0 -226
- package/one/events/separate-implementation-status.md +0 -555
- package/one/events/server-command-optimization-20251108.md +0 -150
- package/one/events/session-summary-2025-10-18.md +0 -366
- package/one/events/skills-complete.md +0 -351
- package/one/events/skills-infer-6-10-summary.md +0 -70
- package/one/events/skills-phase1-complete.md +0 -281
- package/one/events/specialist-assignments.md +0 -766
- package/one/events/structural-analysis-architecture-vs-plans.md +0 -600
- package/one/events/test-dashboard.md +0 -363
- package/one/events/test-index.md +0 -421
- package/one/events/test-report-ontology.md +0 -611
- package/one/events/testing-summary.md +0 -388
- package/one/events/todo-agent-builder.md +0 -1180
- package/one/events/todo-agent-director.md +0 -164
- package/one/events/todo-agent-documenter.md +0 -1815
- package/one/events/todo-agent-frontend.md +0 -1542
- package/one/events/todo-agent-problem-solver.md +0 -1682
- package/one/events/todo-agent-quality.md +0 -1647
- package/one/events/todo-refactoring-complete.md +0 -408
- package/one/events/wave1-backend-implementation-complete.md +0 -698
- package/one/events/web-AI_INTEGRATION_PHASE2_SUMMARY-20251111-152540.md +0 -529
- package/one/events/web-BUY-IN-CHATGPT-README-20251116-235241.md +0 -491
- package/one/events/web-CHARTS-IMPLEMENTATION-20251106-080939.md +0 -576
- package/one/events/web-CHARTS-QUICKSTART-20251106-080939.md +0 -416
- package/one/events/web-CODE-HIGHLIGHTING-SUMMARY-20251111-152540.md +0 -442
- package/one/events/web-DEPLOYMENT_SUMMARY-20251116-005428.md +0 -290
- package/one/events/web-DESIGN-SUMMARY-20251106-080939.md +0 -514
- package/one/events/web-README-AI-INTEGRATION-20251111-152540.md +0 -196
- package/one/events/web-RECHARTS-INTEGRATION-20251111-152540.md +0 -265
- package/one/events/web-RELEASE_OPTIMIZATION_PLAN-20251116-005428.md +0 -447
- package/one/events/web-TEST-CLEANUP-20251105-143205.md +0 -3
- package/one/events/web-USING-ANY-COMPONENT-IN-CHAT-20251111-152540.md +0 -561
- package/one/events/web-test-code-highlighting-20251111-152540.md +0 -231
- package/one/groups/features.md +0 -2904
- package/one/groups/groups.md +0 -587
- package/one/groups/one.md +0 -619
- package/one/groups/strategy-copy.md +0 -887
- package/one/learning/.obsidian/app.json +0 -1
- package/one/learning/.obsidian/appearance.json +0 -1
- package/one/learning/.obsidian/core-plugins.json +0 -33
- package/one/learning/.obsidian/ecommerce-ontology.md +0 -210
- package/one/learning/.obsidian/workspace.json +0 -211
- package/one/learning/100-inference-quick-reference.md +0 -449
- package/one/learning/ag-ui-protocol.md +0 -613
- package/one/learning/agent-onboard-usage.md +0 -630
- package/one/learning/agentic-commerce.md +0 -146
- package/one/learning/ai-agents-vs-memecoins-thesis.md +0 -683
- package/one/learning/ai-api-reference.md +0 -715
- package/one/learning/ai-platform.md +0 -323
- package/one/learning/ai-quickstart.md +0 -355
- package/one/learning/ai-sdk-implementation.md +0 -436
- package/one/learning/ai-token-crypto-analysis-framework.md +0 -1191
- package/one/learning/ai-token-paradigm-shift-2025.md +0 -732
- package/one/learning/altcoin-cycle-prediction-ontology.md +0 -884
- package/one/learning/altcoin-cycle-trading-strategy.md +0 -642
- package/one/learning/architecture-any-backend.md +0 -1589
- package/one/learning/architecture-diagram.md +0 -404
- package/one/learning/architecture-frontend.md +0 -1014
- package/one/learning/architecture.md +0 -1742
- package/one/learning/archived/ontology.old.md +0 -2840
- package/one/learning/astro-effect-complete-vision.md +0 -2148
- package/one/learning/astro-effect-simple-architecture.md +0 -750
- package/one/learning/audit-agent-onboard-alignment.md +0 -481
- package/one/learning/audit-agent-sales-alignment.md +0 -444
- package/one/learning/backend-api-reference.md +0 -728
- package/one/learning/cascading-context-specification.md +0 -1617
- package/one/learning/claude-code-integration.md +0 -1293
- package/one/learning/cli-claude-handoff.md +0 -736
- package/one/learning/context-engineering.md +0 -610
- package/one/learning/crypto-analysis-strategy.md +0 -1276
- package/one/learning/crypto-cycle-2024-2025-analysis.md +0 -44
- package/one/learning/crypto.md +0 -978
- package/one/learning/develop/design.md +0 -364
- package/one/learning/develop/index.md +0 -145
- package/one/learning/development-commands.md +0 -251
- package/one/learning/docs.md +0 -627
- package/one/learning/dsl.md +0 -1678
- package/one/learning/event-driven-documentation.md +0 -270
- package/one/learning/files.md +0 -2489
- package/one/learning/frontend.md +0 -1056
- package/one/learning/games-english.md +0 -691
- package/one/learning/games.md +0 -1082
- package/one/learning/generative-ui-patterns.md +0 -559
- package/one/learning/guidelines.md +0 -314
- package/one/learning/hono.md +0 -2127
- package/one/learning/implementation-examples.md +0 -2554
- package/one/learning/installation-folders.md +0 -366
- package/one/learning/institutional-cycle-paradigm-2025.md +0 -555
- package/one/learning/knowledge.md +0 -660
- package/one/learning/language.md +0 -998
- package/one/learning/lessons-learned.md +0 -378
- package/one/learning/lessons-website-building-focus.md +0 -382
- package/one/learning/merge-report.md +0 -254
- package/one/learning/metadata-system.md +0 -504
- package/one/learning/nine-padel-playbook.md +0 -229
- package/one/learning/one-protocol-ai-agents.md +0 -892
- package/one/learning/one-protocol-executive-report.md +0 -617
- package/one/learning/one-protocol-standard.md +0 -869
- package/one/learning/one-protocol-whitepaper.md +0 -756
- package/one/learning/ontology-blog.yaml +0 -47
- package/one/learning/ontology-cheatsheet.md +0 -617
- package/one/learning/ontology-community.yaml +0 -65
- package/one/learning/ontology-core-universal.md +0 -740
- package/one/learning/ontology-core.yaml +0 -63
- package/one/learning/ontology-courses.yaml +0 -76
- package/one/learning/ontology-creator.md +0 -402
- package/one/learning/ontology-crypto.md +0 -1603
- package/one/learning/ontology-developer-guide.md +0 -814
- package/one/learning/ontology-documentation.md +0 -377
- package/one/learning/ontology-ecommerce.md +0 -269
- package/one/learning/ontology-education-game.md +0 -1654
- package/one/learning/ontology-education.md +0 -938
- package/one/learning/ontology-engineering-specification.md +0 -1310
- package/one/learning/ontology-engineering.md +0 -1676
- package/one/learning/ontology-files.yaml +0 -525
- package/one/learning/ontology-frontend-master.md +0 -2898
- package/one/learning/ontology-frontend-specifications.md +0 -2196
- package/one/learning/ontology-frontend.md +0 -2475
- package/one/learning/ontology-index.md +0 -397
- package/one/learning/ontology-minimal.yaml +0 -301
- package/one/learning/ontology-portfolio.yaml +0 -45
- package/one/learning/ontology-quickstart.md +0 -602
- package/one/learning/ontology-release.md +0 -317
- package/one/learning/ontology-shop.yaml +0 -148
- package/one/learning/ontology-tokens.yaml +0 -51
- package/one/learning/ontology-tutorial.md +0 -455
- package/one/learning/ontology-v2.md +0 -4449
- package/one/learning/ontology-video-script.md +0 -939
- package/one/learning/ontology-visual-guide.md +0 -378
- package/one/learning/ontology.md +0 -3847
- package/one/learning/ontology.yaml +0 -1653
- package/one/learning/parallel-agents.md +0 -932
- package/one/learning/patterns/backend/convex-mutation-pattern.md +0 -130
- package/one/learning/patterns/backend/convex-query-pattern.md +0 -143
- package/one/learning/patterns/backend/mutation-template.md +0 -249
- package/one/learning/patterns/backend/query-template.md +0 -286
- package/one/learning/patterns/backend/service-template.md +0 -258
- package/one/learning/patterns/design/component-architecture.md +0 -435
- package/one/learning/patterns/design/index.md +0 -160
- package/one/learning/patterns/design/test-driven-design-pattern.md +0 -196
- package/one/learning/patterns/design/wireframe-template.md +0 -250
- package/one/learning/patterns/frontend/component-template.md +0 -246
- package/one/learning/patterns/frontend/form-template.md +0 -348
- package/one/learning/patterns/frontend/page-template.md +0 -209
- package/one/learning/patterns/frontend/react-component-pattern.md +0 -188
- package/one/learning/patterns/test/acceptance-criteria-template.md +0 -396
- package/one/learning/patterns/test/technical-test-template.md +0 -566
- package/one/learning/patterns/test/test-driven-pattern.md +0 -160
- package/one/learning/patterns/test/user-flow-template.md +0 -272
- package/one/learning/performance.md +0 -459
- package/one/learning/provider-agnostic-content.md +0 -995
- package/one/learning/provider-creation-guide.md +0 -1082
- package/one/learning/quality-loop.md +0 -419
- package/one/learning/quick-start-ontology-mapping.md +0 -773
- package/one/learning/readme-architecture.md +0 -158
- package/one/learning/readme.md +0 -149
- package/one/learning/rules.md +0 -644
- package/one/learning/score.md +0 -85
- package/one/learning/specifications.md +0 -873
- package/one/learning/tags.md +0 -148
- package/one/learning/todo-template.md +0 -269
- package/one/learning/todo.md +0 -269
- package/one/learning/troubleshooting.md +0 -434
- package/one/learning/typescript-patterns.md +0 -321
- package/one/learning/universal-generation-language.md +0 -827
- package/one/learning/x402-research.md +0 -104
- package/one/license.md +0 -107
- package/one/paths/a2a.md +0 -600
- package/one/paths/acp.md +0 -808
- package/one/paths/acps.md +0 -749
- package/one/paths/agentkit.md +0 -367
- package/one/paths/agui.md +0 -785
- package/one/paths/any-backend.md +0 -1720
- package/one/paths/ap2.md +0 -1072
- package/one/paths/api/queries-reference.md +0 -860
- package/one/paths/api-docs.md +0 -1909
- package/one/paths/api-reference.md +0 -1029
- package/one/paths/api.md +0 -2208
- package/one/paths/architecture-diagram.md +0 -112
- package/one/paths/communications.md +0 -467
- package/one/paths/connections.md +0 -357
- package/one/paths/copilotkit.md +0 -1577
- package/one/paths/cryptonetworks.md +0 -799
- package/one/paths/documentation.md +0 -1138
- package/one/paths/effect.md +0 -297
- package/one/paths/elizaos.md +0 -1308
- package/one/paths/groups.md +0 -814
- package/one/paths/inference.md +0 -76
- package/one/paths/integration-examples.md +0 -893
- package/one/paths/integration-guide.md +0 -887
- package/one/paths/integration-phase2.md +0 -754
- package/one/paths/kyc.md +0 -650
- package/one/paths/mcp.md +0 -860
- package/one/paths/membership.md +0 -1170
- package/one/paths/middleware.md +0 -1085
- package/one/paths/multitenant.md +0 -1359
- package/one/paths/n8n.md +0 -1033
- package/one/paths/patterns.md +0 -107
- package/one/paths/protocols.md +0 -297
- package/one/paths/relationships.md +0 -125
- package/one/paths/schema.md +0 -605
- package/one/paths/service-layer.md +0 -568
- package/one/paths/vectors.md +0 -225
- package/one/paths/wordpress.md +0 -1320
- package/one/paths/workflow-copy.md +0 -923
- package/one/paths/workflow-examples.md +0 -759
- package/one/paths/workflow-onboarding.md +0 -701
- package/one/paths/workflow.md +0 -923
- package/one/paths/workflows/delegation.md +0 -903
- package/one/paths/workflows/frontend.md +0 -1055
- package/one/paths/workflows/strategy.md +0 -921
- package/one/paths/workflows/tasks.md +0 -716
- package/one/paths/x402-baazar.md +0 -131
- package/one/paths/x402.md +0 -1353
- package/one/things/ALIGNMENT_AUDIT_QUALITY_AGENT.md +0 -401
- package/one/things/AUDIT_AGENT_INTEGRATOR_ALIGNMENT.md +0 -588
- package/one/things/AUDIT_REPORT_AGENT_CLEAN.md +0 -461
- package/one/things/CHECKLIST.md +0 -407
- package/one/things/IMPLEMENTATION_STATUS.md +0 -379
- package/one/things/ONE.md +0 -529
- package/one/things/agents/agent-backend.md +0 -1501
- package/one/things/agents/agent-builder.md +0 -1064
- package/one/things/agents/agent-clean.md +0 -1112
- package/one/things/agents/agent-clone.md +0 -1324
- package/one/things/agents/agent-deploy.md +0 -986
- package/one/things/agents/agent-designer.md +0 -2305
- package/one/things/agents/agent-director.md +0 -1526
- package/one/things/agents/agent-documenter.md +0 -1129
- package/one/things/agents/agent-frontend.md +0 -1201
- package/one/things/agents/agent-integrator.md +0 -1269
- package/one/things/agents/agent-lawyer.md +0 -1371
- package/one/things/agents/agent-problem-solver.md +0 -1457
- package/one/things/agents/agent-quality.md +0 -1483
- package/one/things/agents/agent-sales.md +0 -1074
- package/one/things/cascade/cascade.yaml +0 -481
- package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +0 -523
- package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +0 -314
- package/one/things/cascade/docs/examples/1-1-agent-prompts.md +0 -562
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +0 -543
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +0 -272
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +0 -548
- package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +0 -586
- package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +0 -267
- package/one/things/cascade/docs/examples/1-3-event-coordination.md +0 -547
- package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +0 -665
- package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +0 -236
- package/one/things/cascade/docs/examples/1-4-knowledge-management.md +0 -652
- package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +0 -860
- package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +0 -255
- package/one/things/cascade/docs/examples/1-5-quality-loops.md +0 -725
- package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +0 -659
- package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +0 -256
- package/one/things/cascade/docs/examples/1-6-numbering-structure.md +0 -639
- package/one/things/cascade/docs/examples/readme.md +0 -259
- package/one/things/cascade/docs/getting-started.md +0 -533
- package/one/things/cascade/docs/workflow.md +0 -1378
- package/one/things/cascade/readme.md +0 -379
- package/one/things/cascade/templates/feature-template.md +0 -289
- package/one/things/claude/agents/advocacy-activation-manager.md +0 -710
- package/one/things/claude/agents/advocacy-campaign-designer.md +0 -688
- package/one/things/claude/agents/analyst.md +0 -508
- package/one/things/claude/agents/architect.md +0 -505
- package/one/things/claude/agents/brand-identity-specialist.md +0 -538
- package/one/things/claude/agents/bstp-token-strategist.md +0 -690
- package/one/things/claude/agents/builder-repo.md +0 -532
- package/one/things/claude/agents/bullstamp-community-builder.md +0 -597
- package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +0 -529
- package/one/things/claude/agents/bulltilt-platform-growth.md +0 -590
- package/one/things/claude/agents/company-bullstamp-character.md +0 -602
- package/one/things/claude/agents/company-bullstamp-community.md +0 -307
- package/one/things/claude/agents/company-bullstamp-marketing.md +0 -307
- package/one/things/claude/agents/company-bullstamp-token.md +0 -307
- package/one/things/claude/agents/company-bulltilt-growth.md +0 -307
- package/one/things/claude/agents/content-bibliography-formatter.md +0 -404
- package/one/things/claude/agents/content-calendar-planner.md +0 -473
- package/one/things/claude/agents/content-chapter-formatter.md +0 -513
- package/one/things/claude/agents/content-formatter.md +0 -571
- package/one/things/claude/agents/content-hook-specialist.md +0 -485
- package/one/things/claude/agents/content-image-formatter.md +0 -560
- package/one/things/claude/agents/content-introduction-formatter.md +0 -510
- package/one/things/claude/agents/content-multiplication-engine.md +0 -579
- package/one/things/claude/agents/content-playbook-writer.md +0 -473
- package/one/things/claude/agents/content-team-manager.md +0 -647
- package/one/things/claude/agents/content-toc-formatter.md +0 -547
- package/one/things/claude/agents/convex-backend-specialist.md +0 -2725
- package/one/things/claude/agents/core-manager.md +0 -607
- package/one/things/claude/agents/core-master.md +0 -426
- package/one/things/claude/agents/cross-functional-manager.md +0 -476
- package/one/things/claude/agents/crypto-airdrop-strategist.md +0 -622
- package/one/things/claude/agents/crypto-analytics-educator.md +0 -596
- package/one/things/claude/agents/crypto-architecture-specialist.md +0 -497
- package/one/things/claude/agents/crypto-community-analyst.md +0 -314
- package/one/things/claude/agents/crypto-community-psychologist.md +0 -546
- package/one/things/claude/agents/crypto-dex-optimization-expert.md +0 -579
- package/one/things/claude/agents/crypto-dex-optimizer.md +0 -307
- package/one/things/claude/agents/crypto-diamond-formation-specialist.md +0 -552
- package/one/things/claude/agents/crypto-diamond-hands.md +0 -307
- package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +0 -597
- package/one/things/claude/agents/crypto-engagement-specialist.md +0 -581
- package/one/things/claude/agents/crypto-market-researcher.md +0 -307
- package/one/things/claude/agents/crypto-marketing-orchestrator.md +0 -563
- package/one/things/claude/agents/crypto-network-effect-amplifier.md +0 -614
- package/one/things/claude/agents/crypto-optimization-analyst.md +0 -597
- package/one/things/claude/agents/crypto-strategic-synthesizer.md +0 -556
- package/one/things/claude/agents/crypto-team-manager.md +0 -392
- package/one/things/claude/agents/crypto-token-analyst.md +0 -319
- package/one/things/claude/agents/crypto-viral-content-creator.md +0 -549
- package/one/things/claude/agents/crypto-wallet-identification-expert.md +0 -527
- package/one/things/claude/agents/crypto-wallet-identifier.md +0 -307
- package/one/things/claude/agents/customer-journey-designer.md +0 -474
- package/one/things/claude/agents/customer-success-manager.md +0 -574
- package/one/things/claude/agents/dev.md +0 -406
- package/one/things/claude/agents/documenter.md +0 -548
- package/one/things/claude/agents/elevate-marketing-orchestrator.md +0 -403
- package/one/things/claude/agents/engagement-specialist.md +0 -502
- package/one/things/claude/agents/engineering-architect.md +0 -387
- package/one/things/claude/agents/engineering-business-analyst.md +0 -527
- package/one/things/claude/agents/engineering-developer.md +0 -386
- package/one/things/claude/agents/engineering-director.md +0 -322
- package/one/things/claude/agents/engineering-ingestor.md +0 -659
- package/one/things/claude/agents/engineering-product-manager.md +0 -525
- package/one/things/claude/agents/engineering-product-owner.md +0 -527
- package/one/things/claude/agents/engineering-project-coordinator.md +0 -525
- package/one/things/claude/agents/engineering-quality-assurance.md +0 -392
- package/one/things/claude/agents/engineering-team-manager.md +0 -515
- package/one/things/claude/agents/engineering-user-experience.md +0 -386
- package/one/things/claude/agents/framework-elevate-manager.md +0 -309
- package/one/things/claude/agents/improver.md +0 -805
- package/one/things/claude/agents/intelligence-team-manager.md +0 -390
- package/one/things/claude/agents/lead-capture-expert.md +0 -459
- package/one/things/claude/agents/lead-magnet-creator.md +0 -446
- package/one/things/claude/agents/market-research-analyst.md +0 -435
- package/one/things/claude/agents/marketing-brand-identity.md +0 -344
- package/one/things/claude/agents/marketing-content-hooks.md +0 -455
- package/one/things/claude/agents/marketing-content-multiplier.md +0 -331
- package/one/things/claude/agents/marketing-content-poster.md +0 -372
- package/one/things/claude/agents/marketing-customer-journey.md +0 -331
- package/one/things/claude/agents/marketing-director.md +0 -402
- package/one/things/claude/agents/marketing-engagement.md +0 -331
- package/one/things/claude/agents/marketing-lead-capture.md +0 -331
- package/one/things/claude/agents/marketing-lead-magnet.md +0 -331
- package/one/things/claude/agents/marketing-network-effects.md +0 -331
- package/one/things/claude/agents/marketing-nurture-campaigns.md +0 -331
- package/one/things/claude/agents/marketing-share-optimizer.md +0 -331
- package/one/things/claude/agents/marketing-team-manager.md +0 -451
- package/one/things/claude/agents/marketing-viral-growth.md +0 -232
- package/one/things/claude/agents/mission-commander.md +0 -378
- package/one/things/claude/agents/network-effect-analyst.md +0 -604
- package/one/things/claude/agents/nextjs-15-specialist.md +0 -1634
- package/one/things/claude/agents/npx.md +0 -946
- package/one/things/claude/agents/nurture-campaign-manager.md +0 -554
- package/one/things/claude/agents/one-master.md +0 -378
- package/one/things/claude/agents/one-orchestrator.md +0 -345
- package/one/things/claude/agents/one.md +0 -658
- package/one/things/claude/agents/playbook-generator.md +0 -526
- package/one/things/claude/agents/pm.md +0 -349
- package/one/things/claude/agents/po.md +0 -370
- package/one/things/claude/agents/qa.md +0 -361
- package/one/things/claude/agents/research-foundation-analyst.md +0 -324
- package/one/things/claude/agents/research-intelligence-gatherer.md +0 -435
- package/one/things/claude/agents/research-market-analyst.md +0 -324
- package/one/things/claude/agents/research-team-manager.md +0 -489
- package/one/things/claude/agents/sales-environment-optimizer.md +0 -519
- package/one/things/claude/agents/sales-team-manager.md +0 -407
- package/one/things/claude/agents/sales-upsell-strategist.md +0 -324
- package/one/things/claude/agents/service-advocacy-campaigns.md +0 -324
- package/one/things/claude/agents/service-advocacy-manager.md +0 -324
- package/one/things/claude/agents/service-success-manager.md +0 -324
- package/one/things/claude/agents/service-team-manager.md +0 -405
- package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +0 -2357
- package/one/things/claude/agents/share-optimization-specialist.md +0 -576
- package/one/things/claude/agents/sm.md +0 -352
- package/one/things/claude/agents/story-teller.md +0 -498
- package/one/things/claude/agents/task-master.md +0 -621
- package/one/things/claude/agents/tauri-cross-platform-specialist.md +0 -1912
- package/one/things/claude/agents/tester.md +0 -595
- package/one/things/claude/agents/the-bull-character-manager.md +0 -603
- package/one/things/claude/agents/tools-playbook-generator.md +0 -492
- package/one/things/claude/agents/turbo-repo-builder.md +0 -346
- package/one/things/claude/agents/upsell-strategist.md +0 -503
- package/one/things/claude/agents/ux-expert.md +0 -360
- package/one/things/claude/agents/viral-growth-orchestrator.md +0 -520
- package/one/things/claude/claude-code-hooks-development.json +0 -21
- package/one/things/claude/claude-code-hooks-production.json +0 -21
- package/one/things/claude/claude-code-hooks.json +0 -25
- package/one/things/claude/commands/agent.md +0 -124
- package/one/things/claude/commands/cascade-status.md +0 -153
- package/one/things/claude/commands/ingest.md +0 -343
- package/one/things/claude/commands/ingestor.md +0 -158
- package/one/things/claude/commands/mission.md +0 -103
- package/one/things/claude/commands/npx.md +0 -156
- package/one/things/claude/commands/one.md +0 -486
- package/one/things/claude/commands/quality-check.md +0 -252
- package/one/things/claude/commands/smart-route.md +0 -261
- package/one/things/claude/commands/start.md +0 -139
- package/one/things/claude/commands/story.md +0 -103
- package/one/things/claude/commands/task.md +0 -193
- package/one/things/claude/hook-bypass.json +0 -32
- package/one/things/claude/hooks/agent-hook-config.json +0 -427
- package/one/things/claude/hooks/build-hook.sh +0 -156
- package/one/things/claude/hooks/cleanup-hook.sh +0 -201
- package/one/things/claude/hooks/file-organization-hook.sh +0 -80
- package/one/things/claude/hooks/format-hook.sh +0 -43
- package/one/things/claude/hooks/hook-bypass.sh +0 -293
- package/one/things/claude/hooks/hook-debouncer.sh +0 -62
- package/one/things/claude/hooks/hook-logger.sh +0 -89
- package/one/things/claude/hooks/lint-hook.sh +0 -140
- package/one/things/claude/hooks/notification-hook.sh +0 -204
- package/one/things/claude/hooks/ontology-validation-hook.sh +0 -86
- package/one/things/claude/hooks/performance-metrics.json +0 -25
- package/one/things/claude/hooks/security-hook.sh +0 -256
- package/one/things/claude/hooks/story-validation-hook-enhanced.sh +0 -210
- package/one/things/claude/hooks/story-validation-hook.sh +0 -145
- package/one/things/claude/hooks/test-hook.sh +0 -145
- package/one/things/claude/hooks/test-story-validation.sh +0 -170
- package/one/things/claude/settings-local.json +0 -86
- package/one/things/cli/cli-code.md +0 -677
- package/one/things/cli/cli-compiler-code.md +0 -677
- package/one/things/cli/cli.md +0 -871
- package/one/things/components/card-shadcn.md +0 -953
- package/one/things/components/card.md +0 -1041
- package/one/things/components.md +0 -1743
- package/one/things/componets.md +0 -19
- package/one/things/contracts/Move.toml +0 -12
- package/one/things/contracts/README.md +0 -288
- package/one/things/contracts/one.move +0 -762
- package/one/things/contracts/sdk.ts +0 -579
- package/one/things/creator-diagram.md +0 -184
- package/one/things/crypto/FEATURES.md +0 -78
- package/one/things/crypto/ONECORE.md +0 -62
- package/one/things/crypto/ONECOREFAQ.md +0 -22
- package/one/things/crypto/ONECOREHOW.md +0 -46
- package/one/things/crypto/ONEENTERPRISE.md +0 -64
- package/one/things/crypto/ONEENTERPRISEFAQ.md +0 -64
- package/one/things/crypto/ONEENTERPRISEHOW.md +0 -53
- package/one/things/crypto/ONEPRO.md +0 -60
- package/one/things/crypto/ONEPROFAQ.md +0 -22
- package/one/things/crypto/ONEPROHOW.md +0 -53
- package/one/things/crypto/READMEAGENCY.md +0 -64
- package/one/things/crypto/VSL.md +0 -45
- package/one/things/crypto/WebsiteCopy.md +0 -176
- package/one/things/demo-accessibility-animations.md +0 -1025
- package/one/things/demo-components.md +0 -1310
- package/one/things/demo-design-summary.md +0 -692
- package/one/things/demo-design-system.md +0 -973
- package/one/things/demo-page-layouts.md +0 -1016
- package/one/things/design-system.md +0 -832
- package/one/things/designs/accessibility-audit.md +0 -877
- package/one/things/designs/component-specifications.md +0 -855
- package/one/things/designs/design-overview.md +0 -377
- package/one/things/designs/design-tokens.md +0 -448
- package/one/things/designs/wireframes-dashboard.md +0 -710
- package/one/things/docs/api-requests.md +0 -987
- package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +0 -485
- package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +0 -465
- package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +0 -425
- package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +0 -451
- package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +0 -536
- package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +0 -650
- package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +0 -473
- package/one/things/docs/ecommerce/QUICK-START.md +0 -405
- package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +0 -567
- package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +0 -271
- package/one/things/docs/ecommerce/USAGE-EXAMPLE.astro +0 -171
- package/one/things/docs/ecommerce/demo.astro +0 -309
- package/one/things/examples/children/lemonade-stand.md +0 -404
- package/one/things/examples/enterprise/crm-saas.md +0 -1444
- package/one/things/features/1-1-agent-prompts.md +0 -562
- package/one/things/features/1-2-yaml-orchestrator.md +0 -548
- package/one/things/features/1-3-event-coordination.md +0 -547
- package/one/things/features/1-4-knowledge-management.md +0 -652
- package/one/things/features/1-5-quality-loops.md +0 -725
- package/one/things/features/1-6-numbering-structure.md +0 -639
- package/one/things/features/2-1-dataprovider-interface.md +0 -2583
- package/one/things/features/2-2-config-system.md +0 -3242
- package/one/things/features/2-3-effectts-services.md +0 -1645
- package/one/things/features/2-4-react-hooks.md +0 -2136
- package/one/things/features/2-5-auth-migration.md +0 -2144
- package/one/things/features/2-6-dashboard-migration.md +0 -2084
- package/one/things/features/2-7-alternative-providers.md +0 -2578
- package/one/things/features/2-7-implementation-report.md +0 -724
- package/one/things/features/2-cli.md +0 -1720
- package/one/things/features/2-design.md +0 -1770
- package/one/things/features/2-tests.md +0 -576
- package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +0 -576
- package/one/things/features/DECOUPLING.md +0 -290
- package/one/things/features/DEPLOYMENT.md +0 -470
- package/one/things/features/IMPLEMENTATION_SUMMARY.md +0 -362
- package/one/things/features/improve.md +0 -861
- package/one/things/features/remove-convex-deps.md +0 -63
- package/one/things/features/top-features.md +0 -87
- package/one/things/features/use-one-backend.md +0 -1217
- package/one/things/features-in-english.md +0 -200
- package/one/things/files.yaml +0 -721
- package/one/things/ideas/1-create-workflow.md +0 -207
- package/one/things/ideas/2-backend-agnostic-frontend.md +0 -439
- package/one/things/implementation/backend-guide.md +0 -457
- package/one/things/interface.md +0 -257
- package/one/things/landing-page-implementation.md +0 -455
- package/one/things/legal/README.md +0 -234
- package/one/things/legal/privacy-policy.md +0 -1227
- package/one/things/legal/terms-of-service.md +0 -1432
- package/one/things/master-workflow-plan.md +0 -806
- package/one/things/pay.one.ie.md +0 -53
- package/one/things/plans/0-in-sync.md +0 -136
- package/one/things/plans/0-timeline.md +0 -36
- package/one/things/plans/1-create-workflow.md +0 -732
- package/one/things/plans/QUICK-START-SIMPLIFICATION.md +0 -333
- package/one/things/plans/README-SIMPLIFICATION.md +0 -349
- package/one/things/plans/SIMPLIFICATION-EXAMPLES.md +0 -16
- package/one/things/plans/SIMPLIFICATION-SUMMARY.md +0 -455
- package/one/things/plans/ai-elements-integration.md +0 -483
- package/one/things/plans/ai-elements.md +0 -1278
- package/one/things/plans/ai-integration-plan.md +0 -263
- package/one/things/plans/ai-integration.md +0 -996
- package/one/things/plans/ai-sdk.md +0 -798
- package/one/things/plans/ai-tools.md +0 -621
- package/one/things/plans/app.md +0 -832
- package/one/things/plans/architecture-summary.md +0 -312
- package/one/things/plans/async-ai-agents.md +0 -233
- package/one/things/plans/backend-agnostic-frontend.md +0 -390
- package/one/things/plans/backend-cleanup-quickstart.md +0 -380
- package/one/things/plans/backend-ontology-conformance.md +0 -475
- package/one/things/plans/backend-status.md +0 -599
- package/one/things/plans/backend-structure.md +0 -847
- package/one/things/plans/backend-target-structure.md +0 -482
- package/one/things/plans/backend.md +0 -1175
- package/one/things/plans/better-auth-any-backend-revised.md +0 -1103
- package/one/things/plans/better-auth-any-backend.md +0 -1896
- package/one/things/plans/better-auth-available-features.md +0 -273
- package/one/things/plans/big-plan.md +0 -52
- package/one/things/plans/cli-updates-required.md +0 -320
- package/one/things/plans/complete-step-by-step.md +0 -1409
- package/one/things/plans/components.md +0 -709
- package/one/things/plans/convex-agents.md +0 -1034
- package/one/things/plans/convex-better-auth.md +0 -1141
- package/one/things/plans/convex-on-off.md +0 -407
- package/one/things/plans/crypto-token-researcher.md +0 -629
- package/one/things/plans/data-quality-metrics.md +0 -745
- package/one/things/plans/deep-researcher-agent.md +0 -466
- package/one/things/plans/deploy-to-cloudflare.md +0 -623
- package/one/things/plans/deployment-architecture.md +0 -469
- package/one/things/plans/desktop.md +0 -1139
- package/one/things/plans/development-plan.md +0 -1283
- package/one/things/plans/development-workflow-tldr.md +0 -207
- package/one/things/plans/development-workflow.md +0 -959
- package/one/things/plans/dsl-claude-code.md +0 -1011
- package/one/things/plans/effect-components.md +0 -1743
- package/one/things/plans/effect-patterns-reference.md +0 -2235
- package/one/things/plans/effect.md +0 -1806
- package/one/things/plans/email.md +0 -966
- package/one/things/plans/enhance-auth.md +0 -1692
- package/one/things/plans/execution-strategy.md +0 -1291
- package/one/things/plans/existing-infrastructure.md +0 -712
- package/one/things/plans/feature-based-sites.md +0 -894
- package/one/things/plans/frontend-effects.md +0 -1276
- package/one/things/plans/group-folder-multi-tenancy.md +0 -893
- package/one/things/plans/improve-codebase.md +0 -1811
- package/one/things/plans/install-components.md +0 -215
- package/one/things/plans/integrate-frontend-and-backend.md +0 -603
- package/one/things/plans/landing.md +0 -820
- package/one/things/plans/layout.md +0 -249
- package/one/things/plans/mail-backend.md +0 -1361
- package/one/things/plans/mail.md +0 -2677
- package/one/things/plans/mcp-clear-context-prompt.md +0 -81
- package/one/things/plans/mcp-simple.md +0 -248
- package/one/things/plans/multi-ontology-architecture.md +0 -885
- package/one/things/plans/next-features.md +0 -114
- package/one/things/plans/npx-agent-safety.md +0 -785
- package/one/things/plans/npx-agent.md +0 -1089
- package/one/things/plans/onboarding.md +0 -51
- package/one/things/plans/one-protocol-and-payone-usage.md +0 -82
- package/one/things/plans/one.md +0 -677
- package/one/things/plans/ontology-6-dimensions.md +0 -2201
- package/one/things/plans/ontology-compliance-audit.md +0 -342
- package/one/things/plans/ontology-driven-strategy.md +0 -882
- package/one/things/plans/ontology-refine.md +0 -586
- package/one/things/plans/ontology-ui-approach.md +0 -375
- package/one/things/plans/open-agent.md +0 -840
- package/one/things/plans/performace.md +0 -122
- package/one/things/plans/phase-1-foundation.md +0 -620
- package/one/things/plans/phase-3-implementation.md +0 -1037
- package/one/things/plans/plan-connect-to-api.md +0 -146
- package/one/things/plans/quick-wins.md +0 -1428
- package/one/things/plans/r2.md +0 -777
- package/one/things/plans/readme-backend-cleanup.md +0 -402
- package/one/things/plans/release.md +0 -507
- package/one/things/plans/remove-backend-development-from-agents.md +0 -1331
- package/one/things/plans/repos.md +0 -98
- package/one/things/plans/separate-copy-2.md +0 -1349
- package/one/things/plans/separate-copy-3.md +0 -2479
- package/one/things/plans/separate-copy.md +0 -1349
- package/one/things/plans/separate-demo.md +0 -864
- package/one/things/plans/separate.md +0 -1999
- package/one/things/plans/sequence.md +0 -2040
- package/one/things/plans/shadcn-integration-summary.md +0 -510
- package/one/things/plans/sidebar.md +0 -206
- package/one/things/plans/skills.md +0 -709
- package/one/things/plans/small-fixes.md +0 -23
- package/one/things/plans/start-new.md +0 -764
- package/one/things/plans/switch-off-auth.md +0 -42
- package/one/things/plans/sync-checklist.md +0 -351
- package/one/things/plans/test-backend-connection.md +0 -514
- package/one/things/plans/unified-implementation-plan.md +0 -934
- package/one/things/plans/update-demos.md +0 -581
- package/one/things/plans/use-our-backend.md +0 -572
- package/one/things/plans/video-backend.md +0 -638
- package/one/things/plans/video-frontend.md +0 -490
- package/one/things/plans/video-old-archived.md +0 -656
- package/one/things/plans/wave1-onboarding-100-inferences.md +0 -1686
- package/one/things/plans/wave1-onboarding-vision.md +0 -744
- package/one/things/plans/wave1-orchestration-summary.md +0 -604
- package/one/things/plans/wave1-specialist-assignments.md +0 -1413
- package/one/things/plans/workflow-files.md +0 -1210
- package/one/things/plans/workflow.md +0 -1378
- package/one/things/plans-u.md +0 -905
- package/one/things/products/Blockchain Products.md +0 -6278
- package/one/things/products/cascade-landing-page.md +0 -841
- package/one/things/products/cascade.md +0 -1568
- package/one/things/products/context-engineering.md +0 -1488
- package/one/things/products/onthology.md +0 -15
- package/one/things/products/ontology-ui-shadcn.md +0 -1302
- package/one/things/products/ontology-ui.md +0 -1429
- package/one/things/products/ontology.md +0 -789
- package/one/things/products/sdk.md +0 -573
- package/one/things/promptkit.md +0 -930
- package/one/things/repos/all-repos.md +0 -0
- package/one/things/scripts-clean-mac.sh +0 -409
- package/one/things/service-providers-new.md +0 -1052
- package/one/things/service-providers.md +0 -1121
- package/one/things/structure.md +0 -532
- package/one/things/system.md +0 -618
- package/one/things/templates.md +0 -294
- package/one/things/tests/2-1-dataprovider-interface.md +0 -1216
- package/one/things/tests/2-1-test-analysis.md +0 -544
- package/one/things/things.md +0 -384
- package/one/things/todo-acp-integration.md +0 -744
- package/one/things/todo-ai.md +0 -933
- package/one/things/todo-api.md +0 -1078
- package/one/things/todo-assignment.md +0 -580
- package/one/things/todo-buy-chatgpt.md +0 -1450
- package/one/things/todo-components.md +0 -1683
- package/one/things/todo-connections.md +0 -278
- package/one/things/todo-ecommerce-frontend.md +0 -1313
- package/one/things/todo-ecommerce.md +0 -569
- package/one/things/todo-effects.md +0 -1075
- package/one/things/todo-frontend-effects.md +0 -977
- package/one/things/todo-landing-page.md +0 -1091
- package/one/things/todo-mail.md +0 -1160
- package/one/things/todo-master-plan.md +0 -490
- package/one/things/todo-onboard.md +0 -666
- package/one/things/todo-one-ie.md +0 -538
- package/one/things/todo-page.md +0 -606
- package/one/things/todo-plans.md +0 -282
- package/one/things/todo-projects.md +0 -241
- package/one/things/todo-refactoring-plan.md +0 -366
- package/one/things/todo-release.md +0 -654
- package/one/things/todo-sequence.md +0 -1621
- package/one/things/todo-use-our-backend.md +0 -1908
- package/one/things/todo-workflow.md +0 -626
- package/one/things/todo-x402.md +0 -2047
- package/one/things/todo.md +0 -21
- package/one/things/video/scripts-crypto.md +0 -835
- package/one/things/video-script-backup.md +0 -318
- package/one/things/video-script-demo.md +0 -382
- package/one/things/video-script-ontology.md +0 -333
- package/one/things/video-script.md +0 -361
|
@@ -1,2235 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Effect Patterns Reference
|
|
3
|
-
dimension: things
|
|
4
|
-
category: plans
|
|
5
|
-
tags: ai
|
|
6
|
-
related_dimensions: connections, events, knowledge
|
|
7
|
-
scope: global
|
|
8
|
-
created: 2025-11-03
|
|
9
|
-
updated: 2025-11-03
|
|
10
|
-
version: 1.0.0
|
|
11
|
-
ai_context: |
|
|
12
|
-
This document is part of the things dimension in the plans category.
|
|
13
|
-
Location: one/things/plans/effect-patterns-reference.md
|
|
14
|
-
Purpose: Documents effect.ts patterns reference for one platform
|
|
15
|
-
Related dimensions: connections, events, knowledge
|
|
16
|
-
For AI agents: Read this to understand effect patterns reference.
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
# Effect.ts Patterns Reference for ONE Platform
|
|
20
|
-
|
|
21
|
-
**Version:** 1.0.0
|
|
22
|
-
**Last Updated:** 2025-10-30
|
|
23
|
-
**Status:** Production-Ready Patterns
|
|
24
|
-
|
|
25
|
-
This is your practical handbook for using Effect.ts in the ONE Platform. Find patterns, copy examples, ship features.
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## Section 1: Quick Decision Trees
|
|
30
|
-
|
|
31
|
-
### When to Use Effect vs Plain TypeScript
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
START HERE
|
|
35
|
-
│
|
|
36
|
-
├─ Does it involve async operations?
|
|
37
|
-
│ └─ YES → Continue
|
|
38
|
-
│ └─ NO → Use plain TypeScript (no Effect needed)
|
|
39
|
-
│
|
|
40
|
-
├─ Does it need error handling?
|
|
41
|
-
│ └─ YES → Use Effect (tagged errors > try/catch)
|
|
42
|
-
│ └─ NO → Continue
|
|
43
|
-
│
|
|
44
|
-
├─ Does it compose with other operations?
|
|
45
|
-
│ └─ YES → Use Effect (Effect.gen, Effect.all)
|
|
46
|
-
│ └─ NO → Continue
|
|
47
|
-
│
|
|
48
|
-
├─ Does it need retry logic?
|
|
49
|
-
│ └─ YES → Use Effect (Schedule.exponential)
|
|
50
|
-
│ └─ NO → Continue
|
|
51
|
-
│
|
|
52
|
-
├─ Does it need dependency injection?
|
|
53
|
-
│ └─ YES → Use Effect (Context, Layer)
|
|
54
|
-
│ └─ NO → Continue
|
|
55
|
-
│
|
|
56
|
-
└─ Does it manage resources (connections, streams)?
|
|
57
|
-
└─ YES → Use Effect (Scope, acquireRelease)
|
|
58
|
-
└─ NO → Plain async/await is fine
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Simple Rule:** If it's just data transformation or basic async, use plain TypeScript. If it has complex error handling, composition, or resource management → Effect.
|
|
62
|
-
|
|
63
|
-
### When to Wrap Components vs Use Directly
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
CONVEX COMPONENT DECISION
|
|
67
|
-
│
|
|
68
|
-
├─ @convex-dev/agent
|
|
69
|
-
│ └─ Wrap if: Multi-agent orchestration, custom error handling
|
|
70
|
-
│ └─ Direct if: Single agent, simple chat
|
|
71
|
-
│
|
|
72
|
-
├─ @convex-dev/workflow
|
|
73
|
-
│ └─ Wrap if: Business logic in steps needs composition
|
|
74
|
-
│ └─ Direct if: Simple sequential steps
|
|
75
|
-
│
|
|
76
|
-
├─ @convex-dev/rag
|
|
77
|
-
│ └─ Wrap if: Composing search with other services
|
|
78
|
-
│ └─ Direct if: Standalone vector search
|
|
79
|
-
│
|
|
80
|
-
├─ @convex-dev/rate-limiter
|
|
81
|
-
│ └─ Wrap if: Multiple rate limits, custom retry logic
|
|
82
|
-
│ └─ Direct if: Single rate limit check
|
|
83
|
-
│
|
|
84
|
-
├─ @convex-dev/persistent-text-streaming
|
|
85
|
-
│ └─ Direct: Agent component has built-in streaming (use that)
|
|
86
|
-
│
|
|
87
|
-
├─ @convex-dev/retrier
|
|
88
|
-
│ └─ Wrap if: Coordinating with Effect.retry (hybrid approach)
|
|
89
|
-
│ └─ Direct if: Action-level retries only
|
|
90
|
-
│
|
|
91
|
-
├─ @convex-dev/workpool
|
|
92
|
-
│ └─ Wrap if: Batch enqueuing, error handling
|
|
93
|
-
│ └─ Direct if: Simple task queue
|
|
94
|
-
│
|
|
95
|
-
└─ @convex-dev/crons
|
|
96
|
-
└─ Wrap if: Cron job logic needs composition
|
|
97
|
-
└─ Direct if: Simple scheduled mutations
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**Golden Rule:** Components handle infrastructure (durability, retries, streaming). Effect handles business logic (composition, error handling, orchestration).
|
|
101
|
-
|
|
102
|
-
### When to Use Confect vs Manual Wrapping
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
CONFECT DECISION TREE
|
|
106
|
-
│
|
|
107
|
-
├─ Is this a NEW project?
|
|
108
|
-
│ └─ YES → Consider Confect (schema-first, full Effect integration)
|
|
109
|
-
│ └─ NO → Continue
|
|
110
|
-
│
|
|
111
|
-
├─ Is your team experienced with Effect?
|
|
112
|
-
│ └─ YES → Consider Confect
|
|
113
|
-
│ └─ NO → Manual wrapping (easier learning curve)
|
|
114
|
-
│
|
|
115
|
-
├─ Do you want Option<T> instead of T | null everywhere?
|
|
116
|
-
│ └─ YES → Confect
|
|
117
|
-
│ └─ NO → Manual wrapping
|
|
118
|
-
│
|
|
119
|
-
├─ Do you need Effect schemas instead of Convex validators?
|
|
120
|
-
│ └─ YES → Confect
|
|
121
|
-
│ └─ NO → Manual wrapping
|
|
122
|
-
│
|
|
123
|
-
└─ Is this an EXISTING Convex project?
|
|
124
|
-
└─ YES → Manual wrapping (incremental adoption)
|
|
125
|
-
└─ NO → Consider Confect
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
**Recommendation for ONE Platform:** Start with manual wrapping. Confect is powerful but adds learning overhead. Prove the patterns work with manual integration first.
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## Section 2: Core Patterns with Examples
|
|
133
|
-
|
|
134
|
-
### Pattern 1: Effect-Wrapped Component ✅ PRODUCTION-PROVEN
|
|
135
|
-
|
|
136
|
-
**When:** Wrapping Convex components for type-safe error handling and composition.
|
|
137
|
-
|
|
138
|
-
**Example: Wrapping @convex-dev/agent**
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
// backend/convex/services/agent.service.ts
|
|
142
|
-
import { Effect, Context, Layer, Data } from "effect";
|
|
143
|
-
import { Agent } from "@convex-dev/agent";
|
|
144
|
-
import { openai } from "@ai-sdk/openai";
|
|
145
|
-
import { components } from "../_generated/api";
|
|
146
|
-
|
|
147
|
-
// 1. Define tagged errors
|
|
148
|
-
class AgentError extends Data.TaggedError("AgentError")<{
|
|
149
|
-
agentName: string;
|
|
150
|
-
cause: unknown;
|
|
151
|
-
}> {}
|
|
152
|
-
|
|
153
|
-
// 2. Define service interface
|
|
154
|
-
class AgentService extends Context.Tag("AgentService")<
|
|
155
|
-
AgentService,
|
|
156
|
-
{
|
|
157
|
-
readonly generateResponse: (
|
|
158
|
-
ctx: ActionCtx,
|
|
159
|
-
threadId: string,
|
|
160
|
-
prompt: string,
|
|
161
|
-
) => Effect.Effect<string, AgentError>;
|
|
162
|
-
|
|
163
|
-
readonly createThread: (
|
|
164
|
-
ctx: ActionCtx,
|
|
165
|
-
userId: string,
|
|
166
|
-
) => Effect.Effect<string, AgentError>;
|
|
167
|
-
}
|
|
168
|
-
>() {}
|
|
169
|
-
|
|
170
|
-
// 3. Implement service layer
|
|
171
|
-
const AgentServiceLive = Layer.effect(
|
|
172
|
-
AgentService,
|
|
173
|
-
Effect.gen(function* () {
|
|
174
|
-
// Component handles infrastructure
|
|
175
|
-
const agent = new Agent(components.agent, {
|
|
176
|
-
name: "Support Agent",
|
|
177
|
-
chat: openai.chat("gpt-4o-mini"),
|
|
178
|
-
instructions: "You are a helpful assistant.",
|
|
179
|
-
tools: {
|
|
180
|
-
/* ... */
|
|
181
|
-
},
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
generateResponse: (ctx, threadId, prompt) =>
|
|
186
|
-
// Effect provides composition
|
|
187
|
-
Effect.tryPromise({
|
|
188
|
-
try: async () => {
|
|
189
|
-
const { thread } = await agent.continueThread(ctx, { threadId });
|
|
190
|
-
const result = await thread.generateText({ prompt });
|
|
191
|
-
return result.text;
|
|
192
|
-
},
|
|
193
|
-
catch: (error) =>
|
|
194
|
-
new AgentError({
|
|
195
|
-
agentName: "Support Agent",
|
|
196
|
-
cause: error,
|
|
197
|
-
}),
|
|
198
|
-
}),
|
|
199
|
-
|
|
200
|
-
createThread: (ctx, userId) =>
|
|
201
|
-
Effect.tryPromise({
|
|
202
|
-
try: async () => {
|
|
203
|
-
const { threadId } = await agent.createThread(ctx, { userId });
|
|
204
|
-
return threadId;
|
|
205
|
-
},
|
|
206
|
-
catch: (error) =>
|
|
207
|
-
new AgentError({
|
|
208
|
-
agentName: "Support Agent",
|
|
209
|
-
cause: error,
|
|
210
|
-
}),
|
|
211
|
-
}),
|
|
212
|
-
};
|
|
213
|
-
}),
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
export { AgentService, AgentServiceLive, AgentError };
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
**Usage in API:**
|
|
220
|
-
|
|
221
|
-
```typescript
|
|
222
|
-
// backend/convex/api/agents.ts
|
|
223
|
-
import { action } from "../_generated/server";
|
|
224
|
-
import { v } from "convex/values";
|
|
225
|
-
import { Effect } from "effect";
|
|
226
|
-
import { AgentService, AgentServiceLive } from "../services/agent.service";
|
|
227
|
-
|
|
228
|
-
export const chat = action({
|
|
229
|
-
args: { threadId: v.string(), prompt: v.string() },
|
|
230
|
-
handler: (ctx, args) =>
|
|
231
|
-
Effect.gen(function* () {
|
|
232
|
-
const agentService = yield* AgentService;
|
|
233
|
-
const response = yield* agentService.generateResponse(
|
|
234
|
-
ctx,
|
|
235
|
-
args.threadId,
|
|
236
|
-
args.prompt,
|
|
237
|
-
);
|
|
238
|
-
return { response };
|
|
239
|
-
}).pipe(
|
|
240
|
-
Effect.provide(AgentServiceLive),
|
|
241
|
-
Effect.catchTag("AgentError", (error) =>
|
|
242
|
-
Effect.succeed({
|
|
243
|
-
response: "I'm having trouble. Please try again.",
|
|
244
|
-
error: true,
|
|
245
|
-
}),
|
|
246
|
-
),
|
|
247
|
-
Effect.runPromise,
|
|
248
|
-
),
|
|
249
|
-
});
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
---
|
|
253
|
-
|
|
254
|
-
### Pattern 2: Service Layer Pattern (Context.Tag + Layer.effect) ✅ PRODUCTION-PROVEN
|
|
255
|
-
|
|
256
|
-
**When:** Creating reusable, testable services with dependency injection.
|
|
257
|
-
|
|
258
|
-
**Example: RAG Service with Dependencies**
|
|
259
|
-
|
|
260
|
-
```typescript
|
|
261
|
-
// backend/convex/services/rag.service.ts
|
|
262
|
-
import { Effect, Context, Layer, Data } from "effect";
|
|
263
|
-
import { RAG } from "@convex-dev/rag";
|
|
264
|
-
import { openai } from "@ai-sdk/openai";
|
|
265
|
-
import { components } from "../_generated/api";
|
|
266
|
-
|
|
267
|
-
// 1. Define errors
|
|
268
|
-
class RAGError extends Data.TaggedError("RAGError")<{
|
|
269
|
-
operation: string;
|
|
270
|
-
cause: unknown;
|
|
271
|
-
}> {}
|
|
272
|
-
|
|
273
|
-
class EmbeddingError extends Data.TaggedError("EmbeddingError")<{
|
|
274
|
-
text: string;
|
|
275
|
-
cause: unknown;
|
|
276
|
-
}> {}
|
|
277
|
-
|
|
278
|
-
// 2. Define service interface
|
|
279
|
-
class RAGService extends Context.Tag("RAGService")<
|
|
280
|
-
RAGService,
|
|
281
|
-
{
|
|
282
|
-
readonly addDocument: (
|
|
283
|
-
ctx: ActionCtx,
|
|
284
|
-
namespace: string,
|
|
285
|
-
content: string,
|
|
286
|
-
metadata: Record<string, any>,
|
|
287
|
-
) => Effect.Effect<string, RAGError>;
|
|
288
|
-
|
|
289
|
-
readonly search: (
|
|
290
|
-
ctx: ActionCtx,
|
|
291
|
-
namespace: string,
|
|
292
|
-
query: string,
|
|
293
|
-
limit?: number,
|
|
294
|
-
) => Effect.Effect<{ text: string; entries: any[] }, RAGError>;
|
|
295
|
-
}
|
|
296
|
-
>() {}
|
|
297
|
-
|
|
298
|
-
// 3. Implement service
|
|
299
|
-
const RAGServiceLive = Layer.effect(
|
|
300
|
-
RAGService,
|
|
301
|
-
Effect.gen(function* () {
|
|
302
|
-
const rag = new RAG(components.rag, {
|
|
303
|
-
textEmbeddingModel: openai.embedding("text-embedding-3-small"),
|
|
304
|
-
embeddingDimension: 1536,
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
return {
|
|
308
|
-
addDocument: (ctx, namespace, content, metadata) =>
|
|
309
|
-
Effect.tryPromise({
|
|
310
|
-
try: async () => {
|
|
311
|
-
const result = await rag.add(ctx, {
|
|
312
|
-
namespace,
|
|
313
|
-
text: content,
|
|
314
|
-
filterValues: Object.entries(metadata).map(([name, value]) => ({
|
|
315
|
-
name,
|
|
316
|
-
value,
|
|
317
|
-
})),
|
|
318
|
-
});
|
|
319
|
-
return result.entryId;
|
|
320
|
-
},
|
|
321
|
-
catch: (error) =>
|
|
322
|
-
new RAGError({
|
|
323
|
-
operation: "addDocument",
|
|
324
|
-
cause: error,
|
|
325
|
-
}),
|
|
326
|
-
}),
|
|
327
|
-
|
|
328
|
-
search: (ctx, namespace, query, limit = 10) =>
|
|
329
|
-
Effect.tryPromise({
|
|
330
|
-
try: async () => {
|
|
331
|
-
const results = await rag.search(ctx, {
|
|
332
|
-
namespace,
|
|
333
|
-
query,
|
|
334
|
-
limit,
|
|
335
|
-
vectorScoreThreshold: 0.6,
|
|
336
|
-
});
|
|
337
|
-
return {
|
|
338
|
-
text: results.text,
|
|
339
|
-
entries: results.entries,
|
|
340
|
-
};
|
|
341
|
-
},
|
|
342
|
-
catch: (error) =>
|
|
343
|
-
new RAGError({
|
|
344
|
-
operation: "search",
|
|
345
|
-
cause: error,
|
|
346
|
-
}),
|
|
347
|
-
}),
|
|
348
|
-
};
|
|
349
|
-
}),
|
|
350
|
-
);
|
|
351
|
-
|
|
352
|
-
export { RAGService, RAGServiceLive, RAGError };
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
**Composing Services:**
|
|
356
|
-
|
|
357
|
-
```typescript
|
|
358
|
-
// backend/convex/api/contextual-chat.ts
|
|
359
|
-
import { action } from "../_generated/server";
|
|
360
|
-
import { Effect } from "effect";
|
|
361
|
-
import { AgentService, AgentServiceLive } from "../services/agent.service";
|
|
362
|
-
import { RAGService, RAGServiceLive } from "../services/rag.service";
|
|
363
|
-
|
|
364
|
-
export const contextualChat = action({
|
|
365
|
-
args: { userId: v.string(), question: v.string() },
|
|
366
|
-
handler: (ctx, args) =>
|
|
367
|
-
Effect.gen(function* () {
|
|
368
|
-
// Inject both services
|
|
369
|
-
const agentService = yield* AgentService;
|
|
370
|
-
const ragService = yield* RAGService;
|
|
371
|
-
|
|
372
|
-
// 1. Fetch context from RAG
|
|
373
|
-
const context = yield* ragService.search(
|
|
374
|
-
ctx,
|
|
375
|
-
args.userId, // User-specific namespace
|
|
376
|
-
args.question,
|
|
377
|
-
5,
|
|
378
|
-
);
|
|
379
|
-
|
|
380
|
-
// 2. Generate answer with context
|
|
381
|
-
const answer = yield* agentService.generateResponse(
|
|
382
|
-
ctx,
|
|
383
|
-
args.threadId,
|
|
384
|
-
`${args.question}\n\nContext: ${context.text}`,
|
|
385
|
-
);
|
|
386
|
-
|
|
387
|
-
return {
|
|
388
|
-
answer,
|
|
389
|
-
sources: context.entries.map((e) => e.entryId),
|
|
390
|
-
};
|
|
391
|
-
}).pipe(
|
|
392
|
-
// Provide both service implementations
|
|
393
|
-
Effect.provide(Layer.merge(AgentServiceLive, RAGServiceLive)),
|
|
394
|
-
Effect.catchAll((error) =>
|
|
395
|
-
Effect.succeed({
|
|
396
|
-
answer: "I'm having trouble finding information.",
|
|
397
|
-
error: true,
|
|
398
|
-
}),
|
|
399
|
-
),
|
|
400
|
-
Effect.runPromise,
|
|
401
|
-
),
|
|
402
|
-
});
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
---
|
|
406
|
-
|
|
407
|
-
### Pattern 3: Error Handling Pattern (Tagged Errors) ✅ PRODUCTION-PROVEN
|
|
408
|
-
|
|
409
|
-
**When:** Need type-safe error handling with automatic propagation.
|
|
410
|
-
|
|
411
|
-
**Example: Layered Error Handling**
|
|
412
|
-
|
|
413
|
-
```typescript
|
|
414
|
-
// backend/convex/domain/agents/errors.ts
|
|
415
|
-
import { Data } from "effect";
|
|
416
|
-
|
|
417
|
-
// Domain errors (business logic)
|
|
418
|
-
export class UserNotFoundError extends Data.TaggedError("UserNotFoundError")<{
|
|
419
|
-
userId: string;
|
|
420
|
-
}> {}
|
|
421
|
-
|
|
422
|
-
export class InsufficientCreditsError extends Data.TaggedError(
|
|
423
|
-
"InsufficientCreditsError",
|
|
424
|
-
)<{
|
|
425
|
-
userId: string;
|
|
426
|
-
required: number;
|
|
427
|
-
available: number;
|
|
428
|
-
}> {}
|
|
429
|
-
|
|
430
|
-
// Infrastructure errors
|
|
431
|
-
export class AgentError extends Data.TaggedError("AgentError")<{
|
|
432
|
-
agentName: string;
|
|
433
|
-
cause: unknown;
|
|
434
|
-
}> {}
|
|
435
|
-
|
|
436
|
-
export class RateLimitError extends Data.TaggedError("RateLimitError")<{
|
|
437
|
-
retryAfter: number;
|
|
438
|
-
}> {}
|
|
439
|
-
|
|
440
|
-
export class NetworkError extends Data.TaggedError("NetworkError")<{
|
|
441
|
-
endpoint: string;
|
|
442
|
-
cause: unknown;
|
|
443
|
-
}> {}
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
**Handling Errors at Appropriate Layers:**
|
|
447
|
-
|
|
448
|
-
```typescript
|
|
449
|
-
// backend/convex/api/premium-chat.ts
|
|
450
|
-
import { action } from "../_generated/server";
|
|
451
|
-
import { Effect, Schedule } from "effect";
|
|
452
|
-
import { AgentService, AgentServiceLive } from "../services/agent.service";
|
|
453
|
-
import {
|
|
454
|
-
UserNotFoundError,
|
|
455
|
-
InsufficientCreditsError,
|
|
456
|
-
AgentError,
|
|
457
|
-
RateLimitError,
|
|
458
|
-
} from "../domain/agents/errors";
|
|
459
|
-
|
|
460
|
-
export const premiumChat = action({
|
|
461
|
-
args: { userId: v.string(), prompt: v.string() },
|
|
462
|
-
handler: (ctx, args) =>
|
|
463
|
-
Effect.gen(function* () {
|
|
464
|
-
// 1. Check user credits (can fail with UserNotFoundError or InsufficientCreditsError)
|
|
465
|
-
const user = yield* getUserWithCredits(ctx, args.userId);
|
|
466
|
-
|
|
467
|
-
// 2. Generate response (can fail with AgentError or RateLimitError)
|
|
468
|
-
const agentService = yield* AgentService;
|
|
469
|
-
const response = yield* agentService.generateResponse(
|
|
470
|
-
ctx,
|
|
471
|
-
user.threadId,
|
|
472
|
-
args.prompt,
|
|
473
|
-
);
|
|
474
|
-
|
|
475
|
-
// 3. Deduct credits
|
|
476
|
-
yield* deductCredits(ctx, args.userId, 10);
|
|
477
|
-
|
|
478
|
-
return { response };
|
|
479
|
-
}).pipe(
|
|
480
|
-
Effect.provide(AgentServiceLive),
|
|
481
|
-
|
|
482
|
-
// Handle domain errors specifically
|
|
483
|
-
Effect.catchTag("UserNotFoundError", (error) =>
|
|
484
|
-
Effect.succeed({
|
|
485
|
-
error: `User ${error.userId} not found`,
|
|
486
|
-
code: "USER_NOT_FOUND",
|
|
487
|
-
}),
|
|
488
|
-
),
|
|
489
|
-
Effect.catchTag("InsufficientCreditsError", (error) =>
|
|
490
|
-
Effect.succeed({
|
|
491
|
-
error: `Insufficient credits. Need ${error.required}, have ${error.available}`,
|
|
492
|
-
code: "INSUFFICIENT_CREDITS",
|
|
493
|
-
}),
|
|
494
|
-
),
|
|
495
|
-
|
|
496
|
-
// Handle infrastructure errors with retry
|
|
497
|
-
Effect.catchTag("RateLimitError", (error) =>
|
|
498
|
-
Effect.sleep(`${error.retryAfter} seconds`).pipe(
|
|
499
|
-
Effect.flatMap(() => premiumChat.handler(ctx, args)),
|
|
500
|
-
),
|
|
501
|
-
),
|
|
502
|
-
Effect.catchTag("AgentError", (error) =>
|
|
503
|
-
Effect.retry(
|
|
504
|
-
Effect.fail(error),
|
|
505
|
-
Schedule.exponential("1 second").pipe(
|
|
506
|
-
Schedule.compose(Schedule.recurs(2)),
|
|
507
|
-
),
|
|
508
|
-
).pipe(
|
|
509
|
-
Effect.catchAll(() =>
|
|
510
|
-
Effect.succeed({
|
|
511
|
-
error: "Agent temporarily unavailable",
|
|
512
|
-
code: "AGENT_ERROR",
|
|
513
|
-
}),
|
|
514
|
-
),
|
|
515
|
-
),
|
|
516
|
-
),
|
|
517
|
-
|
|
518
|
-
// Catch-all for unexpected errors
|
|
519
|
-
Effect.catchAll((error) => {
|
|
520
|
-
console.error("Unexpected error:", error);
|
|
521
|
-
return Effect.succeed({
|
|
522
|
-
error: "Something went wrong",
|
|
523
|
-
code: "UNKNOWN_ERROR",
|
|
524
|
-
});
|
|
525
|
-
}),
|
|
526
|
-
|
|
527
|
-
Effect.runPromise,
|
|
528
|
-
),
|
|
529
|
-
});
|
|
530
|
-
```
|
|
531
|
-
|
|
532
|
-
**Key Pattern:** Handle errors at the layer where you can do something about them. Domain errors → immediate user feedback. Infrastructure errors → retry/fallback logic.
|
|
533
|
-
|
|
534
|
-
---
|
|
535
|
-
|
|
536
|
-
### Pattern 4: Parallel Execution Pattern (Effect.all) ✅ PRODUCTION-PROVEN
|
|
537
|
-
|
|
538
|
-
**When:** Need to run multiple operations concurrently with controlled parallelism.
|
|
539
|
-
|
|
540
|
-
**Example: Multi-Agent Research Pipeline**
|
|
541
|
-
|
|
542
|
-
```typescript
|
|
543
|
-
// backend/convex/domain/agents/research.ts
|
|
544
|
-
import { Effect } from "effect";
|
|
545
|
-
import { AgentService } from "../../services/agent.service";
|
|
546
|
-
|
|
547
|
-
export const conductResearch = (query: string) =>
|
|
548
|
-
Effect.gen(function* () {
|
|
549
|
-
const agentService = yield* AgentService;
|
|
550
|
-
|
|
551
|
-
// Run 3 agents in parallel with max concurrency of 2
|
|
552
|
-
const [webResults, academicResults, newsResults] = yield* Effect.all(
|
|
553
|
-
[
|
|
554
|
-
agentService.generateResponse(ctx, "web-agent", `Web search: ${query}`),
|
|
555
|
-
agentService.generateResponse(
|
|
556
|
-
ctx,
|
|
557
|
-
"academic-agent",
|
|
558
|
-
`Academic search: ${query}`,
|
|
559
|
-
),
|
|
560
|
-
agentService.generateResponse(
|
|
561
|
-
ctx,
|
|
562
|
-
"news-agent",
|
|
563
|
-
`News search: ${query}`,
|
|
564
|
-
),
|
|
565
|
-
],
|
|
566
|
-
{
|
|
567
|
-
concurrency: 2, // Max 2 concurrent operations
|
|
568
|
-
mode: "default", // Fail fast on first error
|
|
569
|
-
},
|
|
570
|
-
);
|
|
571
|
-
|
|
572
|
-
// Synthesize results
|
|
573
|
-
const synthesis = yield* agentService.generateResponse(
|
|
574
|
-
ctx,
|
|
575
|
-
"synthesis-agent",
|
|
576
|
-
`Synthesize these findings:\n\nWeb: ${webResults}\n\nAcademic: ${academicResults}\n\nNews: ${newsResults}`,
|
|
577
|
-
);
|
|
578
|
-
|
|
579
|
-
return synthesis;
|
|
580
|
-
});
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
**Parallel with Graceful Degradation:**
|
|
584
|
-
|
|
585
|
-
```typescript
|
|
586
|
-
// backend/convex/domain/agents/quality-check.ts
|
|
587
|
-
import { Effect } from "effect";
|
|
588
|
-
|
|
589
|
-
export const qualityCheckWithGracefulDegradation = (response: string) =>
|
|
590
|
-
Effect.gen(function* () {
|
|
591
|
-
// Run quality checks in parallel, continue even if some fail
|
|
592
|
-
const results = yield* Effect.all(
|
|
593
|
-
[
|
|
594
|
-
checkGrammar(response).pipe(
|
|
595
|
-
Effect.catchAll(() => Effect.succeed({ score: 1.0, passed: true })),
|
|
596
|
-
),
|
|
597
|
-
checkFactuality(response).pipe(
|
|
598
|
-
Effect.catchAll(() => Effect.succeed({ score: 1.0, passed: true })),
|
|
599
|
-
),
|
|
600
|
-
checkToxicity(response).pipe(
|
|
601
|
-
Effect.catchAll(() => Effect.succeed({ score: 0.0, passed: true })),
|
|
602
|
-
),
|
|
603
|
-
],
|
|
604
|
-
{
|
|
605
|
-
concurrency: 3,
|
|
606
|
-
mode: "default",
|
|
607
|
-
},
|
|
608
|
-
);
|
|
609
|
-
|
|
610
|
-
const [grammar, factuality, toxicity] = results;
|
|
611
|
-
|
|
612
|
-
return {
|
|
613
|
-
overallScore:
|
|
614
|
-
(grammar.score + factuality.score + (1 - toxicity.score)) / 3,
|
|
615
|
-
passed: grammar.passed && factuality.passed && toxicity.passed,
|
|
616
|
-
};
|
|
617
|
-
});
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
**Parallel Batch Processing:**
|
|
621
|
-
|
|
622
|
-
```typescript
|
|
623
|
-
// backend/convex/api/batch-process.ts
|
|
624
|
-
import { action } from "../_generated/server";
|
|
625
|
-
import { Effect } from "effect";
|
|
626
|
-
|
|
627
|
-
export const processBatch = action({
|
|
628
|
-
args: { items: v.array(v.string()) },
|
|
629
|
-
handler: (ctx, args) =>
|
|
630
|
-
Effect.gen(function* () {
|
|
631
|
-
// Process items with controlled parallelism
|
|
632
|
-
const results = yield* Effect.all(
|
|
633
|
-
args.items.map((item) => processItem(ctx, item)),
|
|
634
|
-
{
|
|
635
|
-
concurrency: 5, // Process 5 items at a time
|
|
636
|
-
mode: "either", // Continue even if some fail
|
|
637
|
-
},
|
|
638
|
-
);
|
|
639
|
-
|
|
640
|
-
// Separate successes and failures
|
|
641
|
-
const successes = results.filter((r) => Effect.isSuccess(r));
|
|
642
|
-
const failures = results.filter((r) => Effect.isFailure(r));
|
|
643
|
-
|
|
644
|
-
return {
|
|
645
|
-
successCount: successes.length,
|
|
646
|
-
failureCount: failures.length,
|
|
647
|
-
results,
|
|
648
|
-
};
|
|
649
|
-
}).pipe(Effect.provide(/* layers */), Effect.runPromise),
|
|
650
|
-
});
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
---
|
|
654
|
-
|
|
655
|
-
### Pattern 5: Resource Management Pattern (Effect.scoped) ✅ PRODUCTION-PROVEN
|
|
656
|
-
|
|
657
|
-
**When:** Managing resources (connections, streams, file handles) that need cleanup.
|
|
658
|
-
|
|
659
|
-
**Example: Database Connection Pool**
|
|
660
|
-
|
|
661
|
-
```typescript
|
|
662
|
-
// backend/convex/services/database.service.ts
|
|
663
|
-
import { Effect, Context, Layer, Scope } from "effect";
|
|
664
|
-
|
|
665
|
-
class DatabaseService extends Context.Tag("DatabaseService")<
|
|
666
|
-
DatabaseService,
|
|
667
|
-
{
|
|
668
|
-
readonly query: <A>(
|
|
669
|
-
sql: string,
|
|
670
|
-
params: any[],
|
|
671
|
-
) => Effect.Effect<A[], Error>;
|
|
672
|
-
readonly transaction: <A>(
|
|
673
|
-
fn: (tx: Transaction) => Effect.Effect<A, Error>,
|
|
674
|
-
) => Effect.Effect<A, Error>;
|
|
675
|
-
}
|
|
676
|
-
>() {}
|
|
677
|
-
|
|
678
|
-
const DatabaseServiceLive = Layer.scoped(
|
|
679
|
-
DatabaseService,
|
|
680
|
-
Effect.gen(function* () {
|
|
681
|
-
// Acquire connection pool (will be released automatically)
|
|
682
|
-
const pool = yield* Effect.acquireRelease(
|
|
683
|
-
Effect.sync(() => createConnectionPool({ size: 10 })),
|
|
684
|
-
(pool) => Effect.sync(() => pool.close()),
|
|
685
|
-
);
|
|
686
|
-
|
|
687
|
-
return {
|
|
688
|
-
query: (sql, params) =>
|
|
689
|
-
Effect.tryPromise({
|
|
690
|
-
try: async () => {
|
|
691
|
-
const conn = await pool.acquire();
|
|
692
|
-
try {
|
|
693
|
-
return await conn.query(sql, params);
|
|
694
|
-
} finally {
|
|
695
|
-
pool.release(conn);
|
|
696
|
-
}
|
|
697
|
-
},
|
|
698
|
-
catch: (error) => new Error(String(error)),
|
|
699
|
-
}),
|
|
700
|
-
|
|
701
|
-
transaction: (fn) =>
|
|
702
|
-
Effect.scoped(
|
|
703
|
-
Effect.gen(function* () {
|
|
704
|
-
// Acquire transaction (will rollback on error, commit on success)
|
|
705
|
-
const tx = yield* Effect.acquireRelease(
|
|
706
|
-
Effect.tryPromise({
|
|
707
|
-
try: () => pool.beginTransaction(),
|
|
708
|
-
catch: (error) => new Error(String(error)),
|
|
709
|
-
}),
|
|
710
|
-
(tx) => Effect.sync(() => tx.rollback()),
|
|
711
|
-
);
|
|
712
|
-
|
|
713
|
-
const result = yield* fn(tx);
|
|
714
|
-
|
|
715
|
-
yield* Effect.tryPromise({
|
|
716
|
-
try: () => tx.commit(),
|
|
717
|
-
catch: (error) => new Error(String(error)),
|
|
718
|
-
});
|
|
719
|
-
|
|
720
|
-
return result;
|
|
721
|
-
}),
|
|
722
|
-
),
|
|
723
|
-
};
|
|
724
|
-
}),
|
|
725
|
-
);
|
|
726
|
-
```
|
|
727
|
-
|
|
728
|
-
**Example: Stream Processing with Cleanup**
|
|
729
|
-
|
|
730
|
-
```typescript
|
|
731
|
-
// backend/convex/services/streaming.service.ts
|
|
732
|
-
import { Effect, Stream } from "effect";
|
|
733
|
-
|
|
734
|
-
const processStreamWithCleanup = (streamUrl: string) =>
|
|
735
|
-
Effect.scoped(
|
|
736
|
-
Effect.gen(function* () {
|
|
737
|
-
// Acquire stream (will close on completion or error)
|
|
738
|
-
const stream = yield* Effect.acquireRelease(
|
|
739
|
-
Effect.tryPromise({
|
|
740
|
-
try: () => openStream(streamUrl),
|
|
741
|
-
catch: (error) => new Error(String(error)),
|
|
742
|
-
}),
|
|
743
|
-
(stream) => Effect.sync(() => stream.close()),
|
|
744
|
-
);
|
|
745
|
-
|
|
746
|
-
// Process chunks
|
|
747
|
-
const results: string[] = [];
|
|
748
|
-
|
|
749
|
-
yield* Stream.fromAsyncIterable(
|
|
750
|
-
stream,
|
|
751
|
-
() => new Error("Stream failed"),
|
|
752
|
-
).pipe(
|
|
753
|
-
Stream.mapEffect((chunk) =>
|
|
754
|
-
Effect.gen(function* () {
|
|
755
|
-
const processed = yield* processChunk(chunk);
|
|
756
|
-
results.push(processed);
|
|
757
|
-
return processed;
|
|
758
|
-
}),
|
|
759
|
-
),
|
|
760
|
-
Stream.runDrain,
|
|
761
|
-
);
|
|
762
|
-
|
|
763
|
-
return results;
|
|
764
|
-
}),
|
|
765
|
-
);
|
|
766
|
-
```
|
|
767
|
-
|
|
768
|
-
---
|
|
769
|
-
|
|
770
|
-
### Pattern 6: Retry and Timeout Patterns ✅ PRODUCTION-PROVEN
|
|
771
|
-
|
|
772
|
-
**When:** Calling unreliable external APIs or LLM services.
|
|
773
|
-
|
|
774
|
-
**Example: Exponential Backoff Retry**
|
|
775
|
-
|
|
776
|
-
```typescript
|
|
777
|
-
// backend/convex/services/llm.service.ts
|
|
778
|
-
import { Effect, Schedule } from "effect";
|
|
779
|
-
|
|
780
|
-
class LLMService extends Context.Tag("LLMService")<
|
|
781
|
-
LLMService,
|
|
782
|
-
{
|
|
783
|
-
readonly complete: (prompt: string) => Effect.Effect<string, LLMError>;
|
|
784
|
-
}
|
|
785
|
-
>() {}
|
|
786
|
-
|
|
787
|
-
const LLMServiceLive = Layer.succeed(LLMService, {
|
|
788
|
-
complete: (prompt) =>
|
|
789
|
-
Effect.tryPromise({
|
|
790
|
-
try: () =>
|
|
791
|
-
openai.chat.completions.create({
|
|
792
|
-
model: "gpt-4o-mini",
|
|
793
|
-
messages: [{ role: "user", content: prompt }],
|
|
794
|
-
}),
|
|
795
|
-
catch: (error) => new LLMError({ cause: error }),
|
|
796
|
-
}).pipe(
|
|
797
|
-
// Retry with exponential backoff
|
|
798
|
-
Effect.retry(
|
|
799
|
-
Schedule.exponential("500 millis").pipe(
|
|
800
|
-
Schedule.compose(Schedule.recurs(3)), // Max 3 retries
|
|
801
|
-
Schedule.compose(
|
|
802
|
-
Schedule.elapsed.pipe(
|
|
803
|
-
Schedule.whileOutput((duration) => duration < 30_000), // Max 30s total
|
|
804
|
-
),
|
|
805
|
-
),
|
|
806
|
-
),
|
|
807
|
-
),
|
|
808
|
-
Effect.map((result) => result.choices[0].message.content),
|
|
809
|
-
),
|
|
810
|
-
});
|
|
811
|
-
```
|
|
812
|
-
|
|
813
|
-
**Example: Timeout with Fallback**
|
|
814
|
-
|
|
815
|
-
```typescript
|
|
816
|
-
// backend/convex/domain/agents/robust-generation.ts
|
|
817
|
-
import { Effect, Schedule } from "effect";
|
|
818
|
-
|
|
819
|
-
export const robustGeneration = (prompt: string) =>
|
|
820
|
-
Effect.gen(function* () {
|
|
821
|
-
const llmService = yield* LLMService;
|
|
822
|
-
|
|
823
|
-
// Try primary model with timeout
|
|
824
|
-
const result = yield* llmService.complete(prompt).pipe(
|
|
825
|
-
Effect.timeout("10 seconds"),
|
|
826
|
-
Effect.catchTag("TimeoutError", () =>
|
|
827
|
-
// Fallback 1: Reduce prompt length and retry
|
|
828
|
-
llmService.complete(truncate(prompt, 1000)).pipe(
|
|
829
|
-
Effect.timeout("10 seconds"),
|
|
830
|
-
Effect.catchTag("TimeoutError", () =>
|
|
831
|
-
// Fallback 2: Use faster model
|
|
832
|
-
llmService.completeFast(truncate(prompt, 500)).pipe(
|
|
833
|
-
Effect.timeout("5 seconds"),
|
|
834
|
-
Effect.catchTag("TimeoutError", () =>
|
|
835
|
-
// Fallback 3: Return cached response
|
|
836
|
-
getCachedResponse(prompt).pipe(
|
|
837
|
-
Effect.catchAll(() =>
|
|
838
|
-
Effect.succeed(
|
|
839
|
-
"I'm experiencing technical difficulties. Please try again.",
|
|
840
|
-
),
|
|
841
|
-
),
|
|
842
|
-
),
|
|
843
|
-
),
|
|
844
|
-
),
|
|
845
|
-
),
|
|
846
|
-
),
|
|
847
|
-
),
|
|
848
|
-
);
|
|
849
|
-
|
|
850
|
-
return result;
|
|
851
|
-
});
|
|
852
|
-
```
|
|
853
|
-
|
|
854
|
-
**Example: Conditional Retry (Only on Specific Errors)**
|
|
855
|
-
|
|
856
|
-
```typescript
|
|
857
|
-
// backend/convex/services/external-api.service.ts
|
|
858
|
-
import { Effect, Schedule } from "effect";
|
|
859
|
-
|
|
860
|
-
const callExternalAPI = (endpoint: string, body: any) =>
|
|
861
|
-
Effect.tryPromise({
|
|
862
|
-
try: () => fetch(endpoint, { method: "POST", body: JSON.stringify(body) }),
|
|
863
|
-
catch: (error) => new NetworkError({ endpoint, cause: error }),
|
|
864
|
-
}).pipe(
|
|
865
|
-
// Only retry on rate limit errors
|
|
866
|
-
Effect.retry(
|
|
867
|
-
Schedule.exponential("1 second").pipe(
|
|
868
|
-
Schedule.whileInput(
|
|
869
|
-
(error: NetworkError) =>
|
|
870
|
-
error.cause instanceof Response && error.cause.status === 429,
|
|
871
|
-
),
|
|
872
|
-
Schedule.compose(Schedule.recurs(5)),
|
|
873
|
-
),
|
|
874
|
-
),
|
|
875
|
-
);
|
|
876
|
-
```
|
|
877
|
-
|
|
878
|
-
---
|
|
879
|
-
|
|
880
|
-
## Section 3: Component Integration Checklists
|
|
881
|
-
|
|
882
|
-
### @convex-dev/agent - Agent Service
|
|
883
|
-
|
|
884
|
-
**When to Wrap:** Multi-agent orchestration, custom error handling, composing with RAG/rate limiting.
|
|
885
|
-
|
|
886
|
-
**Pattern:**
|
|
887
|
-
|
|
888
|
-
```typescript
|
|
889
|
-
import { Agent } from "@convex-dev/agent";
|
|
890
|
-
import { Effect, Context, Layer } from "effect";
|
|
891
|
-
|
|
892
|
-
// 1. Define errors
|
|
893
|
-
class AgentError extends Data.TaggedError("AgentError")<{
|
|
894
|
-
agentName: string;
|
|
895
|
-
cause: unknown;
|
|
896
|
-
}> {}
|
|
897
|
-
|
|
898
|
-
// 2. Define service
|
|
899
|
-
class AgentService extends Context.Tag("AgentService")<
|
|
900
|
-
AgentService,
|
|
901
|
-
{
|
|
902
|
-
readonly generateResponse: (
|
|
903
|
-
ctx,
|
|
904
|
-
threadId,
|
|
905
|
-
prompt,
|
|
906
|
-
) => Effect.Effect<string, AgentError>;
|
|
907
|
-
}
|
|
908
|
-
>() {}
|
|
909
|
-
|
|
910
|
-
// 3. Implement with component
|
|
911
|
-
const AgentServiceLive = Layer.effect(
|
|
912
|
-
AgentService,
|
|
913
|
-
Effect.gen(function* () {
|
|
914
|
-
const agent = new Agent(components.agent, {
|
|
915
|
-
/* config */
|
|
916
|
-
});
|
|
917
|
-
|
|
918
|
-
return {
|
|
919
|
-
generateResponse: (ctx, threadId, prompt) =>
|
|
920
|
-
Effect.tryPromise({
|
|
921
|
-
try: async () => {
|
|
922
|
-
const { thread } = await agent.continueThread(ctx, { threadId });
|
|
923
|
-
const result = await thread.generateText({ prompt });
|
|
924
|
-
return result.text;
|
|
925
|
-
},
|
|
926
|
-
catch: (error) => new AgentError({ agentName: "...", cause: error }),
|
|
927
|
-
}),
|
|
928
|
-
};
|
|
929
|
-
}),
|
|
930
|
-
);
|
|
931
|
-
```
|
|
932
|
-
|
|
933
|
-
**Checklist:**
|
|
934
|
-
|
|
935
|
-
- [ ] Wrap agent calls in `Effect.tryPromise`
|
|
936
|
-
- [ ] Define `AgentError` with tagged class
|
|
937
|
-
- [ ] Create service interface with `Context.Tag`
|
|
938
|
-
- [ ] Implement with `Layer.effect`
|
|
939
|
-
- [ ] Inject dependencies (RateLimitService, RAGService) if needed
|
|
940
|
-
- [ ] Handle errors with `Effect.catchTag`
|
|
941
|
-
- [ ] Test with mock layer (TestAgentServiceLive)
|
|
942
|
-
|
|
943
|
-
---
|
|
944
|
-
|
|
945
|
-
### @convex-dev/workflow - Workflow Service
|
|
946
|
-
|
|
947
|
-
**When to Use Workflow vs Effect:**
|
|
948
|
-
|
|
949
|
-
- **Use Workflow for:** Long-running, durable operations (hours/days), need journaling, external actions
|
|
950
|
-
- **Use Effect for:** Business logic in workflow steps, error handling within steps, service composition
|
|
951
|
-
|
|
952
|
-
**Pattern: Effect in Workflow Steps**
|
|
953
|
-
|
|
954
|
-
```typescript
|
|
955
|
-
import { WorkflowManager } from "@convex-dev/workflow";
|
|
956
|
-
import { Effect } from "effect";
|
|
957
|
-
|
|
958
|
-
const workflow = new WorkflowManager(components.workflow);
|
|
959
|
-
|
|
960
|
-
export const researchWorkflow = workflow.define({
|
|
961
|
-
args: { query: v.string() },
|
|
962
|
-
handler: async (step, args): Promise<ResearchResult> => {
|
|
963
|
-
// Step 1: Fetch context (query)
|
|
964
|
-
const context = await step.runQuery(internal.workflows.getContext, {
|
|
965
|
-
query: args.query,
|
|
966
|
-
});
|
|
967
|
-
|
|
968
|
-
// Step 2: Generate with Effect composition (action)
|
|
969
|
-
const analysis = await step.runAction(
|
|
970
|
-
internal.workflows.analyzeWithEffect,
|
|
971
|
-
{ query: args.query, context },
|
|
972
|
-
);
|
|
973
|
-
|
|
974
|
-
// Step 3: Quality check in parallel
|
|
975
|
-
const [grammar, factuality] = await Promise.all([
|
|
976
|
-
step.runAction(internal.workflows.checkGrammar, { text: analysis }),
|
|
977
|
-
step.runAction(internal.workflows.checkFactuality, { text: analysis }),
|
|
978
|
-
]);
|
|
979
|
-
|
|
980
|
-
// Step 4: Refine if needed
|
|
981
|
-
const refined =
|
|
982
|
-
grammar.score < 0.8 || factuality.score < 0.8
|
|
983
|
-
? await step.runAction(
|
|
984
|
-
internal.workflows.refineResponse,
|
|
985
|
-
{ original: analysis, context },
|
|
986
|
-
{ retry: { maxAttempts: 2 } },
|
|
987
|
-
)
|
|
988
|
-
: analysis;
|
|
989
|
-
|
|
990
|
-
return { result: refined };
|
|
991
|
-
},
|
|
992
|
-
});
|
|
993
|
-
|
|
994
|
-
// The action uses Effect internally
|
|
995
|
-
export const analyzeWithEffect = internalAction({
|
|
996
|
-
args: { query: v.string(), context: v.any() },
|
|
997
|
-
handler: async (ctx, args) => {
|
|
998
|
-
const program = Effect.gen(function* () {
|
|
999
|
-
const agentService = yield* AgentService;
|
|
1000
|
-
const ragService = yield* RAGService;
|
|
1001
|
-
|
|
1002
|
-
const enriched = yield* ragService.search(ctx, "global", args.query, 5);
|
|
1003
|
-
const result = yield* agentService.generateResponse(
|
|
1004
|
-
ctx,
|
|
1005
|
-
"analysis-thread",
|
|
1006
|
-
`${args.query}\n\nContext: ${args.context}\n\nAdditional: ${enriched.text}`,
|
|
1007
|
-
);
|
|
1008
|
-
|
|
1009
|
-
return result;
|
|
1010
|
-
});
|
|
1011
|
-
|
|
1012
|
-
return await Effect.runPromise(
|
|
1013
|
-
program.pipe(
|
|
1014
|
-
Effect.provide(Layer.merge(AgentServiceLive, RAGServiceLive)),
|
|
1015
|
-
Effect.catchAll((error) => {
|
|
1016
|
-
console.error("Analysis failed:", error);
|
|
1017
|
-
return Effect.succeed("Analysis unavailable");
|
|
1018
|
-
}),
|
|
1019
|
-
),
|
|
1020
|
-
);
|
|
1021
|
-
},
|
|
1022
|
-
});
|
|
1023
|
-
```
|
|
1024
|
-
|
|
1025
|
-
**Checklist:**
|
|
1026
|
-
|
|
1027
|
-
- [ ] Use Workflow component for durability (step-level retries, journaling)
|
|
1028
|
-
- [ ] Use Effect in actions called by workflow steps
|
|
1029
|
-
- [ ] Provide service layers in actions
|
|
1030
|
-
- [ ] Convert Effect to Promise with `Effect.runPromise`
|
|
1031
|
-
- [ ] Handle errors with `Effect.catchAll` before running
|
|
1032
|
-
- [ ] Test workflow steps independently with mock layers
|
|
1033
|
-
|
|
1034
|
-
---
|
|
1035
|
-
|
|
1036
|
-
### @convex-dev/rag - RAG Service
|
|
1037
|
-
|
|
1038
|
-
**When to Wrap:** Composing search with other services, custom pre-processing, error handling.
|
|
1039
|
-
|
|
1040
|
-
**Pattern:**
|
|
1041
|
-
|
|
1042
|
-
```typescript
|
|
1043
|
-
import { RAG } from "@convex-dev/rag";
|
|
1044
|
-
import { Effect, Context, Layer } from "effect";
|
|
1045
|
-
|
|
1046
|
-
class RAGError extends Data.TaggedError("RAGError")<{
|
|
1047
|
-
operation: string;
|
|
1048
|
-
cause: unknown;
|
|
1049
|
-
}> {}
|
|
1050
|
-
|
|
1051
|
-
class RAGService extends Context.Tag("RAGService")<
|
|
1052
|
-
RAGService,
|
|
1053
|
-
{
|
|
1054
|
-
readonly addDocument: (
|
|
1055
|
-
ctx,
|
|
1056
|
-
namespace,
|
|
1057
|
-
content,
|
|
1058
|
-
metadata,
|
|
1059
|
-
) => Effect.Effect<string, RAGError>;
|
|
1060
|
-
readonly search: (
|
|
1061
|
-
ctx,
|
|
1062
|
-
namespace,
|
|
1063
|
-
query,
|
|
1064
|
-
limit?,
|
|
1065
|
-
) => Effect.Effect<{ text: string; entries: any[] }, RAGError>;
|
|
1066
|
-
}
|
|
1067
|
-
>() {}
|
|
1068
|
-
|
|
1069
|
-
const RAGServiceLive = Layer.effect(
|
|
1070
|
-
RAGService,
|
|
1071
|
-
Effect.gen(function* () {
|
|
1072
|
-
const rag = new RAG(components.rag, {
|
|
1073
|
-
textEmbeddingModel: openai.embedding("text-embedding-3-small"),
|
|
1074
|
-
embeddingDimension: 1536,
|
|
1075
|
-
});
|
|
1076
|
-
|
|
1077
|
-
return {
|
|
1078
|
-
addDocument: (ctx, namespace, content, metadata) =>
|
|
1079
|
-
Effect.tryPromise({
|
|
1080
|
-
try: async () => {
|
|
1081
|
-
const result = await rag.add(ctx, {
|
|
1082
|
-
namespace,
|
|
1083
|
-
text: content,
|
|
1084
|
-
filterValues: [],
|
|
1085
|
-
});
|
|
1086
|
-
return result.entryId;
|
|
1087
|
-
},
|
|
1088
|
-
catch: (error) =>
|
|
1089
|
-
new RAGError({ operation: "addDocument", cause: error }),
|
|
1090
|
-
}),
|
|
1091
|
-
|
|
1092
|
-
search: (ctx, namespace, query, limit = 10) =>
|
|
1093
|
-
Effect.tryPromise({
|
|
1094
|
-
try: async () => {
|
|
1095
|
-
const results = await rag.search(ctx, { namespace, query, limit });
|
|
1096
|
-
return { text: results.text, entries: results.entries };
|
|
1097
|
-
},
|
|
1098
|
-
catch: (error) => new RAGError({ operation: "search", cause: error }),
|
|
1099
|
-
}),
|
|
1100
|
-
};
|
|
1101
|
-
}),
|
|
1102
|
-
);
|
|
1103
|
-
```
|
|
1104
|
-
|
|
1105
|
-
**Checklist:**
|
|
1106
|
-
|
|
1107
|
-
- [ ] Wrap `rag.add()` and `rag.search()` in `Effect.tryPromise`
|
|
1108
|
-
- [ ] Define `RAGError` with operation name
|
|
1109
|
-
- [ ] Create service interface with `Context.Tag`
|
|
1110
|
-
- [ ] Implement with `Layer.effect`
|
|
1111
|
-
- [ ] Compose with AgentService for contextual responses
|
|
1112
|
-
- [ ] Handle errors with `Effect.catchTag`
|
|
1113
|
-
- [ ] Test with TestRAGServiceLive (mock embeddings)
|
|
1114
|
-
|
|
1115
|
-
---
|
|
1116
|
-
|
|
1117
|
-
### @convex-dev/rate-limiter - Rate Limit Service
|
|
1118
|
-
|
|
1119
|
-
**When to Wrap:** Multiple rate limits, composing with business logic, custom retry.
|
|
1120
|
-
|
|
1121
|
-
**Pattern:**
|
|
1122
|
-
|
|
1123
|
-
```typescript
|
|
1124
|
-
import { RateLimiter, MINUTE } from "@convex-dev/rate-limiter";
|
|
1125
|
-
import { Effect, Context, Layer, Schedule } from "effect";
|
|
1126
|
-
|
|
1127
|
-
class RateLimitError extends Data.TaggedError("RateLimitError")<{
|
|
1128
|
-
type: string;
|
|
1129
|
-
retryAfter: number;
|
|
1130
|
-
}> {}
|
|
1131
|
-
|
|
1132
|
-
class RateLimitService extends Context.Tag("RateLimitService")<
|
|
1133
|
-
RateLimitService,
|
|
1134
|
-
{
|
|
1135
|
-
readonly checkLimit: (
|
|
1136
|
-
ctx,
|
|
1137
|
-
key,
|
|
1138
|
-
count?,
|
|
1139
|
-
) => Effect.Effect<boolean, RateLimitError>;
|
|
1140
|
-
}
|
|
1141
|
-
>() {}
|
|
1142
|
-
|
|
1143
|
-
const RateLimitServiceLive = Layer.effect(
|
|
1144
|
-
RateLimitService,
|
|
1145
|
-
Effect.gen(function* () {
|
|
1146
|
-
const limiter = new RateLimiter(components.rateLimiter, {
|
|
1147
|
-
requests: { kind: "token bucket", rate: 20, period: MINUTE },
|
|
1148
|
-
});
|
|
1149
|
-
|
|
1150
|
-
return {
|
|
1151
|
-
checkLimit: (ctx, key, count = 1) =>
|
|
1152
|
-
Effect.gen(function* () {
|
|
1153
|
-
const result = yield* Effect.tryPromise({
|
|
1154
|
-
try: () => limiter.limit(ctx, "requests", { key, count }),
|
|
1155
|
-
catch: (error) => new Error(String(error)),
|
|
1156
|
-
});
|
|
1157
|
-
|
|
1158
|
-
if (!result.ok) {
|
|
1159
|
-
return yield* Effect.fail(
|
|
1160
|
-
new RateLimitError({
|
|
1161
|
-
type: "requests",
|
|
1162
|
-
retryAfter: result.retryAfter,
|
|
1163
|
-
}),
|
|
1164
|
-
);
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
return true;
|
|
1168
|
-
}),
|
|
1169
|
-
};
|
|
1170
|
-
}),
|
|
1171
|
-
);
|
|
1172
|
-
```
|
|
1173
|
-
|
|
1174
|
-
**Checklist:**
|
|
1175
|
-
|
|
1176
|
-
- [ ] Wrap `limiter.limit()` in `Effect.tryPromise`
|
|
1177
|
-
- [ ] Check `result.ok` and fail with `RateLimitError` if exceeded
|
|
1178
|
-
- [ ] Define `RateLimitError` with `retryAfter` field
|
|
1179
|
-
- [ ] Compose with other services (agent, RAG)
|
|
1180
|
-
- [ ] Handle rate limit errors with retry or user feedback
|
|
1181
|
-
- [ ] Test with TestRateLimitServiceLive (always pass or always fail)
|
|
1182
|
-
|
|
1183
|
-
---
|
|
1184
|
-
|
|
1185
|
-
### @convex-dev/retrier - Retrier Service
|
|
1186
|
-
|
|
1187
|
-
**When to Use:** Action-level retries with persistent state vs Effect.retry for in-memory retries.
|
|
1188
|
-
|
|
1189
|
-
**Pattern: Hybrid Retrier + Effect.retry**
|
|
1190
|
-
|
|
1191
|
-
```typescript
|
|
1192
|
-
import { ActionRetrier } from "@convex-dev/action-retrier";
|
|
1193
|
-
import { Effect, Schedule } from "effect";
|
|
1194
|
-
|
|
1195
|
-
class ResilientExecutionService extends Context.Tag(
|
|
1196
|
-
"ResilientExecutionService",
|
|
1197
|
-
)<
|
|
1198
|
-
ResilientExecutionService,
|
|
1199
|
-
{
|
|
1200
|
-
readonly executeWithRetry: <A>(
|
|
1201
|
-
ctx,
|
|
1202
|
-
action,
|
|
1203
|
-
args,
|
|
1204
|
-
) => Effect.Effect<A, ExecutionError>;
|
|
1205
|
-
}
|
|
1206
|
-
>() {}
|
|
1207
|
-
|
|
1208
|
-
const ResilientExecutionServiceLive = Layer.effect(
|
|
1209
|
-
ResilientExecutionService,
|
|
1210
|
-
Effect.gen(function* () {
|
|
1211
|
-
const retrier = new ActionRetrier(components.actionRetrier, {
|
|
1212
|
-
initialBackoffMs: 250,
|
|
1213
|
-
base: 2,
|
|
1214
|
-
maxFailures: 4,
|
|
1215
|
-
});
|
|
1216
|
-
|
|
1217
|
-
return {
|
|
1218
|
-
executeWithRetry: (ctx, action, args) =>
|
|
1219
|
-
Effect.gen(function* () {
|
|
1220
|
-
// Use retrier for action-level retries
|
|
1221
|
-
const runId = yield* Effect.tryPromise({
|
|
1222
|
-
try: () => retrier.run(ctx, action, args),
|
|
1223
|
-
catch: () => new RetrierStartError(),
|
|
1224
|
-
});
|
|
1225
|
-
|
|
1226
|
-
// Poll for completion with Effect schedule
|
|
1227
|
-
const result = yield* Effect.repeat(
|
|
1228
|
-
Effect.gen(function* () {
|
|
1229
|
-
const status = yield* Effect.tryPromise({
|
|
1230
|
-
try: () => retrier.status(ctx, runId),
|
|
1231
|
-
catch: () => new StatusCheckError(),
|
|
1232
|
-
});
|
|
1233
|
-
|
|
1234
|
-
if (status.type === "inProgress") {
|
|
1235
|
-
return yield* Effect.fail(Option.none());
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
return status.result;
|
|
1239
|
-
}),
|
|
1240
|
-
Schedule.spaced("500 millis").pipe(
|
|
1241
|
-
Schedule.compose(Schedule.recurs(60)), // Max 30 seconds
|
|
1242
|
-
),
|
|
1243
|
-
);
|
|
1244
|
-
|
|
1245
|
-
if (result.type === "success") {
|
|
1246
|
-
return result.returnValue;
|
|
1247
|
-
} else {
|
|
1248
|
-
return yield* Effect.fail(
|
|
1249
|
-
new ExecutionFailed({ error: result.error }),
|
|
1250
|
-
);
|
|
1251
|
-
}
|
|
1252
|
-
}),
|
|
1253
|
-
};
|
|
1254
|
-
}),
|
|
1255
|
-
);
|
|
1256
|
-
```
|
|
1257
|
-
|
|
1258
|
-
**Checklist:**
|
|
1259
|
-
|
|
1260
|
-
- [ ] Use retrier for long-running actions with persistent state
|
|
1261
|
-
- [ ] Use Effect.retry for in-memory, short-lived operations
|
|
1262
|
-
- [ ] Poll for completion with `Effect.repeat` and `Schedule.spaced`
|
|
1263
|
-
- [ ] Handle completion status (success, failed, canceled)
|
|
1264
|
-
- [ ] Compose with other services
|
|
1265
|
-
- [ ] Test with TestResilientExecutionServiceLive
|
|
1266
|
-
|
|
1267
|
-
---
|
|
1268
|
-
|
|
1269
|
-
### @convex-dev/workpool - Task Queue Service
|
|
1270
|
-
|
|
1271
|
-
**When to Wrap:** Batch enqueuing, error handling for tasks, coordinating queues.
|
|
1272
|
-
|
|
1273
|
-
**Pattern:**
|
|
1274
|
-
|
|
1275
|
-
```typescript
|
|
1276
|
-
import { Workpool } from "@convex-dev/workpool";
|
|
1277
|
-
import { Effect, Context, Layer } from "effect";
|
|
1278
|
-
|
|
1279
|
-
class TaskQueueService extends Context.Tag("TaskQueueService")<
|
|
1280
|
-
TaskQueueService,
|
|
1281
|
-
{
|
|
1282
|
-
readonly enqueue: (
|
|
1283
|
-
ctx,
|
|
1284
|
-
priority,
|
|
1285
|
-
action,
|
|
1286
|
-
args,
|
|
1287
|
-
) => Effect.Effect<string, EnqueueError>;
|
|
1288
|
-
}
|
|
1289
|
-
>() {}
|
|
1290
|
-
|
|
1291
|
-
const TaskQueueServiceLive = Layer.effect(
|
|
1292
|
-
TaskQueueService,
|
|
1293
|
-
Effect.gen(function* () {
|
|
1294
|
-
const highPriority = new Workpool(components.highPriorityWorkpool, {
|
|
1295
|
-
maxParallelism: 20,
|
|
1296
|
-
});
|
|
1297
|
-
const lowPriority = new Workpool(components.lowPriorityWorkpool, {
|
|
1298
|
-
maxParallelism: 5,
|
|
1299
|
-
});
|
|
1300
|
-
|
|
1301
|
-
return {
|
|
1302
|
-
enqueue: (ctx, priority, action, args) =>
|
|
1303
|
-
Effect.tryPromise({
|
|
1304
|
-
try: async () => {
|
|
1305
|
-
const pool = priority === "high" ? highPriority : lowPriority;
|
|
1306
|
-
const taskId = await pool.enqueueAction(ctx, action, args);
|
|
1307
|
-
return taskId;
|
|
1308
|
-
},
|
|
1309
|
-
catch: (error) => new EnqueueError({ cause: error }),
|
|
1310
|
-
}),
|
|
1311
|
-
};
|
|
1312
|
-
}),
|
|
1313
|
-
);
|
|
1314
|
-
```
|
|
1315
|
-
|
|
1316
|
-
**Batch Enqueue:**
|
|
1317
|
-
|
|
1318
|
-
```typescript
|
|
1319
|
-
export const processBatch = mutation({
|
|
1320
|
-
args: { items: v.array(v.any()) },
|
|
1321
|
-
handler: (ctx, args) =>
|
|
1322
|
-
Effect.gen(function* () {
|
|
1323
|
-
const taskQueue = yield* TaskQueueService;
|
|
1324
|
-
|
|
1325
|
-
const taskIds = yield* Effect.all(
|
|
1326
|
-
args.items.map((item) =>
|
|
1327
|
-
taskQueue.enqueue(ctx, "low", internal.tasks.processItem, item),
|
|
1328
|
-
),
|
|
1329
|
-
{ concurrency: 10 },
|
|
1330
|
-
);
|
|
1331
|
-
|
|
1332
|
-
return { taskIds, count: taskIds.length };
|
|
1333
|
-
}).pipe(Effect.provide(TaskQueueServiceLive), Effect.runPromise),
|
|
1334
|
-
});
|
|
1335
|
-
```
|
|
1336
|
-
|
|
1337
|
-
**Checklist:**
|
|
1338
|
-
|
|
1339
|
-
- [ ] Wrap `workpool.enqueueAction()` in `Effect.tryPromise`
|
|
1340
|
-
- [ ] Support multiple priority queues
|
|
1341
|
-
- [ ] Use `Effect.all` for batch enqueuing with concurrency control
|
|
1342
|
-
- [ ] Handle enqueue errors with `Effect.catchTag`
|
|
1343
|
-
- [ ] Test with TestTaskQueueServiceLive
|
|
1344
|
-
|
|
1345
|
-
---
|
|
1346
|
-
|
|
1347
|
-
### @convex-dev/persistent-text-streaming - Streaming Service
|
|
1348
|
-
|
|
1349
|
-
**When to Use:** Generally, use Agent component's built-in streaming (`saveStreamDeltas: true`). Only wrap if you need custom stream processing.
|
|
1350
|
-
|
|
1351
|
-
**Pattern:**
|
|
1352
|
-
|
|
1353
|
-
```typescript
|
|
1354
|
-
import { PersistentTextStreaming } from "@convex-dev/persistent-text-streaming";
|
|
1355
|
-
import { Effect, Stream } from "effect";
|
|
1356
|
-
|
|
1357
|
-
class StreamingService extends Context.Tag("StreamingService")<
|
|
1358
|
-
StreamingService,
|
|
1359
|
-
{
|
|
1360
|
-
readonly processStream: (
|
|
1361
|
-
ctx,
|
|
1362
|
-
streamId,
|
|
1363
|
-
source,
|
|
1364
|
-
) => Effect.Effect<void, StreamError>;
|
|
1365
|
-
}
|
|
1366
|
-
>() {}
|
|
1367
|
-
|
|
1368
|
-
const StreamingServiceLive = Layer.effect(
|
|
1369
|
-
StreamingService,
|
|
1370
|
-
Effect.gen(function* () {
|
|
1371
|
-
const streaming = new PersistentTextStreaming(
|
|
1372
|
-
components.persistentTextStreaming,
|
|
1373
|
-
);
|
|
1374
|
-
|
|
1375
|
-
return {
|
|
1376
|
-
processStream: (ctx, streamId, source) =>
|
|
1377
|
-
Effect.gen(function* () {
|
|
1378
|
-
yield* Stream.fromAsyncIterable(source, () => new StreamError()).pipe(
|
|
1379
|
-
Stream.mapEffect((chunk) =>
|
|
1380
|
-
Effect.tryPromise({
|
|
1381
|
-
try: () => streaming.appendChunk(ctx, streamId, chunk),
|
|
1382
|
-
catch: () => new ChunkAppendError({ chunk }),
|
|
1383
|
-
}),
|
|
1384
|
-
),
|
|
1385
|
-
Stream.runDrain,
|
|
1386
|
-
);
|
|
1387
|
-
|
|
1388
|
-
yield* Effect.tryPromise({
|
|
1389
|
-
try: () =>
|
|
1390
|
-
ctx.runMutation(api.streaming.markComplete, { streamId }),
|
|
1391
|
-
catch: () => new StreamCompletionError(),
|
|
1392
|
-
});
|
|
1393
|
-
}),
|
|
1394
|
-
};
|
|
1395
|
-
}),
|
|
1396
|
-
);
|
|
1397
|
-
```
|
|
1398
|
-
|
|
1399
|
-
**Checklist:**
|
|
1400
|
-
|
|
1401
|
-
- [ ] Use Agent component's built-in streaming for most cases
|
|
1402
|
-
- [ ] Only wrap if you need custom processing (duplicate streams, filtering)
|
|
1403
|
-
- [ ] Use `Stream.fromAsyncIterable` for async sources
|
|
1404
|
-
- [ ] Use `Stream.mapEffect` for effectful processing
|
|
1405
|
-
- [ ] Handle backpressure with `Stream.buffer`
|
|
1406
|
-
- [ ] Always mark stream complete or failed
|
|
1407
|
-
|
|
1408
|
-
---
|
|
1409
|
-
|
|
1410
|
-
### @convex-dev/crons - Cron Service
|
|
1411
|
-
|
|
1412
|
-
**When to Wrap:** Cron job logic needs composition with other services.
|
|
1413
|
-
|
|
1414
|
-
**Pattern:**
|
|
1415
|
-
|
|
1416
|
-
```typescript
|
|
1417
|
-
import { Crons } from "@convex-dev/crons";
|
|
1418
|
-
import { Effect } from "effect";
|
|
1419
|
-
|
|
1420
|
-
// Register cron (mutation)
|
|
1421
|
-
export const setupDailyCron = internalMutation({
|
|
1422
|
-
handler: async (ctx) => {
|
|
1423
|
-
const crons = new Crons(components.crons);
|
|
1424
|
-
await crons.register(
|
|
1425
|
-
ctx,
|
|
1426
|
-
{ kind: "cron", cronspec: "0 0 * * *" },
|
|
1427
|
-
internal.crons.dailyMaintenanceWithEffect,
|
|
1428
|
-
{},
|
|
1429
|
-
"daily-maintenance",
|
|
1430
|
-
);
|
|
1431
|
-
},
|
|
1432
|
-
});
|
|
1433
|
-
|
|
1434
|
-
// Cron job uses Effect for logic (action)
|
|
1435
|
-
export const dailyMaintenanceWithEffect = internalAction({
|
|
1436
|
-
handler: async (ctx) => {
|
|
1437
|
-
const program = Effect.gen(function* () {
|
|
1438
|
-
const ragService = yield* RAGService;
|
|
1439
|
-
const monitoring = yield* MonitoringService;
|
|
1440
|
-
|
|
1441
|
-
// Cleanup old content
|
|
1442
|
-
yield* Effect.tryPromise({
|
|
1443
|
-
try: () => ctx.runMutation(internal.rag.cleanupOld, {}),
|
|
1444
|
-
catch: () => new CleanupError(),
|
|
1445
|
-
});
|
|
1446
|
-
|
|
1447
|
-
// Generate report
|
|
1448
|
-
const report = yield* monitoring.generateDailyReport(ctx);
|
|
1449
|
-
|
|
1450
|
-
// Send email
|
|
1451
|
-
yield* Effect.tryPromise({
|
|
1452
|
-
try: () => ctx.runAction(internal.email.sendReport, { report }),
|
|
1453
|
-
catch: () => new EmailError(),
|
|
1454
|
-
});
|
|
1455
|
-
|
|
1456
|
-
return { success: true };
|
|
1457
|
-
});
|
|
1458
|
-
|
|
1459
|
-
await Effect.runPromise(
|
|
1460
|
-
program.pipe(
|
|
1461
|
-
Effect.provide(Layer.merge(RAGServiceLive, MonitoringServiceLive)),
|
|
1462
|
-
Effect.catchAll((error) => {
|
|
1463
|
-
console.error("Daily maintenance failed:", error);
|
|
1464
|
-
return Effect.succeed({ success: false, error });
|
|
1465
|
-
}),
|
|
1466
|
-
),
|
|
1467
|
-
);
|
|
1468
|
-
},
|
|
1469
|
-
});
|
|
1470
|
-
```
|
|
1471
|
-
|
|
1472
|
-
**Checklist:**
|
|
1473
|
-
|
|
1474
|
-
- [ ] Use Crons component for registration and scheduling
|
|
1475
|
-
- [ ] Use Effect in the cron job action for business logic
|
|
1476
|
-
- [ ] Compose with other services (RAG, monitoring, email)
|
|
1477
|
-
- [ ] Provide service layers in the action
|
|
1478
|
-
- [ ] Handle errors gracefully (don't crash cron)
|
|
1479
|
-
- [ ] Log execution results for monitoring
|
|
1480
|
-
|
|
1481
|
-
---
|
|
1482
|
-
|
|
1483
|
-
## Section 4: Production Patterns
|
|
1484
|
-
|
|
1485
|
-
### Pattern: Service Layer Composition (Layer.mergeAll) ✅ PRODUCTION-PROVEN
|
|
1486
|
-
|
|
1487
|
-
**Example: Building Application Layer**
|
|
1488
|
-
|
|
1489
|
-
```typescript
|
|
1490
|
-
// backend/convex/services/layers.ts
|
|
1491
|
-
import { Layer } from "effect";
|
|
1492
|
-
import { AgentServiceLive } from "./agent.service";
|
|
1493
|
-
import { RAGServiceLive } from "./rag.service";
|
|
1494
|
-
import { RateLimitServiceLive } from "./rate-limit.service";
|
|
1495
|
-
import { MonitoringServiceLive } from "./monitoring.service";
|
|
1496
|
-
|
|
1497
|
-
// Compose all service layers
|
|
1498
|
-
export const AppLayer = Layer.mergeAll(
|
|
1499
|
-
RateLimitServiceLive,
|
|
1500
|
-
MonitoringServiceLive,
|
|
1501
|
-
).pipe(
|
|
1502
|
-
Layer.provideMerge(RAGServiceLive), // RAG depends on above
|
|
1503
|
-
Layer.provideMerge(AgentServiceLive), // Agent depends on all above
|
|
1504
|
-
);
|
|
1505
|
-
|
|
1506
|
-
// Usage in any endpoint
|
|
1507
|
-
export const myAction = action({
|
|
1508
|
-
args: {
|
|
1509
|
-
/* ... */
|
|
1510
|
-
},
|
|
1511
|
-
handler: (ctx, args) =>
|
|
1512
|
-
Effect.gen(function* () {
|
|
1513
|
-
// All services available
|
|
1514
|
-
const agent = yield* AgentService;
|
|
1515
|
-
const rag = yield* RAGService;
|
|
1516
|
-
const rateLimit = yield* RateLimitService;
|
|
1517
|
-
const monitoring = yield* MonitoringService;
|
|
1518
|
-
|
|
1519
|
-
// Your logic here
|
|
1520
|
-
}).pipe(
|
|
1521
|
-
Effect.provide(AppLayer), // Single line provides all services
|
|
1522
|
-
Effect.runPromise,
|
|
1523
|
-
),
|
|
1524
|
-
});
|
|
1525
|
-
```
|
|
1526
|
-
|
|
1527
|
-
---
|
|
1528
|
-
|
|
1529
|
-
### Pattern: Multi-Agent Orchestration ✅ PRODUCTION-PROVEN
|
|
1530
|
-
|
|
1531
|
-
**Example: Research Agent System**
|
|
1532
|
-
|
|
1533
|
-
```typescript
|
|
1534
|
-
// backend/convex/domain/agents/research-orchestration.ts
|
|
1535
|
-
import { Effect } from "effect";
|
|
1536
|
-
|
|
1537
|
-
export const conductResearch = (query: string) =>
|
|
1538
|
-
Effect.gen(function* () {
|
|
1539
|
-
const agentService = yield* AgentService;
|
|
1540
|
-
const ragService = yield* RAGService;
|
|
1541
|
-
|
|
1542
|
-
// Step 1: Classify query
|
|
1543
|
-
const classification = yield* agentService.generateResponse(
|
|
1544
|
-
ctx,
|
|
1545
|
-
"classifier-thread",
|
|
1546
|
-
`Classify this query: ${query}`,
|
|
1547
|
-
);
|
|
1548
|
-
|
|
1549
|
-
// Step 2: Parallel research based on classification
|
|
1550
|
-
const [webResults, academicResults, newsResults] = yield* Effect.all(
|
|
1551
|
-
[
|
|
1552
|
-
agentService.generateResponse(ctx, "web-thread", `Web: ${query}`),
|
|
1553
|
-
agentService.generateResponse(
|
|
1554
|
-
ctx,
|
|
1555
|
-
"academic-thread",
|
|
1556
|
-
`Academic: ${query}`,
|
|
1557
|
-
),
|
|
1558
|
-
agentService.generateResponse(ctx, "news-thread", `News: ${query}`),
|
|
1559
|
-
],
|
|
1560
|
-
{ concurrency: 3 },
|
|
1561
|
-
);
|
|
1562
|
-
|
|
1563
|
-
// Step 3: Enrich with RAG context
|
|
1564
|
-
const ragContext = yield* ragService.search(ctx, "global", query, 5);
|
|
1565
|
-
|
|
1566
|
-
// Step 4: Synthesize all findings
|
|
1567
|
-
const synthesis = yield* agentService.generateResponse(
|
|
1568
|
-
ctx,
|
|
1569
|
-
"synthesis-thread",
|
|
1570
|
-
`Synthesize:\n\nWeb: ${webResults}\n\nAcademic: ${academicResults}\n\nNews: ${newsResults}\n\nContext: ${ragContext.text}`,
|
|
1571
|
-
);
|
|
1572
|
-
|
|
1573
|
-
// Step 5: Quality check in parallel
|
|
1574
|
-
const [grammar, factuality] = yield* Effect.all(
|
|
1575
|
-
[checkGrammar(synthesis), checkFactuality(synthesis)],
|
|
1576
|
-
{ concurrency: 2 },
|
|
1577
|
-
);
|
|
1578
|
-
|
|
1579
|
-
// Step 6: Refine if needed
|
|
1580
|
-
const final =
|
|
1581
|
-
grammar.score < 0.8 || factuality.score < 0.8
|
|
1582
|
-
? yield* agentService.generateResponse(
|
|
1583
|
-
ctx,
|
|
1584
|
-
"refine-thread",
|
|
1585
|
-
`Refine this: ${synthesis}`,
|
|
1586
|
-
)
|
|
1587
|
-
: synthesis;
|
|
1588
|
-
|
|
1589
|
-
return {
|
|
1590
|
-
result: final,
|
|
1591
|
-
sources: {
|
|
1592
|
-
web: webResults,
|
|
1593
|
-
academic: academicResults,
|
|
1594
|
-
news: newsResults,
|
|
1595
|
-
rag: ragContext.entries,
|
|
1596
|
-
},
|
|
1597
|
-
quality: { grammar, factuality },
|
|
1598
|
-
};
|
|
1599
|
-
});
|
|
1600
|
-
```
|
|
1601
|
-
|
|
1602
|
-
---
|
|
1603
|
-
|
|
1604
|
-
### Pattern: Testing with Layers (Mock Providers) ✅ PRODUCTION-PROVEN
|
|
1605
|
-
|
|
1606
|
-
**Example: Test Service Implementations**
|
|
1607
|
-
|
|
1608
|
-
```typescript
|
|
1609
|
-
// backend/convex/services/__tests__/agent.service.test.ts
|
|
1610
|
-
import { Effect, Layer } from "effect";
|
|
1611
|
-
import { AgentService } from "../agent.service";
|
|
1612
|
-
import { RAGService } from "../rag.service";
|
|
1613
|
-
import { RateLimitService } from "../rate-limit.service";
|
|
1614
|
-
|
|
1615
|
-
// Create mock implementations
|
|
1616
|
-
const TestAgentServiceLive = Layer.succeed(AgentService, {
|
|
1617
|
-
generateResponse: (ctx, threadId, prompt) =>
|
|
1618
|
-
Effect.succeed("Mock agent response"),
|
|
1619
|
-
|
|
1620
|
-
createThread: (ctx, userId) => Effect.succeed("test-thread-id"),
|
|
1621
|
-
});
|
|
1622
|
-
|
|
1623
|
-
const TestRAGServiceLive = Layer.succeed(RAGService, {
|
|
1624
|
-
search: (ctx, namespace, query, limit) =>
|
|
1625
|
-
Effect.succeed({
|
|
1626
|
-
text: "Mock context",
|
|
1627
|
-
entries: [],
|
|
1628
|
-
}),
|
|
1629
|
-
|
|
1630
|
-
addDocument: (ctx, namespace, content, metadata) =>
|
|
1631
|
-
Effect.succeed("mock-entry-id"),
|
|
1632
|
-
});
|
|
1633
|
-
|
|
1634
|
-
const TestRateLimitServiceLive = Layer.succeed(RateLimitService, {
|
|
1635
|
-
checkLimit: (ctx, key, count) => Effect.succeed(true), // Always pass
|
|
1636
|
-
});
|
|
1637
|
-
|
|
1638
|
-
// Compose test layers
|
|
1639
|
-
const TestAppLayer = Layer.mergeAll(
|
|
1640
|
-
TestRateLimitServiceLive,
|
|
1641
|
-
TestRAGServiceLive,
|
|
1642
|
-
TestAgentServiceLive,
|
|
1643
|
-
);
|
|
1644
|
-
|
|
1645
|
-
// Write tests
|
|
1646
|
-
describe("Research Orchestration", () => {
|
|
1647
|
-
it("should conduct research with all agents", async () => {
|
|
1648
|
-
const program = conductResearch("What is Effect.ts?");
|
|
1649
|
-
|
|
1650
|
-
const result = await Effect.runPromise(
|
|
1651
|
-
program.pipe(Effect.provide(TestAppLayer)),
|
|
1652
|
-
);
|
|
1653
|
-
|
|
1654
|
-
expect(result.result).toBe("Mock agent response");
|
|
1655
|
-
expect(result.sources.web).toBe("Mock agent response");
|
|
1656
|
-
});
|
|
1657
|
-
|
|
1658
|
-
it("should handle agent errors", async () => {
|
|
1659
|
-
// Override one service to fail
|
|
1660
|
-
const FailingAgentLayer = Layer.succeed(AgentService, {
|
|
1661
|
-
generateResponse: () =>
|
|
1662
|
-
Effect.fail(new AgentError({ agentName: "test", cause: "Failed" })),
|
|
1663
|
-
createThread: () => Effect.succeed("test-thread-id"),
|
|
1664
|
-
});
|
|
1665
|
-
|
|
1666
|
-
const TestLayerWithFailure = Layer.mergeAll(
|
|
1667
|
-
TestRateLimitServiceLive,
|
|
1668
|
-
TestRAGServiceLive,
|
|
1669
|
-
FailingAgentLayer,
|
|
1670
|
-
);
|
|
1671
|
-
|
|
1672
|
-
const program = conductResearch("What is Effect.ts?").pipe(
|
|
1673
|
-
Effect.provide(TestLayerWithFailure),
|
|
1674
|
-
Effect.catchTag("AgentError", (error) =>
|
|
1675
|
-
Effect.succeed({ result: "Error handled", error: true }),
|
|
1676
|
-
),
|
|
1677
|
-
);
|
|
1678
|
-
|
|
1679
|
-
const result = await Effect.runPromise(program);
|
|
1680
|
-
|
|
1681
|
-
expect(result.error).toBe(true);
|
|
1682
|
-
});
|
|
1683
|
-
});
|
|
1684
|
-
```
|
|
1685
|
-
|
|
1686
|
-
**Checklist for Testing:**
|
|
1687
|
-
|
|
1688
|
-
- [ ] Create test layers with `Layer.succeed` for all services
|
|
1689
|
-
- [ ] Compose test layers with `Layer.mergeAll`
|
|
1690
|
-
- [ ] Override specific services to test error paths
|
|
1691
|
-
- [ ] Use `Effect.runPromise` to execute tests
|
|
1692
|
-
- [ ] Test both success and failure scenarios
|
|
1693
|
-
- [ ] Test error handling with `Effect.catchTag`
|
|
1694
|
-
|
|
1695
|
-
---
|
|
1696
|
-
|
|
1697
|
-
### Pattern: Error Recovery Strategies ✅ PRODUCTION-PROVEN
|
|
1698
|
-
|
|
1699
|
-
**Example: Fallback Chain**
|
|
1700
|
-
|
|
1701
|
-
```typescript
|
|
1702
|
-
// backend/convex/domain/agents/robust-generation.ts
|
|
1703
|
-
import { Effect, Schedule } from "effect";
|
|
1704
|
-
|
|
1705
|
-
export const robustGeneration = (prompt: string) =>
|
|
1706
|
-
Effect.gen(function* () {
|
|
1707
|
-
const llmService = yield* LLMService;
|
|
1708
|
-
|
|
1709
|
-
// Try primary approach
|
|
1710
|
-
const result = yield* llmService.complete(prompt).pipe(
|
|
1711
|
-
Effect.timeout("30 seconds"),
|
|
1712
|
-
|
|
1713
|
-
// Fallback 1: Reduce context and retry
|
|
1714
|
-
Effect.catchTag("TimeoutError", () =>
|
|
1715
|
-
llmService
|
|
1716
|
-
.complete(truncate(prompt, 1000))
|
|
1717
|
-
.pipe(Effect.timeout("20 seconds")),
|
|
1718
|
-
),
|
|
1719
|
-
|
|
1720
|
-
// Fallback 2: Switch to faster model
|
|
1721
|
-
Effect.catchTag("TimeoutError", () =>
|
|
1722
|
-
llmService
|
|
1723
|
-
.completeFast(truncate(prompt, 500))
|
|
1724
|
-
.pipe(Effect.timeout("10 seconds")),
|
|
1725
|
-
),
|
|
1726
|
-
|
|
1727
|
-
// Fallback 3: Check cache
|
|
1728
|
-
Effect.catchTag("TimeoutError", () =>
|
|
1729
|
-
getCachedResponse(prompt).pipe(
|
|
1730
|
-
Effect.orElse(() =>
|
|
1731
|
-
Effect.succeed("I'm experiencing delays. Please try again."),
|
|
1732
|
-
),
|
|
1733
|
-
),
|
|
1734
|
-
),
|
|
1735
|
-
|
|
1736
|
-
// Retry on rate limits
|
|
1737
|
-
Effect.retry(
|
|
1738
|
-
Schedule.exponential("1 second").pipe(
|
|
1739
|
-
Schedule.whileInput((error) => error._tag === "RateLimitError"),
|
|
1740
|
-
Schedule.compose(Schedule.recurs(3)),
|
|
1741
|
-
),
|
|
1742
|
-
),
|
|
1743
|
-
);
|
|
1744
|
-
|
|
1745
|
-
return result;
|
|
1746
|
-
});
|
|
1747
|
-
```
|
|
1748
|
-
|
|
1749
|
-
---
|
|
1750
|
-
|
|
1751
|
-
### Pattern: Monitoring and Observability ✅ PRODUCTION-PROVEN
|
|
1752
|
-
|
|
1753
|
-
**Example: Monitoring Service**
|
|
1754
|
-
|
|
1755
|
-
```typescript
|
|
1756
|
-
// backend/convex/services/monitoring.service.ts
|
|
1757
|
-
import { Effect, Context, Layer } from "effect";
|
|
1758
|
-
|
|
1759
|
-
interface UsageData {
|
|
1760
|
-
serviceName: string;
|
|
1761
|
-
functionName: string;
|
|
1762
|
-
duration: number;
|
|
1763
|
-
tokenCount?: number;
|
|
1764
|
-
cost?: number;
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
|
-
class MonitoringService extends Context.Tag("MonitoringService")<
|
|
1768
|
-
MonitoringService,
|
|
1769
|
-
{
|
|
1770
|
-
readonly trackUsage: (data: UsageData) => Effect.Effect<void>;
|
|
1771
|
-
readonly trackError: (error: unknown) => Effect.Effect<void>;
|
|
1772
|
-
}
|
|
1773
|
-
>() {}
|
|
1774
|
-
|
|
1775
|
-
const MonitoringServiceLive = Layer.succeed(MonitoringService, {
|
|
1776
|
-
trackUsage: (data) =>
|
|
1777
|
-
Effect.sync(() => {
|
|
1778
|
-
console.log("Service usage:", data);
|
|
1779
|
-
// Send to analytics service (Datadog, Honeycomb, etc.)
|
|
1780
|
-
}),
|
|
1781
|
-
|
|
1782
|
-
trackError: (error) =>
|
|
1783
|
-
Effect.sync(() => {
|
|
1784
|
-
console.error("Service error:", error);
|
|
1785
|
-
// Send to error tracking (Sentry, Rollbar, etc.)
|
|
1786
|
-
}),
|
|
1787
|
-
});
|
|
1788
|
-
|
|
1789
|
-
export { MonitoringService, MonitoringServiceLive };
|
|
1790
|
-
```
|
|
1791
|
-
|
|
1792
|
-
**Wrap Service Calls with Monitoring:**
|
|
1793
|
-
|
|
1794
|
-
```typescript
|
|
1795
|
-
// backend/convex/domain/agents/monitored-generation.ts
|
|
1796
|
-
export const monitoredGeneration = (prompt: string) =>
|
|
1797
|
-
Effect.gen(function* () {
|
|
1798
|
-
const agentService = yield* AgentService;
|
|
1799
|
-
const monitoring = yield* MonitoringService;
|
|
1800
|
-
|
|
1801
|
-
const startTime = Date.now();
|
|
1802
|
-
|
|
1803
|
-
const result = yield* agentService
|
|
1804
|
-
.generateResponse(ctx, threadId, prompt)
|
|
1805
|
-
.pipe(
|
|
1806
|
-
Effect.tap((response) =>
|
|
1807
|
-
monitoring.trackUsage({
|
|
1808
|
-
serviceName: "AgentService",
|
|
1809
|
-
functionName: "generateResponse",
|
|
1810
|
-
duration: Date.now() - startTime,
|
|
1811
|
-
tokenCount: response.usage?.totalTokens,
|
|
1812
|
-
}),
|
|
1813
|
-
),
|
|
1814
|
-
Effect.tapError((error) =>
|
|
1815
|
-
monitoring.trackError({
|
|
1816
|
-
serviceName: "AgentService",
|
|
1817
|
-
functionName: "generateResponse",
|
|
1818
|
-
error,
|
|
1819
|
-
}),
|
|
1820
|
-
),
|
|
1821
|
-
);
|
|
1822
|
-
|
|
1823
|
-
return result;
|
|
1824
|
-
});
|
|
1825
|
-
```
|
|
1826
|
-
|
|
1827
|
-
---
|
|
1828
|
-
|
|
1829
|
-
## Section 5: Migration Path
|
|
1830
|
-
|
|
1831
|
-
### From Promise-based to Effect
|
|
1832
|
-
|
|
1833
|
-
**Before (Promise-based):**
|
|
1834
|
-
|
|
1835
|
-
```typescript
|
|
1836
|
-
// backend/convex/api/chat.ts (Promise-based)
|
|
1837
|
-
export const chat = action({
|
|
1838
|
-
args: { prompt: v.string() },
|
|
1839
|
-
handler: async (ctx, args) => {
|
|
1840
|
-
try {
|
|
1841
|
-
// Check rate limit
|
|
1842
|
-
const rateLimitOk = await checkRateLimit(ctx, ctx.userId);
|
|
1843
|
-
if (!rateLimitOk) {
|
|
1844
|
-
return { error: "Rate limit exceeded" };
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
// Search for context
|
|
1848
|
-
let context = "";
|
|
1849
|
-
try {
|
|
1850
|
-
context = await searchRAG(ctx, args.prompt);
|
|
1851
|
-
} catch (error) {
|
|
1852
|
-
console.error("RAG search failed:", error);
|
|
1853
|
-
// Continue without context
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
// Generate response
|
|
1857
|
-
const response = await generateWithAgent(ctx, args.prompt, context);
|
|
1858
|
-
|
|
1859
|
-
return { response };
|
|
1860
|
-
} catch (error) {
|
|
1861
|
-
console.error("Chat failed:", error);
|
|
1862
|
-
return { error: "Something went wrong" };
|
|
1863
|
-
}
|
|
1864
|
-
},
|
|
1865
|
-
});
|
|
1866
|
-
```
|
|
1867
|
-
|
|
1868
|
-
**After (Effect-based):**
|
|
1869
|
-
|
|
1870
|
-
```typescript
|
|
1871
|
-
// backend/convex/api/chat.ts (Effect-based)
|
|
1872
|
-
export const chat = action({
|
|
1873
|
-
args: { prompt: v.string() },
|
|
1874
|
-
handler: (ctx, args) =>
|
|
1875
|
-
Effect.gen(function* () {
|
|
1876
|
-
const rateLimitService = yield* RateLimitService;
|
|
1877
|
-
const ragService = yield* RAGService;
|
|
1878
|
-
const agentService = yield* AgentService;
|
|
1879
|
-
|
|
1880
|
-
// Check rate limit (errors propagate automatically)
|
|
1881
|
-
const rateLimitOk = yield* rateLimitService.checkLimit(ctx, ctx.userId);
|
|
1882
|
-
|
|
1883
|
-
// Search for context (graceful degradation)
|
|
1884
|
-
const context = yield* ragService
|
|
1885
|
-
.search(ctx, "global", args.prompt, 5)
|
|
1886
|
-
.pipe(Effect.catchAll(() => Effect.succeed({ text: "", entries: [] })));
|
|
1887
|
-
|
|
1888
|
-
// Generate response
|
|
1889
|
-
const response = yield* agentService.generateResponse(
|
|
1890
|
-
ctx,
|
|
1891
|
-
ctx.threadId,
|
|
1892
|
-
`${args.prompt}\n\nContext: ${context.text}`,
|
|
1893
|
-
);
|
|
1894
|
-
|
|
1895
|
-
return { response };
|
|
1896
|
-
}).pipe(
|
|
1897
|
-
Effect.provide(
|
|
1898
|
-
Layer.merge(RateLimitServiceLive, RAGServiceLive, AgentServiceLive),
|
|
1899
|
-
),
|
|
1900
|
-
Effect.catchTag("RateLimitError", (error) =>
|
|
1901
|
-
Effect.succeed({
|
|
1902
|
-
error: "Rate limit exceeded",
|
|
1903
|
-
retryAfter: error.retryAfter,
|
|
1904
|
-
}),
|
|
1905
|
-
),
|
|
1906
|
-
Effect.catchAll((error) =>
|
|
1907
|
-
Effect.succeed({ error: "Something went wrong" }),
|
|
1908
|
-
),
|
|
1909
|
-
Effect.runPromise,
|
|
1910
|
-
),
|
|
1911
|
-
});
|
|
1912
|
-
```
|
|
1913
|
-
|
|
1914
|
-
**Benefits:**
|
|
1915
|
-
|
|
1916
|
-
- No nested try/catch blocks
|
|
1917
|
-
- Automatic error propagation with types
|
|
1918
|
-
- Graceful degradation with `Effect.catchAll(() => fallback)`
|
|
1919
|
-
- Dependency injection (testable with mock layers)
|
|
1920
|
-
- Composable (can add retry, timeout, parallel operations easily)
|
|
1921
|
-
|
|
1922
|
-
---
|
|
1923
|
-
|
|
1924
|
-
### From Plain Convex to Wrapped Services
|
|
1925
|
-
|
|
1926
|
-
**Step 1: Identify High-Value Operations**
|
|
1927
|
-
|
|
1928
|
-
Start with operations that:
|
|
1929
|
-
|
|
1930
|
-
- Call external APIs (LLM, vector search)
|
|
1931
|
-
- Have complex error handling
|
|
1932
|
-
- Need retry logic
|
|
1933
|
-
- Are used in multiple places
|
|
1934
|
-
|
|
1935
|
-
**Step 2: Create Service Interface**
|
|
1936
|
-
|
|
1937
|
-
```typescript
|
|
1938
|
-
// backend/convex/services/my-service.ts
|
|
1939
|
-
import { Effect, Context, Layer, Data } from "effect";
|
|
1940
|
-
|
|
1941
|
-
class MyServiceError extends Data.TaggedError("MyServiceError")<{
|
|
1942
|
-
operation: string;
|
|
1943
|
-
cause: unknown;
|
|
1944
|
-
}> {}
|
|
1945
|
-
|
|
1946
|
-
class MyService extends Context.Tag("MyService")<
|
|
1947
|
-
MyService,
|
|
1948
|
-
{
|
|
1949
|
-
readonly operation: (args) => Effect.Effect<Result, MyServiceError>;
|
|
1950
|
-
}
|
|
1951
|
-
>() {}
|
|
1952
|
-
|
|
1953
|
-
const MyServiceLive = Layer.effect(
|
|
1954
|
-
MyService,
|
|
1955
|
-
Effect.gen(function* () {
|
|
1956
|
-
// Existing implementation wrapped in Effect
|
|
1957
|
-
return {
|
|
1958
|
-
operation: (args) =>
|
|
1959
|
-
Effect.tryPromise({
|
|
1960
|
-
try: () => existingFunction(args),
|
|
1961
|
-
catch: (error) =>
|
|
1962
|
-
new MyServiceError({ operation: "operation", cause: error }),
|
|
1963
|
-
}),
|
|
1964
|
-
};
|
|
1965
|
-
}),
|
|
1966
|
-
);
|
|
1967
|
-
```
|
|
1968
|
-
|
|
1969
|
-
**Step 3: Gradually Replace Calls**
|
|
1970
|
-
|
|
1971
|
-
```typescript
|
|
1972
|
-
// Before
|
|
1973
|
-
const result = await existingFunction(args);
|
|
1974
|
-
|
|
1975
|
-
// After
|
|
1976
|
-
const result = yield * myService.operation(args);
|
|
1977
|
-
```
|
|
1978
|
-
|
|
1979
|
-
**Step 4: Add New Features with Effect**
|
|
1980
|
-
|
|
1981
|
-
All new features use Effect from day one. Old features migrate as needed.
|
|
1982
|
-
|
|
1983
|
-
---
|
|
1984
|
-
|
|
1985
|
-
### Gradual Confect Adoption (If Desired)
|
|
1986
|
-
|
|
1987
|
-
**Phase 1: Evaluate Confect (1-2 weeks)**
|
|
1988
|
-
|
|
1989
|
-
- Read Confect documentation
|
|
1990
|
-
- Create proof-of-concept with small feature
|
|
1991
|
-
- Compare manual wrapping vs Confect
|
|
1992
|
-
- Decide: Confect or manual?
|
|
1993
|
-
|
|
1994
|
-
**Phase 2: Schema Migration (If Confect) (2-4 weeks)**
|
|
1995
|
-
|
|
1996
|
-
- Convert Convex validators to Effect schemas
|
|
1997
|
-
- Update `schema.ts` to use Confect's `defineSchema`
|
|
1998
|
-
- Generate function constructors with `makeFunctions`
|
|
1999
|
-
- Test that existing queries/mutations still work
|
|
2000
|
-
|
|
2001
|
-
**Phase 3: Function Migration (4-8 weeks)**
|
|
2002
|
-
|
|
2003
|
-
- Convert queries to use `ConfectQueryCtx`
|
|
2004
|
-
- Convert mutations to use `ConfectMutationCtx`
|
|
2005
|
-
- Convert actions to use `ConfectActionCtx`
|
|
2006
|
-
- Update all handlers to return `Effect` instead of `Promise`
|
|
2007
|
-
|
|
2008
|
-
**Phase 4: Frontend Integration (2-4 weeks)**
|
|
2009
|
-
|
|
2010
|
-
- Update frontend to handle Option types (`Option.isSome`, `Option.getOrElse`)
|
|
2011
|
-
- Add Effect runners for client-side logic (if needed)
|
|
2012
|
-
- Test reactive queries with new types
|
|
2013
|
-
|
|
2014
|
-
**Phase 5: Complete Transition (2 weeks)**
|
|
2015
|
-
|
|
2016
|
-
- Remove all Promise-based handlers
|
|
2017
|
-
- Delete manual wrapper utilities
|
|
2018
|
-
- Update documentation
|
|
2019
|
-
- Train team on new patterns
|
|
2020
|
-
|
|
2021
|
-
**Total Time Estimate:** 11-20 weeks (depending on codebase size)
|
|
2022
|
-
|
|
2023
|
-
**Recommendation:** For ONE Platform, stick with manual wrapping for now. Confect is powerful but adds significant migration overhead.
|
|
2024
|
-
|
|
2025
|
-
---
|
|
2026
|
-
|
|
2027
|
-
## Quick Reference: Common Tasks
|
|
2028
|
-
|
|
2029
|
-
### I need to wrap an agent
|
|
2030
|
-
|
|
2031
|
-
```typescript
|
|
2032
|
-
import { Agent } from "@convex-dev/agent";
|
|
2033
|
-
import { Effect, Context, Layer, Data } from "effect";
|
|
2034
|
-
|
|
2035
|
-
class AgentError extends Data.TaggedError("AgentError")<{ cause: unknown }> {}
|
|
2036
|
-
class AgentService extends Context.Tag("AgentService")<
|
|
2037
|
-
AgentService,
|
|
2038
|
-
{ readonly generate: (ctx, prompt) => Effect.Effect<string, AgentError> }
|
|
2039
|
-
>() {}
|
|
2040
|
-
|
|
2041
|
-
const AgentServiceLive = Layer.effect(
|
|
2042
|
-
AgentService,
|
|
2043
|
-
Effect.gen(function* () {
|
|
2044
|
-
const agent = new Agent(components.agent, {
|
|
2045
|
-
/* config */
|
|
2046
|
-
});
|
|
2047
|
-
return {
|
|
2048
|
-
generate: (ctx, prompt) =>
|
|
2049
|
-
Effect.tryPromise({
|
|
2050
|
-
try: async () => {
|
|
2051
|
-
const result = await agent.generateText(
|
|
2052
|
-
ctx,
|
|
2053
|
-
{ threadId },
|
|
2054
|
-
{ prompt },
|
|
2055
|
-
);
|
|
2056
|
-
return result.text;
|
|
2057
|
-
},
|
|
2058
|
-
catch: (error) => new AgentError({ cause: error }),
|
|
2059
|
-
}),
|
|
2060
|
-
};
|
|
2061
|
-
}),
|
|
2062
|
-
);
|
|
2063
|
-
```
|
|
2064
|
-
|
|
2065
|
-
---
|
|
2066
|
-
|
|
2067
|
-
### I need to call multiple services in parallel
|
|
2068
|
-
|
|
2069
|
-
```typescript
|
|
2070
|
-
const results =
|
|
2071
|
-
yield *
|
|
2072
|
-
Effect.all(
|
|
2073
|
-
[service1.operation1(), service2.operation2(), service3.operation3()],
|
|
2074
|
-
{ concurrency: 2 }, // Max 2 at a time
|
|
2075
|
-
);
|
|
2076
|
-
```
|
|
2077
|
-
|
|
2078
|
-
---
|
|
2079
|
-
|
|
2080
|
-
### I need to retry on failure
|
|
2081
|
-
|
|
2082
|
-
```typescript
|
|
2083
|
-
const result =
|
|
2084
|
-
yield *
|
|
2085
|
-
riskyOperation().pipe(
|
|
2086
|
-
Effect.retry(
|
|
2087
|
-
Schedule.exponential("1 second").pipe(
|
|
2088
|
-
Schedule.compose(Schedule.recurs(3)), // Max 3 retries
|
|
2089
|
-
),
|
|
2090
|
-
),
|
|
2091
|
-
);
|
|
2092
|
-
```
|
|
2093
|
-
|
|
2094
|
-
---
|
|
2095
|
-
|
|
2096
|
-
### I need to handle specific errors
|
|
2097
|
-
|
|
2098
|
-
```typescript
|
|
2099
|
-
const result =
|
|
2100
|
-
yield *
|
|
2101
|
-
operation().pipe(
|
|
2102
|
-
Effect.catchTag("SpecificError", (error) =>
|
|
2103
|
-
Effect.succeed("Handled specific error"),
|
|
2104
|
-
),
|
|
2105
|
-
Effect.catchAll((error) => Effect.succeed("Handled any error")),
|
|
2106
|
-
);
|
|
2107
|
-
```
|
|
2108
|
-
|
|
2109
|
-
---
|
|
2110
|
-
|
|
2111
|
-
### I need to compose services
|
|
2112
|
-
|
|
2113
|
-
```typescript
|
|
2114
|
-
const program = Effect.gen(function* () {
|
|
2115
|
-
const service1 = yield* Service1;
|
|
2116
|
-
const service2 = yield* Service2;
|
|
2117
|
-
|
|
2118
|
-
const result1 = yield* service1.operation();
|
|
2119
|
-
const result2 = yield* service2.operation(result1);
|
|
2120
|
-
|
|
2121
|
-
return result2;
|
|
2122
|
-
});
|
|
2123
|
-
|
|
2124
|
-
await Effect.runPromise(
|
|
2125
|
-
program.pipe(Effect.provide(Layer.merge(Service1Live, Service2Live))),
|
|
2126
|
-
);
|
|
2127
|
-
```
|
|
2128
|
-
|
|
2129
|
-
---
|
|
2130
|
-
|
|
2131
|
-
### I need to test a service
|
|
2132
|
-
|
|
2133
|
-
```typescript
|
|
2134
|
-
const TestServiceLive = Layer.succeed(Service, {
|
|
2135
|
-
operation: (args) => Effect.succeed("mock result"),
|
|
2136
|
-
});
|
|
2137
|
-
|
|
2138
|
-
const result = await Effect.runPromise(
|
|
2139
|
-
myProgram.pipe(Effect.provide(TestServiceLive)),
|
|
2140
|
-
);
|
|
2141
|
-
|
|
2142
|
-
expect(result).toBe("mock result");
|
|
2143
|
-
```
|
|
2144
|
-
|
|
2145
|
-
---
|
|
2146
|
-
|
|
2147
|
-
### I need to manage resources (connections, streams)
|
|
2148
|
-
|
|
2149
|
-
```typescript
|
|
2150
|
-
Effect.scoped(
|
|
2151
|
-
Effect.gen(function* () {
|
|
2152
|
-
const resource = yield* Effect.acquireRelease(
|
|
2153
|
-
Effect.sync(() => acquire()),
|
|
2154
|
-
(r) => Effect.sync(() => release(r)),
|
|
2155
|
-
);
|
|
2156
|
-
|
|
2157
|
-
return yield* useResource(resource);
|
|
2158
|
-
}),
|
|
2159
|
-
);
|
|
2160
|
-
```
|
|
2161
|
-
|
|
2162
|
-
---
|
|
2163
|
-
|
|
2164
|
-
### I need to add timeout
|
|
2165
|
-
|
|
2166
|
-
```typescript
|
|
2167
|
-
const result =
|
|
2168
|
-
yield *
|
|
2169
|
-
operation().pipe(
|
|
2170
|
-
Effect.timeout("10 seconds"),
|
|
2171
|
-
Effect.catchTag("TimeoutError", () =>
|
|
2172
|
-
Effect.succeed("Operation timed out"),
|
|
2173
|
-
),
|
|
2174
|
-
);
|
|
2175
|
-
```
|
|
2176
|
-
|
|
2177
|
-
---
|
|
2178
|
-
|
|
2179
|
-
### I need to log execution
|
|
2180
|
-
|
|
2181
|
-
```typescript
|
|
2182
|
-
const result =
|
|
2183
|
-
yield *
|
|
2184
|
-
operation().pipe(
|
|
2185
|
-
Effect.tap((result) => Effect.log("Operation succeeded", { result })),
|
|
2186
|
-
Effect.tapError((error) => Effect.log("Operation failed", { error })),
|
|
2187
|
-
);
|
|
2188
|
-
```
|
|
2189
|
-
|
|
2190
|
-
---
|
|
2191
|
-
|
|
2192
|
-
## Related Resources
|
|
2193
|
-
|
|
2194
|
-
**Effect.ts Official:**
|
|
2195
|
-
|
|
2196
|
-
- [Effect.ts Documentation](https://effect.website) - Core Effect patterns
|
|
2197
|
-
- [Effect.ts GitHub](https://github.com/Effect-TS/effect) - Source code and examples
|
|
2198
|
-
- [Effect.ts Discord](https://discord.gg/effect-ts) - Community support
|
|
2199
|
-
|
|
2200
|
-
**Convex Components:**
|
|
2201
|
-
|
|
2202
|
-
- [@convex-dev/agent](https://github.com/get-convex/agent) - AI agent component
|
|
2203
|
-
- [@convex-dev/workflow](https://github.com/get-convex/workflow) - Durable workflows
|
|
2204
|
-
- [@convex-dev/rag](https://github.com/get-convex/rag) - Vector search and RAG
|
|
2205
|
-
|
|
2206
|
-
**ONE Platform Docs:**
|
|
2207
|
-
|
|
2208
|
-
- [6-Dimension Ontology](/one/knowledge/ontology.md) - Platform data model
|
|
2209
|
-
- [Architecture Overview](/one/knowledge/architecture.md) - System design
|
|
2210
|
-
- [Effect Integration Plan](/one/things/plans/effect.md) - Backend-agnostic architecture
|
|
2211
|
-
- [Component Integration Guide](/one/things/plans/effect-components.md) - Convex components + Effect
|
|
2212
|
-
|
|
2213
|
-
---
|
|
2214
|
-
|
|
2215
|
-
## Production-Proven Patterns (From 14.ai)
|
|
2216
|
-
|
|
2217
|
-
These patterns are marked with ✅ PRODUCTION-PROVEN and come from 14.ai's AI customer support platform:
|
|
2218
|
-
|
|
2219
|
-
1. **Effect-Wrapped Component** - Wrapping @convex-dev/agent with Effect services
|
|
2220
|
-
2. **Service Layer Pattern** - Context.Tag + Layer.effect for dependency injection
|
|
2221
|
-
3. **Error Handling Pattern** - Tagged errors with layered recovery strategies
|
|
2222
|
-
4. **Parallel Execution** - Effect.all with concurrency control
|
|
2223
|
-
5. **Resource Management** - Effect.scoped for connection pools
|
|
2224
|
-
6. **Retry and Timeout** - Schedule.exponential for resilient operations
|
|
2225
|
-
7. **Multi-Agent Orchestration** - Composing multiple agents with Effect.gen
|
|
2226
|
-
8. **Testing with Layers** - Mock service implementations for unit tests
|
|
2227
|
-
9. **Monitoring and Observability** - Effect.tap for usage tracking
|
|
2228
|
-
|
|
2229
|
-
Use these patterns with confidence—they've been battle-tested in production.
|
|
2230
|
-
|
|
2231
|
-
---
|
|
2232
|
-
|
|
2233
|
-
**Ready to build with Effect.ts? Start with Pattern 1 (Effect-Wrapped Component) and expand from there.**
|
|
2234
|
-
|
|
2235
|
-
**Need help? Find the pattern, copy the example, adapt to your use case. Ship it.**
|