oneie 2.0.2 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +245 -0
- package/CLAUDE.md +725 -0
- package/LICENSE.md +84 -0
- package/README.md +489 -931
- package/folders.yaml +78 -17
- package/one/.obsidian/app.json +1 -0
- package/one/.obsidian/appearance.json +1 -0
- package/one/.obsidian/core-plugins.json +33 -0
- package/one/.obsidian/workspace.json +211 -0
- package/one/connections/a2a.md +551 -0
- package/one/connections/acp.md +761 -0
- package/one/connections/acps.md +731 -0
- package/one/connections/agentkit.md +349 -0
- package/one/connections/agui.md +767 -0
- package/one/connections/any-backend.md +1702 -0
- package/one/connections/ap2.md +998 -0
- package/one/connections/api-docs.md +1891 -0
- package/one/connections/api.md +2190 -0
- package/one/connections/architecture-diagram.md +94 -0
- package/one/connections/communications.md +449 -0
- package/one/connections/connections.md +339 -0
- package/one/connections/copilotkit.md +1559 -0
- package/one/connections/cryptonetworks.md +781 -0
- package/one/connections/documentation.md +1120 -0
- package/one/connections/effect.md +279 -0
- package/one/connections/elizaos.md +1290 -0
- package/one/connections/inference.md +58 -0
- package/one/connections/kyc.md +632 -0
- package/one/connections/mcp.md +842 -0
- package/one/connections/membership.md +1152 -0
- package/one/connections/middleware.md +1067 -0
- package/one/connections/multitenant.md +1341 -0
- package/one/connections/n8n.md +1015 -0
- package/one/connections/patterns.md +89 -0
- package/one/connections/protocols.md +279 -0
- package/one/connections/relationships.md +107 -0
- package/one/connections/schema.md +587 -0
- package/one/connections/service-layer.md +550 -0
- package/one/connections/structure.md +0 -0
- package/one/connections/vectors.md +207 -0
- package/one/connections/wordpress.md +1302 -0
- package/one/connections/workflow-copy.md +905 -0
- package/one/connections/workflow-examples.md +741 -0
- package/one/connections/workflow.md +905 -0
- package/one/connections/workflows/delegation.md +885 -0
- package/one/connections/workflows/frontend.md +1037 -0
- package/one/connections/workflows/strategy.md +903 -0
- package/one/connections/workflows/tasks.md +698 -0
- package/one/connections/x402.md +1249 -0
- package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +412 -0
- package/one/events/FEATURE-2-4-COMPLETE.md +302 -0
- package/one/events/FEATURE_2_3_COMPLETE.md +575 -0
- package/one/events/GROUPS-MIGRATION.md +625 -0
- package/one/events/INSTALL-TESTS.md +293 -0
- package/one/events/INTEGRATION-ARCHITECTURE.md +561 -0
- package/one/events/INTEGRATION-CHECKLIST.md +1234 -0
- package/one/events/INTEGRATION-ORCHESTRATION.md +2623 -0
- package/one/events/INTEGRATION-SUMMARY.md +653 -0
- package/one/events/MIGRATION-REPORT.md +435 -0
- package/one/events/MIGRATION.md +69 -0
- package/one/events/README-archived.md +519 -0
- package/one/events/TEST-SUMMARY.md +393 -0
- package/one/events/TESTS-QUICK-REF.md +262 -0
- package/one/events/events.md +545 -0
- package/one/groups/groups.md +543 -0
- package/one/groups/one.md +599 -0
- package/one/groups/revenue.md +673 -0
- package/one/groups/strategy.md +869 -0
- package/one/groups/vision.md +98 -0
- package/one/knowledge/CLOUDFLARE_ENV_SETUP.md +49 -0
- package/one/knowledge/ai-platform.md +305 -0
- package/one/knowledge/architecture-any-backend.md +1366 -0
- package/one/knowledge/architecture-diagram.md +94 -0
- package/one/knowledge/architecture-frontend.md +930 -0
- package/one/knowledge/architecture.md +2077 -0
- package/one/knowledge/crypto.md +960 -0
- package/one/knowledge/docs/flow.md +0 -0
- package/one/knowledge/dsl.md +1660 -0
- package/one/knowledge/files.md +2471 -0
- package/one/knowledge/frontend.md +1038 -0
- package/one/knowledge/hono.md +2109 -0
- package/one/knowledge/implementation-examples.md +2536 -0
- package/one/knowledge/inference-score.md +159 -0
- package/one/knowledge/knowledge.md +642 -0
- package/one/knowledge/language.md +980 -0
- package/one/knowledge/lessons-learned.md +70 -0
- package/one/knowledge/ontology-6-dimensions.md +0 -0
- package/one/knowledge/ontology-documentation.md +356 -0
- package/one/knowledge/ontology-engineering-specification.md +1292 -0
- package/one/knowledge/ontology-engineering.md +1652 -0
- package/one/knowledge/ontology-frontend-copy-2.md +1492 -0
- package/one/knowledge/ontology-frontend-copy.md +753 -0
- package/one/knowledge/ontology-frontend-specifications.md +2188 -0
- package/one/knowledge/ontology-frontend.md +2427 -0
- package/one/knowledge/ontology-minimal.yaml +299 -0
- package/one/knowledge/ontology.md +2830 -0
- package/one/knowledge/ontology.md.backup +2822 -0
- package/one/knowledge/ontology.yaml +1165 -0
- package/one/knowledge/patterns/backend/convex-mutation-pattern.md +100 -0
- package/one/knowledge/patterns/backend/convex-query-pattern.md +88 -0
- package/one/knowledge/patterns/backend/mutation-template.md +231 -0
- package/one/knowledge/patterns/backend/query-template.md +267 -0
- package/one/knowledge/patterns/backend/service-template.md +237 -0
- package/one/knowledge/patterns/design/component-architecture.md +399 -0
- package/one/knowledge/patterns/design/test-driven-design-pattern.md +162 -0
- package/one/knowledge/patterns/design/wireframe-template.md +216 -0
- package/one/knowledge/patterns/frontend/component-template.md +195 -0
- package/one/knowledge/patterns/frontend/form-template.md +276 -0
- package/one/knowledge/patterns/frontend/page-template.md +178 -0
- package/one/knowledge/patterns/frontend/react-component-pattern.md +128 -0
- package/one/knowledge/patterns/test/acceptance-criteria-template.md +378 -0
- package/one/knowledge/patterns/test/technical-test-template.md +544 -0
- package/one/knowledge/patterns/test/test-driven-pattern.md +140 -0
- package/one/knowledge/patterns/test/user-flow-template.md +254 -0
- package/one/knowledge/provider-creation-guide.md +1064 -0
- package/one/knowledge/quality-loop.md +401 -0
- package/one/knowledge/readme.md +131 -0
- package/one/knowledge/rules.md +626 -0
- package/one/knowledge/score.md +67 -0
- package/one/knowledge/specifications.md +855 -0
- package/one/knowledge/tags.md +130 -0
- package/one/knowledge/todo.md +251 -0
- package/one/license.md +84 -0
- package/one/people/anthony-o-connell.md +440 -0
- package/one/people/people.md +567 -0
- package/one/things/CHECKLIST.md +356 -0
- package/one/things/ONE.md +510 -0
- package/one/things/agents/agent-backend.md +1401 -0
- package/one/things/agents/agent-builder.md +955 -0
- package/one/things/agents/agent-clean.md +709 -0
- package/one/things/agents/agent-clone.md +1341 -0
- package/one/things/agents/agent-designer.md +2177 -0
- package/one/things/agents/agent-director.md +1508 -0
- package/one/things/agents/agent-documenter.md +1049 -0
- package/one/things/agents/agent-frontend.md +1119 -0
- package/one/things/agents/agent-integrator.md +1192 -0
- package/one/things/agents/agent-problem-solver.md +1379 -0
- package/one/things/agents/agent-quality.md +1353 -0
- package/one/things/agents/agent-sales.md +986 -0
- package/one/things/cascade/cascade.yaml +464 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +470 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +264 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts.md +486 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +497 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +227 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +516 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +544 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +223 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination.md +508 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +609 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +195 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management.md +577 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +797 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +212 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops.md +641 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +610 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +213 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure.md +575 -0
- package/one/things/cascade/docs/examples/readme.md +222 -0
- package/one/things/cascade/docs/getting-started.md +515 -0
- package/one/things/cascade/docs/workflow.md +1372 -0
- package/one/things/cascade/readme.md +336 -0
- package/one/things/cascade/templates/feature-template.md +267 -0
- package/one/things/claude/agents/advocacy-activation-manager.md +685 -0
- package/one/things/claude/agents/advocacy-campaign-designer.md +663 -0
- package/one/things/claude/agents/analyst.md +483 -0
- package/one/things/claude/agents/architect.md +480 -0
- package/one/things/claude/agents/brand-identity-specialist.md +513 -0
- package/one/things/claude/agents/bstp-token-strategist.md +667 -0
- package/one/things/claude/agents/builder-repo.md +489 -0
- package/one/things/claude/agents/bullstamp-community-builder.md +574 -0
- package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +506 -0
- package/one/things/claude/agents/bulltilt-platform-growth.md +567 -0
- package/one/things/claude/agents/company-bullstamp-character.md +587 -0
- package/one/things/claude/agents/company-bullstamp-community.md +292 -0
- package/one/things/claude/agents/company-bullstamp-marketing.md +292 -0
- package/one/things/claude/agents/company-bullstamp-token.md +292 -0
- package/one/things/claude/agents/company-bulltilt-growth.md +292 -0
- package/one/things/claude/agents/content-bibliography-formatter.md +381 -0
- package/one/things/claude/agents/content-calendar-planner.md +448 -0
- package/one/things/claude/agents/content-chapter-formatter.md +488 -0
- package/one/things/claude/agents/content-formatter.md +546 -0
- package/one/things/claude/agents/content-hook-specialist.md +462 -0
- package/one/things/claude/agents/content-image-formatter.md +535 -0
- package/one/things/claude/agents/content-introduction-formatter.md +485 -0
- package/one/things/claude/agents/content-multiplication-engine.md +556 -0
- package/one/things/claude/agents/content-playbook-writer.md +448 -0
- package/one/things/claude/agents/content-team-manager.md +622 -0
- package/one/things/claude/agents/content-toc-formatter.md +522 -0
- package/one/things/claude/agents/convex-backend-specialist.md +2561 -0
- package/one/things/claude/agents/core-manager.md +582 -0
- package/one/things/claude/agents/core-master.md +403 -0
- package/one/things/claude/agents/cross-functional-manager.md +471 -0
- package/one/things/claude/agents/crypto-airdrop-strategist.md +602 -0
- package/one/things/claude/agents/crypto-analytics-educator.md +553 -0
- package/one/things/claude/agents/crypto-architecture-specialist.md +466 -0
- package/one/things/claude/agents/crypto-community-analyst.md +298 -0
- package/one/things/claude/agents/crypto-community-psychologist.md +509 -0
- package/one/things/claude/agents/crypto-dex-optimization-expert.md +538 -0
- package/one/things/claude/agents/crypto-dex-optimizer.md +292 -0
- package/one/things/claude/agents/crypto-diamond-formation-specialist.md +513 -0
- package/one/things/claude/agents/crypto-diamond-hands.md +292 -0
- package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +554 -0
- package/one/things/claude/agents/crypto-engagement-specialist.md +540 -0
- package/one/things/claude/agents/crypto-market-researcher.md +292 -0
- package/one/things/claude/agents/crypto-marketing-orchestrator.md +523 -0
- package/one/things/claude/agents/crypto-network-effect-amplifier.md +569 -0
- package/one/things/claude/agents/crypto-optimization-analyst.md +554 -0
- package/one/things/claude/agents/crypto-strategic-synthesizer.md +517 -0
- package/one/things/claude/agents/crypto-team-manager.md +387 -0
- package/one/things/claude/agents/crypto-token-analyst.md +278 -0
- package/one/things/claude/agents/crypto-viral-content-creator.md +546 -0
- package/one/things/claude/agents/crypto-wallet-identification-expert.md +517 -0
- package/one/things/claude/agents/crypto-wallet-identifier.md +292 -0
- package/one/things/claude/agents/customer-journey-designer.md +481 -0
- package/one/things/claude/agents/customer-success-manager.md +581 -0
- package/one/things/claude/agents/dev.md +413 -0
- package/one/things/claude/agents/documenter.md +546 -0
- package/one/things/claude/agents/elevate-marketing-orchestrator.md +410 -0
- package/one/things/claude/agents/engagement-specialist.md +509 -0
- package/one/things/claude/agents/engineering-architect.md +387 -0
- package/one/things/claude/agents/engineering-business-analyst.md +537 -0
- package/one/things/claude/agents/engineering-developer.md +387 -0
- package/one/things/claude/agents/engineering-director.md +282 -0
- package/one/things/claude/agents/engineering-ingestor.md +649 -0
- package/one/things/claude/agents/engineering-product-manager.md +537 -0
- package/one/things/claude/agents/engineering-product-owner.md +537 -0
- package/one/things/claude/agents/engineering-project-coordinator.md +537 -0
- package/one/things/claude/agents/engineering-quality-assurance.md +393 -0
- package/one/things/claude/agents/engineering-team-manager.md +512 -0
- package/one/things/claude/agents/engineering-user-experience.md +387 -0
- package/one/things/claude/agents/framework-elevate-manager.md +294 -0
- package/one/things/claude/agents/improver.md +763 -0
- package/one/things/claude/agents/intelligence-team-manager.md +385 -0
- package/one/things/claude/agents/lead-capture-expert.md +466 -0
- package/one/things/claude/agents/lead-magnet-creator.md +453 -0
- package/one/things/claude/agents/market-research-analyst.md +412 -0
- package/one/things/claude/agents/marketing-brand-identity.md +314 -0
- package/one/things/claude/agents/marketing-content-hooks.md +450 -0
- package/one/things/claude/agents/marketing-content-multiplier.md +326 -0
- package/one/things/claude/agents/marketing-content-poster.md +361 -0
- package/one/things/claude/agents/marketing-customer-journey.md +326 -0
- package/one/things/claude/agents/marketing-director.md +397 -0
- package/one/things/claude/agents/marketing-engagement.md +326 -0
- package/one/things/claude/agents/marketing-lead-capture.md +326 -0
- package/one/things/claude/agents/marketing-lead-magnet.md +326 -0
- package/one/things/claude/agents/marketing-network-effects.md +326 -0
- package/one/things/claude/agents/marketing-nurture-campaigns.md +326 -0
- package/one/things/claude/agents/marketing-share-optimizer.md +326 -0
- package/one/things/claude/agents/marketing-team-manager.md +446 -0
- package/one/things/claude/agents/marketing-viral-growth.md +201 -0
- package/one/things/claude/agents/mission-commander.md +373 -0
- package/one/things/claude/agents/network-effect-analyst.md +587 -0
- package/one/things/claude/agents/nextjs-15-specialist.md +1547 -0
- package/one/things/claude/agents/npx.md +890 -0
- package/one/things/claude/agents/nurture-campaign-manager.md +531 -0
- package/one/things/claude/agents/one-master.md +355 -0
- package/one/things/claude/agents/one-orchestrator.md +315 -0
- package/one/things/claude/agents/one.md +601 -0
- package/one/things/claude/agents/playbook-generator.md +503 -0
- package/one/things/claude/agents/pm.md +326 -0
- package/one/things/claude/agents/po.md +345 -0
- package/one/things/claude/agents/qa.md +336 -0
- package/one/things/claude/agents/research-foundation-analyst.md +307 -0
- package/one/things/claude/agents/research-intelligence-gatherer.md +408 -0
- package/one/things/claude/agents/research-market-analyst.md +307 -0
- package/one/things/claude/agents/research-team-manager.md +482 -0
- package/one/things/claude/agents/sales-environment-optimizer.md +494 -0
- package/one/things/claude/agents/sales-team-manager.md +400 -0
- package/one/things/claude/agents/sales-upsell-strategist.md +307 -0
- package/one/things/claude/agents/service-advocacy-campaigns.md +307 -0
- package/one/things/claude/agents/service-advocacy-manager.md +307 -0
- package/one/things/claude/agents/service-success-manager.md +307 -0
- package/one/things/claude/agents/service-team-manager.md +400 -0
- package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +2302 -0
- package/one/things/claude/agents/share-optimization-specialist.md +551 -0
- package/one/things/claude/agents/sm.md +327 -0
- package/one/things/claude/agents/story-teller.md +473 -0
- package/one/things/claude/agents/task-master.md +596 -0
- package/one/things/claude/agents/tauri-cross-platform-specialist.md +1827 -0
- package/one/things/claude/agents/tester.md +556 -0
- package/one/things/claude/agents/the-bull-character-manager.md +580 -0
- package/one/things/claude/agents/tools-playbook-generator.md +489 -0
- package/one/things/claude/agents/turbo-repo-builder.md +316 -0
- package/one/things/claude/agents/upsell-strategist.md +480 -0
- package/one/things/claude/agents/ux-expert.md +335 -0
- package/one/things/claude/agents/viral-growth-orchestrator.md +497 -0
- package/one/things/claude/claude-code-hooks-development.json +21 -0
- package/one/things/claude/claude-code-hooks-production.json +21 -0
- package/one/things/claude/claude-code-hooks.json +25 -0
- package/one/things/claude/commands/agent.md +104 -0
- package/one/things/claude/commands/cascade-status.md +128 -0
- package/one/things/claude/commands/ingest.md +290 -0
- package/one/things/claude/commands/ingestor.md +136 -0
- package/one/things/claude/commands/mission.md +83 -0
- package/one/things/claude/commands/npx.md +133 -0
- package/one/things/claude/commands/one.md +440 -0
- package/one/things/claude/commands/quality-check.md +204 -0
- package/one/things/claude/commands/smart-route.md +220 -0
- package/one/things/claude/commands/start.md +121 -0
- package/one/things/claude/commands/story.md +83 -0
- package/one/things/claude/commands/task.md +173 -0
- package/one/things/claude/hook-bypass.json +32 -0
- package/one/things/claude/hooks/agent-hook-config.json +427 -0
- package/one/things/claude/hooks/agent-hook-manager.js +525 -0
- package/one/things/claude/hooks/agent-load-balancer.js +271 -0
- package/one/things/claude/hooks/agent-request-interceptor.js +70 -0
- package/one/things/claude/hooks/build-hook.sh +156 -0
- package/one/things/claude/hooks/cascade-feedback.js +297 -0
- package/one/things/claude/hooks/cascade-integration-hooks.js +648 -0
- package/one/things/claude/hooks/cleanup-hook.sh +201 -0
- package/one/things/claude/hooks/continuous-improvement-monitor.js +510 -0
- package/one/things/claude/hooks/file-organization-engine.js +427 -0
- package/one/things/claude/hooks/file-organization-hook.sh +80 -0
- package/one/things/claude/hooks/file-organization-monitor.js +269 -0
- package/one/things/claude/hooks/format-hook.sh +43 -0
- package/one/things/claude/hooks/hook-bypass.sh +293 -0
- package/one/things/claude/hooks/hook-config-manager.js +202 -0
- package/one/things/claude/hooks/hook-debouncer.sh +62 -0
- package/one/things/claude/hooks/hook-logger.sh +89 -0
- package/one/things/claude/hooks/hook-orchestrator.js +662 -0
- package/one/things/claude/hooks/hook-performance-report.js +120 -0
- package/one/things/claude/hooks/lint-hook.sh +140 -0
- package/one/things/claude/hooks/mcp-cascade-integration.js +816 -0
- package/one/things/claude/hooks/memory-optimizer.js +510 -0
- package/one/things/claude/hooks/notification-hook.sh +204 -0
- package/one/things/claude/hooks/ontology-compliance.js +394 -0
- package/one/things/claude/hooks/ontology-hook-manager.js +316 -0
- package/one/things/claude/hooks/ontology-validation-engine.js +317 -0
- package/one/things/claude/hooks/ontology-validation-hook.sh +86 -0
- package/one/things/claude/hooks/performance-metrics.json +25 -0
- package/one/things/claude/hooks/performance-monitoring-hook.js +422 -0
- package/one/things/claude/hooks/quality-scoring-engine.js +834 -0
- package/one/things/claude/hooks/security-hook.sh +256 -0
- package/one/things/claude/hooks/simple-load-balancer.js +238 -0
- package/one/things/claude/hooks/startup-optimizer.js +625 -0
- package/one/things/claude/hooks/story-scoring-system.js +445 -0
- package/one/things/claude/hooks/story-validation-engine.js +473 -0
- package/one/things/claude/hooks/story-validation-hook-enhanced.sh +210 -0
- package/one/things/claude/hooks/story-validation-hook.sh +145 -0
- package/one/things/claude/hooks/structure-synchronizer.js +194 -0
- package/one/things/claude/hooks/sub-agent-output-validator.js +647 -0
- package/one/things/claude/hooks/sub-agent-validation-hook.js +343 -0
- package/one/things/claude/hooks/test-hook.sh +145 -0
- package/one/things/claude/hooks/test-story-validation.sh +170 -0
- package/one/things/claude/hooks/trinity-validation-system.js +392 -0
- package/one/things/claude/settings-local.json +86 -0
- package/one/things/cli/cli-code.md +652 -0
- package/one/things/cli/cli-compiler-code.md +652 -0
- package/one/things/cli/cli.md +1068 -0
- package/one/things/components/card-shadcn.md +929 -0
- package/one/things/components/card.md +1050 -0
- package/one/things/components.md +1669 -0
- package/one/things/componets.md +4 -0
- package/one/things/creator-diagram.md +166 -0
- package/one/things/examples/children/lemonade-stand.md +366 -0
- package/one/things/examples/enterprise/crm-saas.md +1429 -0
- package/one/things/features/1-1-agent-prompts/design.md +470 -0
- package/one/things/features/1-1-agent-prompts/tests.md +264 -0
- package/one/things/features/1-1-agent-prompts.md +486 -0
- package/one/things/features/1-2-yaml-orchestrator/design.md +497 -0
- package/one/things/features/1-2-yaml-orchestrator/tests.md +227 -0
- package/one/things/features/1-2-yaml-orchestrator.md +516 -0
- package/one/things/features/1-3-event-coordination/design.md +544 -0
- package/one/things/features/1-3-event-coordination/tests.md +223 -0
- package/one/things/features/1-3-event-coordination.md +508 -0
- package/one/things/features/1-4-knowledge-management/design.md +609 -0
- package/one/things/features/1-4-knowledge-management/tests.md +195 -0
- package/one/things/features/1-4-knowledge-management.md +577 -0
- package/one/things/features/1-5-quality-loops/design.md +797 -0
- package/one/things/features/1-5-quality-loops/tests.md +212 -0
- package/one/things/features/1-5-quality-loops.md +641 -0
- package/one/things/features/1-6-numbering-structure/design.md +610 -0
- package/one/things/features/1-6-numbering-structure/tests.md +213 -0
- package/one/things/features/1-6-numbering-structure.md +575 -0
- package/one/things/features/2-1-dataprovider-interface.md +2358 -0
- package/one/things/features/2-2-config-system.md +3075 -0
- package/one/things/features/2-3-effectts-services.md +1498 -0
- package/one/things/features/2-4-react-hooks.md +2120 -0
- package/one/things/features/2-5-auth-migration.md +2046 -0
- package/one/things/features/2-6-dashboard-migration.md +1985 -0
- package/one/things/features/2-7-alternative-providers.md +2505 -0
- package/one/things/features/2-7-implementation-report.md +680 -0
- package/one/things/features/2-cli.md +1235 -0
- package/one/things/features/2-design.md +1738 -0
- package/one/things/features/2-tests.md +520 -0
- package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +521 -0
- package/one/things/features/DECOUPLING.md +272 -0
- package/one/things/features/DEPLOYMENT.md +452 -0
- package/one/things/features/IMPLEMENTATION_SUMMARY.md +316 -0
- package/one/things/features/dataprovider-interface/1-tests.md +1522 -0
- package/one/things/features/improve.md +843 -0
- package/one/things/features/remove-convex-deps.md +45 -0
- package/one/things/features/top-features.md +79 -0
- package/one/things/features/use-one-backend.md +1180 -0
- package/one/things/ideas/1-create-workflow.md +189 -0
- package/one/things/ideas/2-backend-agnostic-frontend.md +384 -0
- package/one/things/plans/1-create-workflow-status.md +555 -0
- package/one/things/plans/1-create-workflow.md +713 -0
- package/one/things/plans/2-backend-agnostic-frontend.md +543 -0
- package/one/things/plans/3-groups.md +502 -0
- package/one/things/plans/app.md +761 -0
- package/one/things/plans/backend-agnostic-frontend.md +323 -0
- package/one/things/plans/better-auth-any-backend-revised.md +1065 -0
- package/one/things/plans/better-auth-any-backend.md +1852 -0
- package/one/things/plans/better-auth-available-features.md +235 -0
- package/one/things/plans/big-plan.md +38 -0
- package/one/things/plans/convex-better-auth.md +1109 -0
- package/one/things/plans/convex-on-off.md +389 -0
- package/one/things/plans/deploy-to-cloudflare.md +581 -0
- package/one/things/plans/desktop.md +1121 -0
- package/one/things/plans/effect-components.md +1669 -0
- package/one/things/plans/effect.md +973 -0
- package/one/things/plans/email.md +953 -0
- package/one/things/plans/enhance-auth.md +1669 -0
- package/one/things/plans/install-components.md +198 -0
- package/one/things/plans/landing.md +728 -0
- package/one/things/plans/layout.md +205 -0
- package/one/things/plans/mail-backend.md +1308 -0
- package/one/things/plans/mail.md +2624 -0
- package/one/things/plans/next-features.md +83 -0
- package/one/things/plans/one.md +658 -0
- package/one/things/plans/ontology-6-dimensions.md +2216 -0
- package/one/things/plans/ontology-driven-strategy.md +866 -0
- package/one/things/plans/ontology-ui-approach.md +357 -0
- package/one/things/plans/open-agent.md +785 -0
- package/one/things/plans/organizations-to-groups.md +705 -0
- package/one/things/plans/performace.md +90 -0
- package/one/things/plans/release.md +432 -0
- package/one/things/plans/releases.md +809 -0
- package/one/things/plans/repos.md +76 -0
- package/one/things/plans/separate-copy-2.md +1293 -0
- package/one/things/plans/separate-copy-3.md +2458 -0
- package/one/things/plans/separate-copy.md +1293 -0
- package/one/things/plans/separate.md +1983 -0
- package/one/things/plans/shadcn-integration-summary.md +450 -0
- package/one/things/plans/sidebar.md +172 -0
- package/one/things/plans/small-fixes.md +5 -0
- package/one/things/plans/test-backend-connection.md +476 -0
- package/one/things/plans/workflow-files.md +1196 -0
- package/one/things/plans/workflow.md +1372 -0
- package/one/things/products/cascade-landing-page.md +737 -0
- package/one/things/products/cascade.md +1518 -0
- package/one/things/products/context-engineering.md +1427 -0
- package/one/things/products/onthology.md +0 -0
- package/one/things/products/ontology-ui-shadcn.md +1280 -0
- package/one/things/products/ontology-ui.md +1387 -0
- package/one/things/products/ontology.md +717 -0
- package/one/things/products/sdk.md +557 -0
- package/one/things/promptkit.md +903 -0
- package/one/things/service-providers-new.md +982 -0
- package/one/things/service-providers.md +1092 -0
- package/one/things/system.md +600 -0
- package/one/things/tests/2-1-dataprovider-interface.md +1144 -0
- package/one/things/tests/2-1-test-analysis.md +496 -0
- package/one/things/things.md +349 -0
- package/one/things/todo.md +1248 -0
- package/one/things/vision/elegant-interface.md +214 -0
- package/package.json +5 -2
|
@@ -0,0 +1,1092 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// convex/services/providers/openai.ts
|
|
3
|
+
// OpenAI Provider - LLM operations, embeddings, chat completions
|
|
4
|
+
// ============================================================================
|
|
5
|
+
|
|
6
|
+
import { Effect, Context, Layer } from "effect";
|
|
7
|
+
import OpenAI from "openai";
|
|
8
|
+
|
|
9
|
+
// Error Types
|
|
10
|
+
export class OpenAIError {
|
|
11
|
+
readonly _tag = "OpenAIError";
|
|
12
|
+
constructor(readonly message: string, readonly code?: string) {}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class RateLimitError {
|
|
16
|
+
readonly _tag = "RateLimitError";
|
|
17
|
+
constructor(readonly retryAfter?: number) {}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class InvalidResponseError {
|
|
21
|
+
readonly _tag = "InvalidResponseError";
|
|
22
|
+
constructor(readonly response: any) {}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Service Interface
|
|
26
|
+
export class OpenAIProvider extends Context.Tag("OpenAIProvider")<
|
|
27
|
+
OpenAIProvider,
|
|
28
|
+
{
|
|
29
|
+
readonly chat: (params: {
|
|
30
|
+
systemPrompt: string;
|
|
31
|
+
messages: Array<{ role: string; content: string }>;
|
|
32
|
+
context?: string;
|
|
33
|
+
model?: string;
|
|
34
|
+
temperature?: number;
|
|
35
|
+
maxTokens?: number;
|
|
36
|
+
}) => Effect.Effect<
|
|
37
|
+
{
|
|
38
|
+
content: string;
|
|
39
|
+
usage: {
|
|
40
|
+
promptTokens: number;
|
|
41
|
+
completionTokens: number;
|
|
42
|
+
totalTokens: number;
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
OpenAIError | RateLimitError
|
|
46
|
+
>;
|
|
47
|
+
|
|
48
|
+
readonly embed: (
|
|
49
|
+
text: string,
|
|
50
|
+
model?: string
|
|
51
|
+
) => Effect.Effect<number[], OpenAIError | RateLimitError>;
|
|
52
|
+
|
|
53
|
+
readonly generateImage: (
|
|
54
|
+
prompt: string,
|
|
55
|
+
options?: { size?: string; quality?: string }
|
|
56
|
+
) => Effect.Effect<{ url: string }, OpenAIError | RateLimitError>;
|
|
57
|
+
|
|
58
|
+
readonly analyzePersonality: (content: {
|
|
59
|
+
videos: string[];
|
|
60
|
+
posts: string[];
|
|
61
|
+
interactions: string[];
|
|
62
|
+
}) => Effect.Effect<
|
|
63
|
+
{
|
|
64
|
+
systemPrompt: string;
|
|
65
|
+
traits: string[];
|
|
66
|
+
style: string;
|
|
67
|
+
values: string[];
|
|
68
|
+
},
|
|
69
|
+
OpenAIError
|
|
70
|
+
>;
|
|
71
|
+
}
|
|
72
|
+
>() {}
|
|
73
|
+
|
|
74
|
+
// Implementation
|
|
75
|
+
export const OpenAIProviderLive = Layer.effect(
|
|
76
|
+
OpenAIProvider,
|
|
77
|
+
Effect.gen(function* () {
|
|
78
|
+
const apiKey = yield* Effect.sync(() => process.env.OPENAI_API_KEY);
|
|
79
|
+
|
|
80
|
+
if (!apiKey) {
|
|
81
|
+
return yield* Effect.fail(
|
|
82
|
+
new OpenAIError("OPENAI_API_KEY environment variable not set")
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const client = new OpenAI({ apiKey });
|
|
87
|
+
|
|
88
|
+
return OpenAIProvider.of({
|
|
89
|
+
chat: (params) =>
|
|
90
|
+
Effect.gen(function* () {
|
|
91
|
+
const messages: OpenAI.Chat.ChatCompletionMessageParam[] = [
|
|
92
|
+
{ role: "system", content: params.systemPrompt },
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
if (params.context) {
|
|
96
|
+
messages.push({
|
|
97
|
+
role: "system",
|
|
98
|
+
content: `Context:\n${params.context}`,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
messages.push(
|
|
103
|
+
...params.messages.map(
|
|
104
|
+
(m): OpenAI.Chat.ChatCompletionMessageParam => ({
|
|
105
|
+
role: m.role as "user" | "assistant",
|
|
106
|
+
content: m.content,
|
|
107
|
+
})
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const response = yield* Effect.tryPromise({
|
|
112
|
+
try: () =>
|
|
113
|
+
client.chat.completions.create({
|
|
114
|
+
model: params.model || "gpt-4-turbo",
|
|
115
|
+
messages,
|
|
116
|
+
temperature: params.temperature ?? 0.7,
|
|
117
|
+
max_tokens: params.maxTokens,
|
|
118
|
+
}),
|
|
119
|
+
catch: (error: any) => {
|
|
120
|
+
if (error.status === 429) {
|
|
121
|
+
return new RateLimitError(error.headers?.["retry-after"]);
|
|
122
|
+
}
|
|
123
|
+
return new OpenAIError(error.message, error.code);
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const choice = response.choices[0];
|
|
128
|
+
if (!choice?.message?.content) {
|
|
129
|
+
return yield* Effect.fail(
|
|
130
|
+
new InvalidResponseError(response)
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
content: choice.message.content,
|
|
136
|
+
usage: {
|
|
137
|
+
promptTokens: response.usage?.prompt_tokens || 0,
|
|
138
|
+
completionTokens: response.usage?.completion_tokens || 0,
|
|
139
|
+
totalTokens: response.usage?.total_tokens || 0,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}).pipe(
|
|
143
|
+
Effect.retry({ times: 3, delay: "1 second" }),
|
|
144
|
+
Effect.timeout("60 seconds")
|
|
145
|
+
),
|
|
146
|
+
|
|
147
|
+
embed: (text, model = "text-embedding-3-small") =>
|
|
148
|
+
Effect.gen(function* () {
|
|
149
|
+
const response = yield* Effect.tryPromise({
|
|
150
|
+
try: () =>
|
|
151
|
+
client.embeddings.create({
|
|
152
|
+
model,
|
|
153
|
+
input: text,
|
|
154
|
+
dimensions: 1536,
|
|
155
|
+
}),
|
|
156
|
+
catch: (error: any) => {
|
|
157
|
+
if (error.status === 429) {
|
|
158
|
+
return new RateLimitError(error.headers?.["retry-after"]);
|
|
159
|
+
}
|
|
160
|
+
return new OpenAIError(error.message, error.code);
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
return response.data[0].embedding;
|
|
165
|
+
}).pipe(Effect.retry({ times: 3, delay: "1 second" })),
|
|
166
|
+
|
|
167
|
+
generateImage: (prompt, options) =>
|
|
168
|
+
Effect.gen(function* () {
|
|
169
|
+
const response = yield* Effect.tryPromise({
|
|
170
|
+
try: () =>
|
|
171
|
+
client.images.generate({
|
|
172
|
+
model: "dall-e-3",
|
|
173
|
+
prompt,
|
|
174
|
+
size: (options?.size as any) || "1024x1024",
|
|
175
|
+
quality: (options?.quality as any) || "standard",
|
|
176
|
+
n: 1,
|
|
177
|
+
}),
|
|
178
|
+
catch: (error: any) =>
|
|
179
|
+
new OpenAIError(error.message, error.code),
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const url = response.data[0]?.url;
|
|
183
|
+
if (!url) {
|
|
184
|
+
return yield* Effect.fail(
|
|
185
|
+
new InvalidResponseError(response)
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return { url };
|
|
190
|
+
}),
|
|
191
|
+
|
|
192
|
+
analyzePersonality: (content) =>
|
|
193
|
+
Effect.gen(function* () {
|
|
194
|
+
const prompt = `Analyze this creator's personality and communication style to create an AI clone system prompt.
|
|
195
|
+
|
|
196
|
+
Videos: ${content.videos.join("\n")}
|
|
197
|
+
Posts: ${content.posts.join("\n")}
|
|
198
|
+
Interactions: ${content.interactions.join("\n")}
|
|
199
|
+
|
|
200
|
+
Provide a JSON response with:
|
|
201
|
+
{
|
|
202
|
+
"systemPrompt": "A detailed system prompt for the AI clone",
|
|
203
|
+
"traits": ["trait1", "trait2", ...],
|
|
204
|
+
"style": "communication style description",
|
|
205
|
+
"values": ["value1", "value2", ...]
|
|
206
|
+
}`;
|
|
207
|
+
|
|
208
|
+
const response = yield* Effect.gen(function* () {
|
|
209
|
+
return yield* this.chat({
|
|
210
|
+
systemPrompt:
|
|
211
|
+
"You are a personality analysis expert. Respond with valid JSON only.",
|
|
212
|
+
messages: [{ role: "user", content: prompt }],
|
|
213
|
+
temperature: 0.3,
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
const parsed = yield* Effect.try({
|
|
218
|
+
try: () => JSON.parse(response.content),
|
|
219
|
+
catch: () => new InvalidResponseError(response.content),
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
return parsed;
|
|
223
|
+
}),
|
|
224
|
+
});
|
|
225
|
+
})
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
// Mock for Testing
|
|
229
|
+
export const OpenAIProviderTest = Layer.succeed(
|
|
230
|
+
OpenAIProvider,
|
|
231
|
+
OpenAIProvider.of({
|
|
232
|
+
chat: () =>
|
|
233
|
+
Effect.succeed({
|
|
234
|
+
content: "Mock AI response",
|
|
235
|
+
usage: { promptTokens: 10, completionTokens: 20, totalTokens: 30 },
|
|
236
|
+
}),
|
|
237
|
+
embed: () => Effect.succeed(Array(1536).fill(0.1)),
|
|
238
|
+
generateImage: () => Effect.succeed({ url: "https://mock-image.jpg" }),
|
|
239
|
+
analyzePersonality: () =>
|
|
240
|
+
Effect.succeed({
|
|
241
|
+
systemPrompt: "Mock system prompt",
|
|
242
|
+
traits: ["friendly", "knowledgeable"],
|
|
243
|
+
style: "casual and helpful",
|
|
244
|
+
values: ["authenticity", "growth"],
|
|
245
|
+
}),
|
|
246
|
+
})
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
// ============================================================================
|
|
250
|
+
// convex/services/providers/elevenlabs.ts
|
|
251
|
+
// ElevenLabs Provider - Voice cloning and text-to-speech
|
|
252
|
+
// ============================================================================
|
|
253
|
+
|
|
254
|
+
import { Effect, Context, Layer } from "effect";
|
|
255
|
+
|
|
256
|
+
// Error Types
|
|
257
|
+
export class ElevenLabsError {
|
|
258
|
+
readonly _tag = "ElevenLabsError";
|
|
259
|
+
constructor(readonly message: string) {}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export class VoiceCloneFailedError {
|
|
263
|
+
readonly _tag = "VoiceCloneFailedError";
|
|
264
|
+
constructor(readonly reason: string) {}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export class InsufficientSamplesError {
|
|
268
|
+
readonly _tag = "InsufficientSamplesError";
|
|
269
|
+
constructor(readonly provided: number, readonly required: number) {}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Service Interface
|
|
273
|
+
export class ElevenLabsProvider extends Context.Tag("ElevenLabsProvider")<
|
|
274
|
+
ElevenLabsProvider,
|
|
275
|
+
{
|
|
276
|
+
readonly cloneVoice: (params: {
|
|
277
|
+
name: string;
|
|
278
|
+
samples: string[]; // Storage IDs or URLs
|
|
279
|
+
description?: string;
|
|
280
|
+
}) => Effect.Effect<
|
|
281
|
+
{ voiceId: string },
|
|
282
|
+
ElevenLabsError | VoiceCloneFailedError | InsufficientSamplesError
|
|
283
|
+
>;
|
|
284
|
+
|
|
285
|
+
readonly textToSpeech: (params: {
|
|
286
|
+
voiceId: string;
|
|
287
|
+
text: string;
|
|
288
|
+
model?: string;
|
|
289
|
+
}) => Effect.Effect<{ audioUrl: string }, ElevenLabsError>;
|
|
290
|
+
|
|
291
|
+
readonly listVoices: () => Effect.Effect<
|
|
292
|
+
Array<{ id: string; name: string }>,
|
|
293
|
+
ElevenLabsError
|
|
294
|
+
>;
|
|
295
|
+
|
|
296
|
+
readonly deleteVoice: (
|
|
297
|
+
voiceId: string
|
|
298
|
+
) => Effect.Effect<void, ElevenLabsError>;
|
|
299
|
+
}
|
|
300
|
+
>() {}
|
|
301
|
+
|
|
302
|
+
// Implementation
|
|
303
|
+
export const ElevenLabsProviderLive = Layer.effect(
|
|
304
|
+
ElevenLabsProvider,
|
|
305
|
+
Effect.gen(function* () {
|
|
306
|
+
const apiKey = yield* Effect.sync(() => process.env.ELEVENLABS_API_KEY);
|
|
307
|
+
|
|
308
|
+
if (!apiKey) {
|
|
309
|
+
return yield* Effect.fail(
|
|
310
|
+
new ElevenLabsError("ELEVENLABS_API_KEY not set")
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const baseUrl = "https://api.elevenlabs.io/v1";
|
|
315
|
+
|
|
316
|
+
return ElevenLabsProvider.of({
|
|
317
|
+
cloneVoice: (params) =>
|
|
318
|
+
Effect.gen(function* () {
|
|
319
|
+
// Validate sample count
|
|
320
|
+
if (params.samples.length < 5) {
|
|
321
|
+
return yield* Effect.fail(
|
|
322
|
+
new InsufficientSamplesError(params.samples.length, 5)
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Create FormData with samples
|
|
327
|
+
const formData = new FormData();
|
|
328
|
+
formData.append("name", params.name);
|
|
329
|
+
if (params.description) {
|
|
330
|
+
formData.append("description", params.description);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Add audio samples
|
|
334
|
+
for (const sample of params.samples) {
|
|
335
|
+
// Fetch audio file from storage/URL
|
|
336
|
+
const audioBlob = yield* Effect.tryPromise({
|
|
337
|
+
try: async () => {
|
|
338
|
+
const response = await fetch(sample);
|
|
339
|
+
return await response.blob();
|
|
340
|
+
},
|
|
341
|
+
catch: (error: any) =>
|
|
342
|
+
new ElevenLabsError(`Failed to fetch sample: ${error.message}`),
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
formData.append("files", audioBlob, `sample-${Date.now()}.mp3`);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// API call to create voice
|
|
349
|
+
const response = yield* Effect.tryPromise({
|
|
350
|
+
try: async () => {
|
|
351
|
+
const res = await fetch(`${baseUrl}/voices/add`, {
|
|
352
|
+
method: "POST",
|
|
353
|
+
headers: { "xi-api-key": apiKey },
|
|
354
|
+
body: formData,
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
if (!res.ok) {
|
|
358
|
+
const error = await res.json();
|
|
359
|
+
throw new Error(error.detail?.message || "Voice clone failed");
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return await res.json();
|
|
363
|
+
},
|
|
364
|
+
catch: (error: any) =>
|
|
365
|
+
new VoiceCloneFailedError(error.message),
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
return { voiceId: response.voice_id };
|
|
369
|
+
}).pipe(
|
|
370
|
+
Effect.retry({ times: 2, delay: "5 seconds" }),
|
|
371
|
+
Effect.timeout("5 minutes")
|
|
372
|
+
),
|
|
373
|
+
|
|
374
|
+
textToSpeech: (params) =>
|
|
375
|
+
Effect.gen(function* () {
|
|
376
|
+
const response = yield* Effect.tryPromise({
|
|
377
|
+
try: async () => {
|
|
378
|
+
const res = await fetch(
|
|
379
|
+
`${baseUrl}/text-to-speech/${params.voiceId}`,
|
|
380
|
+
{
|
|
381
|
+
method: "POST",
|
|
382
|
+
headers: {
|
|
383
|
+
"xi-api-key": apiKey,
|
|
384
|
+
"Content-Type": "application/json",
|
|
385
|
+
},
|
|
386
|
+
body: JSON.stringify({
|
|
387
|
+
text: params.text,
|
|
388
|
+
model_id: params.model || "eleven_multilingual_v2",
|
|
389
|
+
voice_settings: {
|
|
390
|
+
stability: 0.5,
|
|
391
|
+
similarity_boost: 0.75,
|
|
392
|
+
},
|
|
393
|
+
}),
|
|
394
|
+
}
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
if (!res.ok) {
|
|
398
|
+
throw new Error("Text-to-speech failed");
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
return await res.blob();
|
|
402
|
+
},
|
|
403
|
+
catch: (error: any) => new ElevenLabsError(error.message),
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
// Upload to storage and return URL
|
|
407
|
+
const audioUrl = yield* Effect.succeed(
|
|
408
|
+
URL.createObjectURL(response)
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
return { audioUrl };
|
|
412
|
+
}),
|
|
413
|
+
|
|
414
|
+
listVoices: () =>
|
|
415
|
+
Effect.gen(function* () {
|
|
416
|
+
const response = yield* Effect.tryPromise({
|
|
417
|
+
try: async () => {
|
|
418
|
+
const res = await fetch(`${baseUrl}/voices`, {
|
|
419
|
+
headers: { "xi-api-key": apiKey },
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
if (!res.ok) {
|
|
423
|
+
throw new Error("Failed to list voices");
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return await res.json();
|
|
427
|
+
},
|
|
428
|
+
catch: (error: any) => new ElevenLabsError(error.message),
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
return response.voices.map((v: any) => ({
|
|
432
|
+
id: v.voice_id,
|
|
433
|
+
name: v.name,
|
|
434
|
+
}));
|
|
435
|
+
}),
|
|
436
|
+
|
|
437
|
+
deleteVoice: (voiceId) =>
|
|
438
|
+
Effect.gen(function* () {
|
|
439
|
+
yield* Effect.tryPromise({
|
|
440
|
+
try: async () => {
|
|
441
|
+
const res = await fetch(`${baseUrl}/voices/${voiceId}`, {
|
|
442
|
+
method: "DELETE",
|
|
443
|
+
headers: { "xi-api-key": apiKey },
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
if (!res.ok) {
|
|
447
|
+
throw new Error("Failed to delete voice");
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
catch: (error: any) => new ElevenLabsError(error.message),
|
|
451
|
+
});
|
|
452
|
+
}),
|
|
453
|
+
});
|
|
454
|
+
})
|
|
455
|
+
);
|
|
456
|
+
|
|
457
|
+
// Mock for Testing
|
|
458
|
+
export const ElevenLabsProviderTest = Layer.succeed(
|
|
459
|
+
ElevenLabsProvider,
|
|
460
|
+
ElevenLabsProvider.of({
|
|
461
|
+
cloneVoice: () => Effect.succeed({ voiceId: "mock-voice-id" }),
|
|
462
|
+
textToSpeech: () =>
|
|
463
|
+
Effect.succeed({ audioUrl: "https://mock-audio.mp3" }),
|
|
464
|
+
listVoices: () =>
|
|
465
|
+
Effect.succeed([
|
|
466
|
+
{ id: "voice-1", name: "Mock Voice 1" },
|
|
467
|
+
{ id: "voice-2", name: "Mock Voice 2" },
|
|
468
|
+
]),
|
|
469
|
+
deleteVoice: () => Effect.succeed(undefined),
|
|
470
|
+
})
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
// ============================================================================
|
|
474
|
+
// convex/services/providers/stripe.ts
|
|
475
|
+
// Stripe Provider - Payment processing
|
|
476
|
+
// ============================================================================
|
|
477
|
+
|
|
478
|
+
import { Effect, Context, Layer } from "effect";
|
|
479
|
+
import Stripe from "stripe";
|
|
480
|
+
|
|
481
|
+
// Error Types
|
|
482
|
+
export class StripeError {
|
|
483
|
+
readonly _tag = "StripeError";
|
|
484
|
+
constructor(
|
|
485
|
+
readonly message: string,
|
|
486
|
+
readonly code?: string,
|
|
487
|
+
readonly declineCode?: string
|
|
488
|
+
) {}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export class PaymentFailedError {
|
|
492
|
+
readonly _tag = "PaymentFailedError";
|
|
493
|
+
constructor(readonly reason: string) {}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// Service Interface
|
|
497
|
+
export class StripeProvider extends Context.Tag("StripeProvider")<
|
|
498
|
+
StripeProvider,
|
|
499
|
+
{
|
|
500
|
+
readonly charge: (params: {
|
|
501
|
+
amount: number; // in cents
|
|
502
|
+
currency: string;
|
|
503
|
+
metadata?: Record<string, string>;
|
|
504
|
+
}) => Effect.Effect<
|
|
505
|
+
{ id: string; amount: number; status: string },
|
|
506
|
+
StripeError | PaymentFailedError
|
|
507
|
+
>;
|
|
508
|
+
|
|
509
|
+
readonly createCheckoutSession: (params: {
|
|
510
|
+
amount: number;
|
|
511
|
+
currency: string;
|
|
512
|
+
successUrl: string;
|
|
513
|
+
cancelUrl: string;
|
|
514
|
+
metadata?: Record<string, string>;
|
|
515
|
+
}) => Effect.Effect<
|
|
516
|
+
{ sessionId: string; url: string },
|
|
517
|
+
StripeError
|
|
518
|
+
>;
|
|
519
|
+
|
|
520
|
+
readonly refund: (
|
|
521
|
+
paymentIntentId: string,
|
|
522
|
+
amount?: number
|
|
523
|
+
) => Effect.Effect<{ refundId: string }, StripeError>;
|
|
524
|
+
|
|
525
|
+
readonly createConnectAccount: (params: {
|
|
526
|
+
email: string;
|
|
527
|
+
country: string;
|
|
528
|
+
}) => Effect.Effect<{ accountId: string }, StripeError>;
|
|
529
|
+
|
|
530
|
+
readonly getPaymentStatus: (
|
|
531
|
+
paymentIntentId: string
|
|
532
|
+
) => Effect.Effect<
|
|
533
|
+
{ status: string; amount: number },
|
|
534
|
+
StripeError
|
|
535
|
+
>;
|
|
536
|
+
}
|
|
537
|
+
>() {}
|
|
538
|
+
|
|
539
|
+
// Implementation
|
|
540
|
+
export const StripeProviderLive = Layer.effect(
|
|
541
|
+
StripeProvider,
|
|
542
|
+
Effect.gen(function* () {
|
|
543
|
+
const apiKey = yield* Effect.sync(() => process.env.STRIPE_SECRET_KEY);
|
|
544
|
+
|
|
545
|
+
if (!apiKey) {
|
|
546
|
+
return yield* Effect.fail(
|
|
547
|
+
new StripeError("STRIPE_SECRET_KEY not set")
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const stripe = new Stripe(apiKey, {
|
|
552
|
+
apiVersion: "2024-11-20.acacia",
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
return StripeProvider.of({
|
|
556
|
+
charge: (params) =>
|
|
557
|
+
Effect.gen(function* () {
|
|
558
|
+
const paymentIntent = yield* Effect.tryPromise({
|
|
559
|
+
try: () =>
|
|
560
|
+
stripe.paymentIntents.create({
|
|
561
|
+
amount: params.amount,
|
|
562
|
+
currency: params.currency,
|
|
563
|
+
automatic_payment_methods: { enabled: true },
|
|
564
|
+
metadata: params.metadata,
|
|
565
|
+
}),
|
|
566
|
+
catch: (error: any) => {
|
|
567
|
+
if (error.type === "card_error") {
|
|
568
|
+
return new PaymentFailedError(
|
|
569
|
+
error.message || "Card declined"
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
return new StripeError(error.message, error.code);
|
|
573
|
+
},
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
return {
|
|
577
|
+
id: paymentIntent.id,
|
|
578
|
+
amount: paymentIntent.amount,
|
|
579
|
+
status: paymentIntent.status,
|
|
580
|
+
};
|
|
581
|
+
}),
|
|
582
|
+
|
|
583
|
+
createCheckoutSession: (params) =>
|
|
584
|
+
Effect.gen(function* () {
|
|
585
|
+
const session = yield* Effect.tryPromise({
|
|
586
|
+
try: () =>
|
|
587
|
+
stripe.checkout.sessions.create({
|
|
588
|
+
line_items: [
|
|
589
|
+
{
|
|
590
|
+
price_data: {
|
|
591
|
+
currency: params.currency,
|
|
592
|
+
unit_amount: params.amount,
|
|
593
|
+
product_data: {
|
|
594
|
+
name: "Token Purchase",
|
|
595
|
+
},
|
|
596
|
+
},
|
|
597
|
+
quantity: 1,
|
|
598
|
+
},
|
|
599
|
+
],
|
|
600
|
+
mode: "payment",
|
|
601
|
+
success_url: params.successUrl,
|
|
602
|
+
cancel_url: params.cancelUrl,
|
|
603
|
+
metadata: params.metadata,
|
|
604
|
+
}),
|
|
605
|
+
catch: (error: any) =>
|
|
606
|
+
new StripeError(error.message, error.code),
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
return {
|
|
610
|
+
sessionId: session.id,
|
|
611
|
+
url: session.url!,
|
|
612
|
+
};
|
|
613
|
+
}),
|
|
614
|
+
|
|
615
|
+
refund: (paymentIntentId, amount) =>
|
|
616
|
+
Effect.gen(function* () {
|
|
617
|
+
const refund = yield* Effect.tryPromise({
|
|
618
|
+
try: () =>
|
|
619
|
+
stripe.refunds.create({
|
|
620
|
+
payment_intent: paymentIntentId,
|
|
621
|
+
amount,
|
|
622
|
+
}),
|
|
623
|
+
catch: (error: any) =>
|
|
624
|
+
new StripeError(error.message, error.code),
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
return { refundId: refund.id };
|
|
628
|
+
}),
|
|
629
|
+
|
|
630
|
+
createConnectAccount: (params) =>
|
|
631
|
+
Effect.gen(function* () {
|
|
632
|
+
const account = yield* Effect.tryPromise({
|
|
633
|
+
try: () =>
|
|
634
|
+
stripe.accounts.create({
|
|
635
|
+
type: "express",
|
|
636
|
+
email: params.email,
|
|
637
|
+
country: params.country,
|
|
638
|
+
capabilities: {
|
|
639
|
+
card_payments: { requested: true },
|
|
640
|
+
transfers: { requested: true },
|
|
641
|
+
},
|
|
642
|
+
}),
|
|
643
|
+
catch: (error: any) =>
|
|
644
|
+
new StripeError(error.message, error.code),
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
return { accountId: account.id };
|
|
648
|
+
}),
|
|
649
|
+
|
|
650
|
+
getPaymentStatus: (paymentIntentId) =>
|
|
651
|
+
Effect.gen(function* () {
|
|
652
|
+
const paymentIntent = yield* Effect.tryPromise({
|
|
653
|
+
try: () => stripe.paymentIntents.retrieve(paymentIntentId),
|
|
654
|
+
catch: (error: any) =>
|
|
655
|
+
new StripeError(error.message, error.code),
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
return {
|
|
659
|
+
status: paymentIntent.status,
|
|
660
|
+
amount: paymentIntent.amount,
|
|
661
|
+
};
|
|
662
|
+
}),
|
|
663
|
+
});
|
|
664
|
+
})
|
|
665
|
+
);
|
|
666
|
+
|
|
667
|
+
// Mock for Testing
|
|
668
|
+
export const StripeProviderTest = Layer.succeed(
|
|
669
|
+
StripeProvider,
|
|
670
|
+
StripeProvider.of({
|
|
671
|
+
charge: () =>
|
|
672
|
+
Effect.succeed({
|
|
673
|
+
id: "pi_mock123",
|
|
674
|
+
amount: 1000,
|
|
675
|
+
status: "succeeded",
|
|
676
|
+
}),
|
|
677
|
+
createCheckoutSession: () =>
|
|
678
|
+
Effect.succeed({
|
|
679
|
+
sessionId: "cs_mock123",
|
|
680
|
+
url: "https://checkout.stripe.com/mock",
|
|
681
|
+
}),
|
|
682
|
+
refund: () => Effect.succeed({ refundId: "re_mock123" }),
|
|
683
|
+
createConnectAccount: () =>
|
|
684
|
+
Effect.succeed({ accountId: "acct_mock123" }),
|
|
685
|
+
getPaymentStatus: () =>
|
|
686
|
+
Effect.succeed({ status: "succeeded", amount: 1000 }),
|
|
687
|
+
})
|
|
688
|
+
);
|
|
689
|
+
|
|
690
|
+
// ============================================================================
|
|
691
|
+
// convex/services/providers/blockchain.ts
|
|
692
|
+
// Blockchain Provider - Base L2 token operations
|
|
693
|
+
// ============================================================================
|
|
694
|
+
|
|
695
|
+
import { Effect, Context, Layer } from "effect";
|
|
696
|
+
import { createPublicClient, createWalletClient, http } from "viem";
|
|
697
|
+
import { base } from "viem/chains";
|
|
698
|
+
|
|
699
|
+
// Error Types
|
|
700
|
+
export class BlockchainError {
|
|
701
|
+
readonly _tag = "BlockchainError";
|
|
702
|
+
constructor(readonly message: string) {}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
export class TransactionFailedError {
|
|
706
|
+
readonly _tag = "TransactionFailedError";
|
|
707
|
+
constructor(readonly txHash?: string, readonly reason?: string) {}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// Service Interface
|
|
711
|
+
export class BlockchainProvider extends Context.Tag("BlockchainProvider")<
|
|
712
|
+
BlockchainProvider,
|
|
713
|
+
{
|
|
714
|
+
readonly deployToken: (params: {
|
|
715
|
+
name: string;
|
|
716
|
+
symbol: string;
|
|
717
|
+
totalSupply: number;
|
|
718
|
+
}) => Effect.Effect<
|
|
719
|
+
{ contractAddress: string; txHash: string },
|
|
720
|
+
BlockchainError | TransactionFailedError
|
|
721
|
+
>;
|
|
722
|
+
|
|
723
|
+
readonly mint: (params: {
|
|
724
|
+
contractAddress: string;
|
|
725
|
+
toAddress: string;
|
|
726
|
+
amount: number;
|
|
727
|
+
}) => Effect.Effect<
|
|
728
|
+
{ transactionHash: string },
|
|
729
|
+
BlockchainError | TransactionFailedError
|
|
730
|
+
>;
|
|
731
|
+
|
|
732
|
+
readonly burn: (params: {
|
|
733
|
+
contractAddress: string;
|
|
734
|
+
amount: number;
|
|
735
|
+
}) => Effect.Effect<
|
|
736
|
+
{ transactionHash: string },
|
|
737
|
+
BlockchainError | TransactionFailedError
|
|
738
|
+
>;
|
|
739
|
+
|
|
740
|
+
readonly transfer: (params: {
|
|
741
|
+
contractAddress: string;
|
|
742
|
+
fromAddress: string;
|
|
743
|
+
toAddress: string;
|
|
744
|
+
amount: number;
|
|
745
|
+
}) => Effect.Effect<{ transactionHash: string }, BlockchainError>;
|
|
746
|
+
|
|
747
|
+
readonly getBalance: (params: {
|
|
748
|
+
contractAddress: string;
|
|
749
|
+
address: string;
|
|
750
|
+
}) => Effect.Effect<number, BlockchainError>;
|
|
751
|
+
}
|
|
752
|
+
>() {}
|
|
753
|
+
|
|
754
|
+
// Implementation
|
|
755
|
+
export const BlockchainProviderLive = Layer.effect(
|
|
756
|
+
BlockchainProvider,
|
|
757
|
+
Effect.gen(function* () {
|
|
758
|
+
const privateKey = yield* Effect.sync(
|
|
759
|
+
() => process.env.WALLET_PRIVATE_KEY as `0x${string}`
|
|
760
|
+
);
|
|
761
|
+
|
|
762
|
+
if (!privateKey) {
|
|
763
|
+
return yield* Effect.fail(
|
|
764
|
+
new BlockchainError("WALLET_PRIVATE_KEY not set")
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
const publicClient = createPublicClient({
|
|
769
|
+
chain: base,
|
|
770
|
+
transport: http(),
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
const walletClient = createWalletClient({
|
|
774
|
+
chain: base,
|
|
775
|
+
transport: http(),
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
return BlockchainProvider.of({
|
|
779
|
+
deployToken: (params) =>
|
|
780
|
+
Effect.gen(function* () {
|
|
781
|
+
// Deploy ERC20 contract
|
|
782
|
+
const txHash = yield* Effect.tryPromise({
|
|
783
|
+
try: async () => {
|
|
784
|
+
// Contract deployment logic here
|
|
785
|
+
// This is simplified - real implementation would use contract ABIs
|
|
786
|
+
return "0xmock-deploy-hash";
|
|
787
|
+
},
|
|
788
|
+
catch: (error: any) =>
|
|
789
|
+
new TransactionFailedError(undefined, error.message),
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
// Wait for confirmation
|
|
793
|
+
yield* Effect.sleep("30 seconds");
|
|
794
|
+
|
|
795
|
+
return {
|
|
796
|
+
contractAddress: "0xmock-contract-address",
|
|
797
|
+
txHash,
|
|
798
|
+
};
|
|
799
|
+
}).pipe(
|
|
800
|
+
Effect.retry({ times: 2, delay: "10 seconds" }),
|
|
801
|
+
Effect.timeout("5 minutes")
|
|
802
|
+
),
|
|
803
|
+
|
|
804
|
+
mint: (params) =>
|
|
805
|
+
Effect.gen(function* () {
|
|
806
|
+
const txHash = yield* Effect.tryPromise({
|
|
807
|
+
try: async () => {
|
|
808
|
+
// Mint tokens on contract
|
|
809
|
+
// Simplified - real implementation would call contract
|
|
810
|
+
return "0xmock-mint-hash";
|
|
811
|
+
},
|
|
812
|
+
catch: (error: any) =>
|
|
813
|
+
new TransactionFailedError(undefined, error.message),
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
return { transactionHash: txHash };
|
|
817
|
+
}),
|
|
818
|
+
|
|
819
|
+
burn: (params) =>
|
|
820
|
+
Effect.gen(function* () {
|
|
821
|
+
const txHash = yield* Effect.tryPromise({
|
|
822
|
+
try: async () => {
|
|
823
|
+
// Burn tokens
|
|
824
|
+
return "0xmock-burn-hash";
|
|
825
|
+
},
|
|
826
|
+
catch: (error: any) =>
|
|
827
|
+
new TransactionFailedError(undefined, error.message),
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
return { transactionHash: txHash };
|
|
831
|
+
}),
|
|
832
|
+
|
|
833
|
+
transfer: (params) =>
|
|
834
|
+
Effect.gen(function* () {
|
|
835
|
+
const txHash = yield* Effect.tryPromise({
|
|
836
|
+
try: async () => {
|
|
837
|
+
// Transfer tokens
|
|
838
|
+
return "0xmock-transfer-hash";
|
|
839
|
+
},
|
|
840
|
+
catch: (error: any) => new BlockchainError(error.message),
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
return { transactionHash: txHash };
|
|
844
|
+
}),
|
|
845
|
+
|
|
846
|
+
getBalance: (params) =>
|
|
847
|
+
Effect.gen(function* () {
|
|
848
|
+
const balance = yield* Effect.tryPromise({
|
|
849
|
+
try: async () => {
|
|
850
|
+
// Get balance from contract
|
|
851
|
+
return 1000; // Mock balance
|
|
852
|
+
},
|
|
853
|
+
catch: (error: any) => new BlockchainError(error.message),
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
return balance;
|
|
857
|
+
}),
|
|
858
|
+
});
|
|
859
|
+
})
|
|
860
|
+
);
|
|
861
|
+
|
|
862
|
+
// Mock for Testing
|
|
863
|
+
export const BlockchainProviderTest = Layer.succeed(
|
|
864
|
+
BlockchainProvider,
|
|
865
|
+
BlockchainProvider.of({
|
|
866
|
+
deployToken: () =>
|
|
867
|
+
Effect.succeed({
|
|
868
|
+
contractAddress: "0xmock-contract",
|
|
869
|
+
txHash: "0xmock-deploy",
|
|
870
|
+
}),
|
|
871
|
+
mint: () => Effect.succeed({ transactionHash: "0xmock-mint" }),
|
|
872
|
+
burn: () => Effect.succeed({ transactionHash: "0xmock-burn" }),
|
|
873
|
+
transfer: () => Effect.succeed({ transactionHash: "0xmock-transfer" }),
|
|
874
|
+
getBalance: () => Effect.succeed(1000),
|
|
875
|
+
})
|
|
876
|
+
);
|
|
877
|
+
|
|
878
|
+
// ============================================================================
|
|
879
|
+
// convex/services/providers/resend.ts
|
|
880
|
+
// Resend Provider - Transactional emails
|
|
881
|
+
// ============================================================================
|
|
882
|
+
|
|
883
|
+
import { Effect, Context, Layer } from "effect";
|
|
884
|
+
import { Resend } from "resend";
|
|
885
|
+
|
|
886
|
+
// Error Types
|
|
887
|
+
export class ResendError {
|
|
888
|
+
readonly _tag = "ResendError";
|
|
889
|
+
constructor(readonly message: string) {}
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
export class EmailSendFailedError {
|
|
893
|
+
readonly _tag = "EmailSendFailedError";
|
|
894
|
+
constructor(readonly reason: string) {}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
// Service Interface
|
|
898
|
+
export class ResendProvider extends Context.Tag("ResendProvider")<
|
|
899
|
+
ResendProvider,
|
|
900
|
+
{
|
|
901
|
+
readonly sendVerificationEmail: (params: {
|
|
902
|
+
to: string;
|
|
903
|
+
verificationUrl: string;
|
|
904
|
+
}) => Effect.Effect<{ messageId: string }, ResendError | EmailSendFailedError>;
|
|
905
|
+
|
|
906
|
+
readonly sendPasswordReset: (params: {
|
|
907
|
+
to: string;
|
|
908
|
+
resetUrl: string;
|
|
909
|
+
}) => Effect.Effect<{ messageId: string }, ResendError | EmailSendFailedError>;
|
|
910
|
+
|
|
911
|
+
readonly sendNotification: (params: {
|
|
912
|
+
to: string;
|
|
913
|
+
subject: string;
|
|
914
|
+
body: string;
|
|
915
|
+
}) => Effect.Effect<{ messageId: string }, ResendError | EmailSendFailedError>;
|
|
916
|
+
|
|
917
|
+
readonly sendInsightsReport: (params: {
|
|
918
|
+
to: string;
|
|
919
|
+
insights: any;
|
|
920
|
+
}) => Effect.Effect<{ messageId: string }, ResendError | EmailSendFailedError>;
|
|
921
|
+
}
|
|
922
|
+
>() {}
|
|
923
|
+
|
|
924
|
+
// Implementation
|
|
925
|
+
export const ResendProviderLive = Layer.effect(
|
|
926
|
+
ResendProvider,
|
|
927
|
+
Effect.gen(function* () {
|
|
928
|
+
const apiKey = yield* Effect.sync(() => process.env.RESEND_API_KEY);
|
|
929
|
+
|
|
930
|
+
if (!apiKey) {
|
|
931
|
+
return yield* Effect.fail(new ResendError("RESEND_API_KEY not set"));
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
const resend = new Resend(apiKey);
|
|
935
|
+
const fromEmail = process.env.RESEND_FROM_EMAIL || "noreply@one.ie";
|
|
936
|
+
|
|
937
|
+
return ResendProvider.of({
|
|
938
|
+
sendVerificationEmail: (params) =>
|
|
939
|
+
Effect.gen(function* () {
|
|
940
|
+
const { data, error } = yield* Effect.tryPromise({
|
|
941
|
+
try: () =>
|
|
942
|
+
resend.emails.send({
|
|
943
|
+
from: fromEmail,
|
|
944
|
+
to: params.to,
|
|
945
|
+
subject: "Verify your email",
|
|
946
|
+
html: `
|
|
947
|
+
<h1>Welcome to ONE Platform!</h1>
|
|
948
|
+
<p>Click the link below to verify your email:</p>
|
|
949
|
+
<a href="${params.verificationUrl}">Verify Email</a>
|
|
950
|
+
<p>This link expires in 24 hours.</p>
|
|
951
|
+
`,
|
|
952
|
+
}),
|
|
953
|
+
catch: (error: any) =>
|
|
954
|
+
new EmailSendFailedError(error.message),
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
if (error) {
|
|
958
|
+
return yield* Effect.fail(
|
|
959
|
+
new EmailSendFailedError(error.message)
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
return { messageId: data!.id };
|
|
964
|
+
}),
|
|
965
|
+
|
|
966
|
+
sendPasswordReset: (params) =>
|
|
967
|
+
Effect.gen(function* () {
|
|
968
|
+
const { data, error } = yield* Effect.tryPromise({
|
|
969
|
+
try: () =>
|
|
970
|
+
resend.emails.send({
|
|
971
|
+
from: fromEmail,
|
|
972
|
+
to: params.to,
|
|
973
|
+
subject: "Reset your password",
|
|
974
|
+
html: `
|
|
975
|
+
<h1>Password Reset Request</h1>
|
|
976
|
+
<p>Click the link below to reset your password:</p>
|
|
977
|
+
<a href="${params.resetUrl}">Reset Password</a>
|
|
978
|
+
<p>This link expires in 1 hour.</p>
|
|
979
|
+
<p>If you didn't request this, please ignore this email.</p>
|
|
980
|
+
`,
|
|
981
|
+
}),
|
|
982
|
+
catch: (error: any) =>
|
|
983
|
+
new EmailSendFailedError(error.message),
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
if (error) {
|
|
987
|
+
return yield* Effect.fail(
|
|
988
|
+
new EmailSendFailedError(error.message)
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
return { messageId: data!.id };
|
|
993
|
+
}),
|
|
994
|
+
|
|
995
|
+
sendNotification: (params) =>
|
|
996
|
+
Effect.gen(function* () {
|
|
997
|
+
const { data, error } = yield* Effect.tryPromise({
|
|
998
|
+
try: () =>
|
|
999
|
+
resend.emails.send({
|
|
1000
|
+
from: fromEmail,
|
|
1001
|
+
to: params.to,
|
|
1002
|
+
subject: params.subject,
|
|
1003
|
+
html: params.body,
|
|
1004
|
+
}),
|
|
1005
|
+
catch: (error: any) =>
|
|
1006
|
+
new EmailSendFailedError(error.message),
|
|
1007
|
+
});
|
|
1008
|
+
|
|
1009
|
+
if (error) {
|
|
1010
|
+
return yield* Effect.fail(
|
|
1011
|
+
new EmailSendFailedError(error.message)
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
return { messageId: data!.id };
|
|
1016
|
+
}),
|
|
1017
|
+
|
|
1018
|
+
sendInsightsReport: (params) =>
|
|
1019
|
+
Effect.gen(function* () {
|
|
1020
|
+
const { data, error } = yield* Effect.tryPromise({
|
|
1021
|
+
try: () =>
|
|
1022
|
+
resend.emails.send({
|
|
1023
|
+
from: fromEmail,
|
|
1024
|
+
to: params.to,
|
|
1025
|
+
subject: "Your Business Insights Report",
|
|
1026
|
+
html: `
|
|
1027
|
+
<h1>Your Business Insights</h1>
|
|
1028
|
+
<p>Here's your personalized analysis:</p>
|
|
1029
|
+
<pre>${JSON.stringify(params.insights, null, 2)}</pre>
|
|
1030
|
+
`,
|
|
1031
|
+
}),
|
|
1032
|
+
catch: (error: any) =>
|
|
1033
|
+
new EmailSendFailedError(error.message),
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
if (error) {
|
|
1037
|
+
return yield* Effect.fail(
|
|
1038
|
+
new EmailSendFailedError(error.message)
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
return { messageId: data!.id };
|
|
1043
|
+
}),
|
|
1044
|
+
});
|
|
1045
|
+
})
|
|
1046
|
+
);
|
|
1047
|
+
|
|
1048
|
+
// Mock for Testing
|
|
1049
|
+
export const ResendProviderTest = Layer.succeed(
|
|
1050
|
+
ResendProvider,
|
|
1051
|
+
ResendProvider.of({
|
|
1052
|
+
sendVerificationEmail: () =>
|
|
1053
|
+
Effect.succeed({ messageId: "mock-verify-123" }),
|
|
1054
|
+
sendPasswordReset: () => Effect.succeed({ messageId: "mock-reset-123" }),
|
|
1055
|
+
sendNotification: () => Effect.succeed({ messageId: "mock-notif-123" }),
|
|
1056
|
+
sendInsightsReport: () =>
|
|
1057
|
+
Effect.succeed({ messageId: "mock-insights-123" }),
|
|
1058
|
+
})
|
|
1059
|
+
);
|
|
1060
|
+
|
|
1061
|
+
// ============================================================================
|
|
1062
|
+
// convex/services/index.ts
|
|
1063
|
+
// Main Layer - Combines all providers
|
|
1064
|
+
// ============================================================================
|
|
1065
|
+
|
|
1066
|
+
import { Layer } from "effect";
|
|
1067
|
+
import { OpenAIProviderLive } from "./providers/openai";
|
|
1068
|
+
import { ElevenLabsProviderLive } from "./providers/elevenlabs";
|
|
1069
|
+
import { StripeProviderLive } from "./providers/stripe";
|
|
1070
|
+
import { BlockchainProviderLive } from "./providers/blockchain";
|
|
1071
|
+
import { ResendProviderLive } from "./providers/resend";
|
|
1072
|
+
import { ConvexDatabaseLive } from "./core/database";
|
|
1073
|
+
|
|
1074
|
+
// Production Layer - All real providers
|
|
1075
|
+
export const MainLayer = Layer.mergeAll(
|
|
1076
|
+
OpenAIProviderLive,
|
|
1077
|
+
ElevenLabsProviderLive,
|
|
1078
|
+
StripeProviderLive,
|
|
1079
|
+
BlockchainProviderLive,
|
|
1080
|
+
ResendProviderLive,
|
|
1081
|
+
ConvexDatabaseLive
|
|
1082
|
+
);
|
|
1083
|
+
|
|
1084
|
+
// Test Layer - All mock providers
|
|
1085
|
+
export const TestLayer = Layer.mergeAll(
|
|
1086
|
+
OpenAIProviderTest,
|
|
1087
|
+
ElevenLabsProviderTest,
|
|
1088
|
+
StripeProviderTest,
|
|
1089
|
+
BlockchainProviderTest,
|
|
1090
|
+
ResendProviderTest,
|
|
1091
|
+
ConvexDatabaseTest
|
|
1092
|
+
);
|