oneie 3.6.40 → 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.
Files changed (984) hide show
  1. package/README.md +28 -9
  2. package/dist/admin/build.d.ts +15 -0
  3. package/dist/admin/build.d.ts.map +1 -0
  4. package/dist/admin/build.js +295 -0
  5. package/dist/admin/build.js.map +1 -0
  6. package/dist/admin/index.d.ts +24 -0
  7. package/dist/admin/index.d.ts.map +1 -0
  8. package/dist/admin/index.js +98 -0
  9. package/dist/admin/index.js.map +1 -0
  10. package/dist/admin/list.d.ts +14 -0
  11. package/dist/admin/list.d.ts.map +1 -0
  12. package/dist/admin/list.js +90 -0
  13. package/dist/admin/list.js.map +1 -0
  14. package/dist/admin/manifest.d.ts +86 -0
  15. package/dist/admin/manifest.d.ts.map +1 -0
  16. package/dist/admin/manifest.js +183 -0
  17. package/dist/admin/manifest.js.map +1 -0
  18. package/dist/admin/monorepo.d.ts +25 -0
  19. package/dist/admin/monorepo.d.ts.map +1 -0
  20. package/dist/admin/monorepo.js +59 -0
  21. package/dist/admin/monorepo.js.map +1 -0
  22. package/dist/admin/release.d.ts +17 -0
  23. package/dist/admin/release.d.ts.map +1 -0
  24. package/dist/admin/release.js +144 -0
  25. package/dist/admin/release.js.map +1 -0
  26. package/dist/admin/sync.d.ts +14 -0
  27. package/dist/admin/sync.d.ts.map +1 -0
  28. package/dist/admin/sync.js +104 -0
  29. package/dist/admin/sync.js.map +1 -0
  30. package/dist/admin/validate.d.ts +15 -0
  31. package/dist/admin/validate.d.ts.map +1 -0
  32. package/dist/admin/validate.js +169 -0
  33. package/dist/admin/validate.js.map +1 -0
  34. package/dist/commands/agent.d.ts +2 -0
  35. package/dist/commands/agent.d.ts.map +1 -1
  36. package/dist/commands/agent.js +44 -0
  37. package/dist/commands/agent.js.map +1 -1
  38. package/dist/commands/ask.d.ts +4 -0
  39. package/dist/commands/ask.d.ts.map +1 -0
  40. package/dist/commands/ask.js +8 -0
  41. package/dist/commands/ask.js.map +1 -0
  42. package/dist/commands/bounty.d.ts +4 -0
  43. package/dist/commands/bounty.d.ts.map +1 -0
  44. package/dist/commands/bounty.js +24 -0
  45. package/dist/commands/bounty.js.map +1 -0
  46. package/dist/commands/capabilities.d.ts +4 -0
  47. package/dist/commands/capabilities.d.ts.map +1 -0
  48. package/dist/commands/capabilities.js +18 -0
  49. package/dist/commands/capabilities.js.map +1 -0
  50. package/dist/commands/claw.d.ts +4 -0
  51. package/dist/commands/claw.d.ts.map +1 -0
  52. package/dist/commands/claw.js +14 -0
  53. package/dist/commands/claw.js.map +1 -0
  54. package/dist/commands/commend.d.ts +4 -0
  55. package/dist/commands/commend.d.ts.map +1 -0
  56. package/dist/commands/commend.js +13 -0
  57. package/dist/commands/commend.js.map +1 -0
  58. package/dist/commands/completion.d.ts +4 -0
  59. package/dist/commands/completion.d.ts.map +1 -0
  60. package/dist/commands/completion.js +49 -0
  61. package/dist/commands/completion.js.map +1 -0
  62. package/dist/commands/config.d.ts +4 -0
  63. package/dist/commands/config.d.ts.map +1 -0
  64. package/dist/commands/config.js +78 -0
  65. package/dist/commands/config.js.map +1 -0
  66. package/dist/commands/deploy.d.ts +4 -0
  67. package/dist/commands/deploy.d.ts.map +1 -0
  68. package/dist/commands/deploy.js +10 -0
  69. package/dist/commands/deploy.js.map +1 -0
  70. package/dist/commands/doctor.d.ts +4 -0
  71. package/dist/commands/doctor.d.ts.map +1 -0
  72. package/dist/commands/doctor.js +72 -0
  73. package/dist/commands/doctor.js.map +1 -0
  74. package/dist/commands/export.d.ts +4 -0
  75. package/dist/commands/export.d.ts.map +1 -0
  76. package/dist/commands/export.js +15 -0
  77. package/dist/commands/export.js.map +1 -0
  78. package/dist/commands/fade.d.ts +4 -0
  79. package/dist/commands/fade.d.ts.map +1 -0
  80. package/dist/commands/fade.js +15 -0
  81. package/dist/commands/fade.js.map +1 -0
  82. package/dist/commands/flag.d.ts +4 -0
  83. package/dist/commands/flag.d.ts.map +1 -0
  84. package/dist/commands/flag.js +13 -0
  85. package/dist/commands/flag.js.map +1 -0
  86. package/dist/commands/forget.d.ts +4 -0
  87. package/dist/commands/forget.d.ts.map +1 -0
  88. package/dist/commands/forget.js +16 -0
  89. package/dist/commands/forget.js.map +1 -0
  90. package/dist/commands/frontier.d.ts +4 -0
  91. package/dist/commands/frontier.d.ts.map +1 -0
  92. package/dist/commands/frontier.js +11 -0
  93. package/dist/commands/frontier.js.map +1 -0
  94. package/dist/commands/health.d.ts +4 -0
  95. package/dist/commands/health.d.ts.map +1 -0
  96. package/dist/commands/health.js +11 -0
  97. package/dist/commands/health.js.map +1 -0
  98. package/dist/commands/highways.d.ts +4 -0
  99. package/dist/commands/highways.d.ts.map +1 -0
  100. package/dist/commands/highways.js +14 -0
  101. package/dist/commands/highways.js.map +1 -0
  102. package/dist/commands/hire.d.ts +4 -0
  103. package/dist/commands/hire.d.ts.map +1 -0
  104. package/dist/commands/hire.js +16 -0
  105. package/dist/commands/hire.js.map +1 -0
  106. package/dist/commands/init.d.ts.map +1 -1
  107. package/dist/commands/init.js +69 -42
  108. package/dist/commands/init.js.map +1 -1
  109. package/dist/commands/know.d.ts +4 -0
  110. package/dist/commands/know.d.ts.map +1 -0
  111. package/dist/commands/know.js +8 -0
  112. package/dist/commands/know.js.map +1 -0
  113. package/dist/commands/launch.d.ts +4 -0
  114. package/dist/commands/launch.d.ts.map +1 -0
  115. package/dist/commands/launch.js +16 -0
  116. package/dist/commands/launch.js.map +1 -0
  117. package/dist/commands/mark.d.ts +4 -0
  118. package/dist/commands/mark.d.ts.map +1 -0
  119. package/dist/commands/mark.js +15 -0
  120. package/dist/commands/mark.js.map +1 -0
  121. package/dist/commands/pay.d.ts +4 -0
  122. package/dist/commands/pay.d.ts.map +1 -0
  123. package/dist/commands/pay.js +21 -0
  124. package/dist/commands/pay.js.map +1 -0
  125. package/dist/commands/pipe.d.ts +4 -0
  126. package/dist/commands/pipe.d.ts.map +1 -0
  127. package/dist/commands/pipe.js +35 -0
  128. package/dist/commands/pipe.js.map +1 -0
  129. package/dist/commands/publish.d.ts +4 -0
  130. package/dist/commands/publish.d.ts.map +1 -0
  131. package/dist/commands/publish.js +23 -0
  132. package/dist/commands/publish.js.map +1 -0
  133. package/dist/commands/recall.d.ts +4 -0
  134. package/dist/commands/recall.d.ts.map +1 -0
  135. package/dist/commands/recall.js +12 -0
  136. package/dist/commands/recall.js.map +1 -0
  137. package/dist/commands/repl.d.ts +4 -0
  138. package/dist/commands/repl.d.ts.map +1 -0
  139. package/dist/commands/repl.js +56 -0
  140. package/dist/commands/repl.js.map +1 -0
  141. package/dist/commands/reveal.d.ts +4 -0
  142. package/dist/commands/reveal.d.ts.map +1 -0
  143. package/dist/commands/reveal.js +11 -0
  144. package/dist/commands/reveal.js.map +1 -0
  145. package/dist/commands/revenue.d.ts +4 -0
  146. package/dist/commands/revenue.d.ts.map +1 -0
  147. package/dist/commands/revenue.js +11 -0
  148. package/dist/commands/revenue.js.map +1 -0
  149. package/dist/commands/select.d.ts +4 -0
  150. package/dist/commands/select.d.ts.map +1 -0
  151. package/dist/commands/select.js +19 -0
  152. package/dist/commands/select.js.map +1 -0
  153. package/dist/commands/signal.d.ts +4 -0
  154. package/dist/commands/signal.d.ts.map +1 -0
  155. package/dist/commands/signal.js +8 -0
  156. package/dist/commands/signal.js.map +1 -0
  157. package/dist/commands/stats.d.ts +4 -0
  158. package/dist/commands/stats.d.ts.map +1 -0
  159. package/dist/commands/stats.js +11 -0
  160. package/dist/commands/stats.js.map +1 -0
  161. package/dist/commands/status.d.ts +4 -0
  162. package/dist/commands/status.d.ts.map +1 -0
  163. package/dist/commands/status.js +18 -0
  164. package/dist/commands/status.js.map +1 -0
  165. package/dist/commands/sync.d.ts +4 -0
  166. package/dist/commands/sync.d.ts.map +1 -0
  167. package/dist/commands/sync.js +20 -0
  168. package/dist/commands/sync.js.map +1 -0
  169. package/dist/commands/tail.d.ts +4 -0
  170. package/dist/commands/tail.d.ts.map +1 -0
  171. package/dist/commands/tail.js +51 -0
  172. package/dist/commands/tail.js.map +1 -0
  173. package/dist/commands/warn.d.ts +4 -0
  174. package/dist/commands/warn.d.ts.map +1 -0
  175. package/dist/commands/warn.js +15 -0
  176. package/dist/commands/warn.js.map +1 -0
  177. package/dist/create-org-profile.js +2 -2
  178. package/dist/create-user-profile.js +2 -2
  179. package/dist/index.js +135 -7
  180. package/dist/index.js.map +1 -1
  181. package/dist/lib/args.d.ts +11 -0
  182. package/dist/lib/args.d.ts.map +1 -0
  183. package/dist/lib/args.js +57 -0
  184. package/dist/lib/args.js.map +1 -0
  185. package/dist/lib/config.d.ts +12 -0
  186. package/dist/lib/config.d.ts.map +1 -0
  187. package/dist/lib/config.js +38 -0
  188. package/dist/lib/config.js.map +1 -0
  189. package/dist/lib/http.d.ts +9 -0
  190. package/dist/lib/http.d.ts.map +1 -0
  191. package/dist/lib/http.js +25 -0
  192. package/dist/lib/http.js.map +1 -0
  193. package/dist/lib/output.d.ts +5 -0
  194. package/dist/lib/output.d.ts.map +1 -0
  195. package/dist/lib/output.js +32 -0
  196. package/dist/lib/output.js.map +1 -0
  197. package/dist/lib/sdk.d.ts +10 -0
  198. package/dist/lib/sdk.d.ts.map +1 -0
  199. package/dist/lib/sdk.js +22 -0
  200. package/dist/lib/sdk.js.map +1 -0
  201. package/dist/lib/telemetry.d.ts +4 -0
  202. package/dist/lib/telemetry.d.ts.map +1 -0
  203. package/dist/lib/telemetry.js +61 -0
  204. package/dist/lib/telemetry.js.map +1 -0
  205. package/dist/utils/file-resolver.js +1 -3
  206. package/dist/utils/file-resolver.js.map +1 -1
  207. package/dist/utils/installation-setup.d.ts +15 -0
  208. package/dist/utils/installation-setup.d.ts.map +1 -1
  209. package/dist/utils/installation-setup.js +71 -8
  210. package/dist/utils/installation-setup.js.map +1 -1
  211. package/package.json +5 -21
  212. package/.claude/agents/TROUBLESHOOTING.md +0 -530
  213. package/.claude/agents/agent-backend.md +0 -574
  214. package/.claude/agents/agent-builder.md +0 -911
  215. package/.claude/agents/agent-claude.md +0 -645
  216. package/.claude/agents/agent-clean.md +0 -477
  217. package/.claude/agents/agent-clone.md +0 -554
  218. package/.claude/agents/agent-designer.md +0 -1080
  219. package/.claude/agents/agent-director.md +0 -2254
  220. package/.claude/agents/agent-documenter.md +0 -688
  221. package/.claude/agents/agent-frontend.md +0 -1199
  222. package/.claude/agents/agent-integrator.md +0 -670
  223. package/.claude/agents/agent-lawyer.md +0 -1320
  224. package/.claude/agents/agent-news.md +0 -363
  225. package/.claude/agents/agent-onboard.md +0 -613
  226. package/.claude/agents/agent-ontology.md +0 -585
  227. package/.claude/agents/agent-ops.md +0 -1275
  228. package/.claude/agents/agent-problem-solver.md +0 -669
  229. package/.claude/agents/agent-quality.md +0 -1042
  230. package/.claude/agents/agent-sales.md +0 -507
  231. package/.claude/agents/agent-writer.md +0 -1068
  232. package/.claude/commands/cascade.md +0 -742
  233. package/.claude/commands/chat.md +0 -728
  234. package/.claude/commands/commit.md +0 -95
  235. package/.claude/commands/create.md +0 -544
  236. package/.claude/commands/deploy.md +0 -309
  237. package/.claude/commands/fast.md +0 -636
  238. package/.claude/commands/mcp-on.md +0 -191
  239. package/.claude/commands/media-upload.md +0 -186
  240. package/.claude/commands/news.md +0 -274
  241. package/.claude/commands/onboard.md +0 -440
  242. package/.claude/commands/one.md +0 -398
  243. package/.claude/commands/optimize.md +0 -74
  244. package/.claude/commands/plan.md +0 -719
  245. package/.claude/commands/push.md +0 -214
  246. package/.claude/commands/release.md +0 -105
  247. package/.claude/commands/review.md +0 -99
  248. package/.claude/commands/server.md +0 -487
  249. package/.claude/commands/start.md +0 -227
  250. package/.claude/commands/test.md +0 -197
  251. package/.claude/commands/validate.md +0 -140
  252. package/.claude/hooks/.last-news-context +0 -1
  253. package/.claude/hooks/PULL-BEFORE-PUSH-GUIDE.md +0 -473
  254. package/.claude/hooks/README-knowledge-hooks.md +0 -451
  255. package/.claude/hooks/README-news-generation.md +0 -364
  256. package/.claude/hooks/README-root-cleanup.md +0 -200
  257. package/.claude/hooks/README.md +0 -284
  258. package/.claude/hooks/__pycache__/todo.cpython-312.pyc +0 -0
  259. package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
  260. package/.claude/hooks/auto-format.sh +0 -106
  261. package/.claude/hooks/check-filenames.py +0 -177
  262. package/.claude/hooks/clean-post.py +0 -468
  263. package/.claude/hooks/clean-pre.py +0 -393
  264. package/.claude/hooks/clean-root-markdown.sh +0 -73
  265. package/.claude/hooks/commit-push.sh +0 -95
  266. package/.claude/hooks/done.py +0 -236
  267. package/.claude/hooks/format-hook.sh +0 -163
  268. package/.claude/hooks/formatting.py +0 -187
  269. package/.claude/hooks/hook-logger.sh +0 -173
  270. package/.claude/hooks/knowledge-post.py +0 -355
  271. package/.claude/hooks/knowledge-pre.py +0 -245
  272. package/.claude/hooks/mcp-on.sh +0 -134
  273. package/.claude/hooks/notification-hook.sh +0 -279
  274. package/.claude/hooks/ontology-validation.py +0 -255
  275. package/.claude/hooks/push.sh +0 -153
  276. package/.claude/hooks/release-cli.sh +0 -205
  277. package/.claude/hooks/root-cleanup.py +0 -217
  278. package/.claude/hooks/security-hook.sh +0 -397
  279. package/.claude/hooks/tag-all-docs.py +0 -464
  280. package/.claude/hooks/test-validate-ontology.sh +0 -170
  281. package/.claude/hooks/todo.py +0 -368
  282. package/.claude/hooks/track-changes.sh +0 -101
  283. package/.claude/hooks/validate-imports.py +0 -182
  284. package/.claude/hooks/validate-ontology-structure-summary.md +0 -243
  285. package/.claude/hooks/validate-ontology-structure.py +0 -558
  286. package/.claude/hooks/validate-ontology-structure.py.backup +0 -518
  287. package/.claude/hooks/validate-ontology.py +0 -140
  288. package/.claude/hooks/write-news.sh +0 -194
  289. package/.claude/skills/INDEX.md +0 -523
  290. package/.claude/skills/REGISTRY.md +0 -529
  291. package/.claude/skills/agent-backend-create-mutation.md +0 -319
  292. package/.claude/skills/agent-designer-create-wireframe.md +0 -341
  293. package/.claude/skills/agent-frontend-create-page.md +0 -413
  294. package/.claude/skills/agents/README.md +0 -238
  295. package/.claude/skills/astro/add-content-collection.md +0 -30
  296. package/.claude/skills/astro/check-build.md +0 -29
  297. package/.claude/skills/astro/create-component.md +0 -29
  298. package/.claude/skills/astro/create-page.md +0 -30
  299. package/.claude/skills/astro/optimize-performance.md +0 -21
  300. package/.claude/skills/convex/check-deployment.md +0 -46
  301. package/.claude/skills/convex/create-mutation.md +0 -405
  302. package/.claude/skills/convex/create-query.md +0 -52
  303. package/.claude/skills/convex/read-schema.md +0 -373
  304. package/.claude/skills/convex/test-function.md +0 -50
  305. package/.claude/skills/deployment/check-deployment-health.md +0 -20
  306. package/.claude/skills/deployment/create-release.md +0 -21
  307. package/.claude/skills/deployment/deploy-cloudflare.md +0 -31
  308. package/.claude/skills/deployment/deploy-convex.md +0 -30
  309. package/.claude/skills/deployment/sync-repositories.md +0 -19
  310. package/.claude/skills/design/check-accessibility.md +0 -21
  311. package/.claude/skills/design/create-component-spec.md +0 -27
  312. package/.claude/skills/design/generate-design-tokens.md +0 -24
  313. package/.claude/skills/design/generate-wireframe.md +0 -30
  314. package/.claude/skills/documentation/create-migration-guide.md +0 -20
  315. package/.claude/skills/documentation/generate-api-docs.md +0 -27
  316. package/.claude/skills/documentation/generate-readme.md +0 -22
  317. package/.claude/skills/documentation/update-knowledge.md +0 -20
  318. package/.claude/skills/integration/connect-external-system.md +0 -21
  319. package/.claude/skills/integration/implement-a2a.md +0 -20
  320. package/.claude/skills/integration/implement-acp.md +0 -20
  321. package/.claude/skills/integration/verify-integration.md +0 -20
  322. package/.claude/skills/ontology/README.md +0 -255
  323. package/.claude/skills/ontology/check-dimension.md +0 -307
  324. package/.claude/skills/ontology/generate-entity-type.md +0 -339
  325. package/.claude/skills/ontology/validate-schema.md +0 -229
  326. package/.claude/skills/ontology/verify-relationships.md +0 -310
  327. package/.claude/skills/problem-solving/analyze-test-failure.md +0 -21
  328. package/.claude/skills/problem-solving/identify-root-cause.md +0 -20
  329. package/.claude/skills/problem-solving/propose-solution.md +0 -29
  330. package/.claude/skills/problem-solving/verify-fix.md +0 -21
  331. package/.claude/skills/sales/generate-demo-script.md +0 -21
  332. package/.claude/skills/sales/qualify-lead.md +0 -30
  333. package/.claude/skills/sales/track-trial.md +0 -20
  334. package/.claude/skills/sales/verify-kyc.md +0 -20
  335. package/.claude/skills/testing/analyze-coverage.md +0 -24
  336. package/.claude/skills/testing/generate-tests.md +0 -24
  337. package/.claude/skills/testing/run-tests.md +0 -27
  338. package/.claude/skills/testing/validate-e2e.md +0 -25
  339. package/AGENTS.md +0 -60
  340. package/CLAUDE.md +0 -321
  341. package/CREATE-WEBSITE.md +0 -458
  342. package/SECURITY.md +0 -31
  343. package/dist/commands/create-website.d.ts +0 -19
  344. package/dist/commands/create-website.d.ts.map +0 -1
  345. package/dist/commands/create-website.js +0 -231
  346. package/dist/commands/create-website.js.map +0 -1
  347. package/folders.yaml +0 -92
  348. package/one/README.md +0 -760
  349. package/one/connections/a2a.md +0 -600
  350. package/one/connections/acp.md +0 -808
  351. package/one/connections/acps.md +0 -749
  352. package/one/connections/agentkit.md +0 -367
  353. package/one/connections/agui.md +0 -785
  354. package/one/connections/any-backend.md +0 -1720
  355. package/one/connections/ap2.md +0 -1072
  356. package/one/connections/api/queries-reference.md +0 -860
  357. package/one/connections/api-docs.md +0 -1909
  358. package/one/connections/api-reference.md +0 -1029
  359. package/one/connections/api.md +0 -2208
  360. package/one/connections/architecture-diagram.md +0 -112
  361. package/one/connections/communications.md +0 -467
  362. package/one/connections/connections.md +0 -357
  363. package/one/connections/copilotkit.md +0 -1577
  364. package/one/connections/cryptonetworks.md +0 -799
  365. package/one/connections/documentation.md +0 -1138
  366. package/one/connections/effect.md +0 -297
  367. package/one/connections/elizaos.md +0 -1308
  368. package/one/connections/groups.md +0 -814
  369. package/one/connections/inference.md +0 -76
  370. package/one/connections/integration-examples.md +0 -893
  371. package/one/connections/integration-guide.md +0 -887
  372. package/one/connections/integration-phase2.md +0 -754
  373. package/one/connections/kyc.md +0 -650
  374. package/one/connections/mcp.md +0 -860
  375. package/one/connections/membership.md +0 -1170
  376. package/one/connections/middleware.md +0 -1085
  377. package/one/connections/multitenant.md +0 -1359
  378. package/one/connections/n8n.md +0 -1033
  379. package/one/connections/patterns.md +0 -107
  380. package/one/connections/protocols.md +0 -297
  381. package/one/connections/relationships.md +0 -125
  382. package/one/connections/schema.md +0 -605
  383. package/one/connections/service-layer.md +0 -568
  384. package/one/connections/vectors.md +0 -225
  385. package/one/connections/wordpress.md +0 -1320
  386. package/one/connections/workflow-copy.md +0 -923
  387. package/one/connections/workflow-examples.md +0 -759
  388. package/one/connections/workflow-onboarding.md +0 -701
  389. package/one/connections/workflow.md +0 -923
  390. package/one/connections/workflows/delegation.md +0 -903
  391. package/one/connections/workflows/frontend.md +0 -1055
  392. package/one/connections/workflows/strategy.md +0 -921
  393. package/one/connections/workflows/tasks.md +0 -716
  394. package/one/connections/x402-baazar.md +0 -131
  395. package/one/connections/x402.md +0 -1353
  396. package/one/groups/features.md +0 -2904
  397. package/one/groups/groups.md +0 -587
  398. package/one/groups/one.md +0 -619
  399. package/one/groups/strategy-copy.md +0 -887
  400. package/one/knowledge/.obsidian/app.json +0 -1
  401. package/one/knowledge/.obsidian/appearance.json +0 -1
  402. package/one/knowledge/.obsidian/core-plugins.json +0 -33
  403. package/one/knowledge/.obsidian/ecommerce-ontology.md +0 -210
  404. package/one/knowledge/.obsidian/workspace.json +0 -211
  405. package/one/knowledge/100-inference-quick-reference.md +0 -449
  406. package/one/knowledge/ag-ui-protocol.md +0 -613
  407. package/one/knowledge/agent-onboard-usage.md +0 -630
  408. package/one/knowledge/agentic-commerce.md +0 -146
  409. package/one/knowledge/ai-agents-vs-memecoins-thesis.md +0 -683
  410. package/one/knowledge/ai-api-reference.md +0 -715
  411. package/one/knowledge/ai-platform.md +0 -323
  412. package/one/knowledge/ai-quickstart.md +0 -355
  413. package/one/knowledge/ai-sdk-implementation.md +0 -436
  414. package/one/knowledge/ai-token-crypto-analysis-framework.md +0 -1191
  415. package/one/knowledge/ai-token-paradigm-shift-2025.md +0 -732
  416. package/one/knowledge/altcoin-cycle-prediction-ontology.md +0 -884
  417. package/one/knowledge/altcoin-cycle-trading-strategy.md +0 -642
  418. package/one/knowledge/architecture-any-backend.md +0 -1589
  419. package/one/knowledge/architecture-diagram.md +0 -404
  420. package/one/knowledge/architecture-frontend.md +0 -1014
  421. package/one/knowledge/architecture.md +0 -1742
  422. package/one/knowledge/archived/ontology.old.md +0 -2840
  423. package/one/knowledge/astro-effect-complete-vision.md +0 -2148
  424. package/one/knowledge/astro-effect-simple-architecture.md +0 -750
  425. package/one/knowledge/audit-agent-onboard-alignment.md +0 -481
  426. package/one/knowledge/audit-agent-sales-alignment.md +0 -444
  427. package/one/knowledge/backend-api-reference.md +0 -728
  428. package/one/knowledge/cascading-context-specification.md +0 -1617
  429. package/one/knowledge/claude-code-integration.md +0 -1293
  430. package/one/knowledge/cli-claude-handoff.md +0 -736
  431. package/one/knowledge/context-engineering.md +0 -610
  432. package/one/knowledge/crypto-analysis-strategy.md +0 -1276
  433. package/one/knowledge/crypto-cycle-2024-2025-analysis.md +0 -44
  434. package/one/knowledge/crypto.md +0 -978
  435. package/one/knowledge/develop/design.md +0 -364
  436. package/one/knowledge/develop/index.md +0 -145
  437. package/one/knowledge/development-commands.md +0 -251
  438. package/one/knowledge/docs.md +0 -627
  439. package/one/knowledge/dsl.md +0 -1678
  440. package/one/knowledge/event-driven-documentation.md +0 -270
  441. package/one/knowledge/files.md +0 -2489
  442. package/one/knowledge/frontend.md +0 -1056
  443. package/one/knowledge/games-english.md +0 -691
  444. package/one/knowledge/games.md +0 -1082
  445. package/one/knowledge/generative-ui-patterns.md +0 -559
  446. package/one/knowledge/guidelines.md +0 -314
  447. package/one/knowledge/hono.md +0 -2127
  448. package/one/knowledge/implementation-examples.md +0 -2554
  449. package/one/knowledge/installation-folders.md +0 -366
  450. package/one/knowledge/institutional-cycle-paradigm-2025.md +0 -555
  451. package/one/knowledge/knowledge.md +0 -660
  452. package/one/knowledge/language.md +0 -998
  453. package/one/knowledge/lessons-learned.md +0 -378
  454. package/one/knowledge/lessons-website-building-focus.md +0 -382
  455. package/one/knowledge/merge-report.md +0 -254
  456. package/one/knowledge/metadata-system.md +0 -504
  457. package/one/knowledge/nine-padel-playbook.md +0 -229
  458. package/one/knowledge/one-protocol-ai-agents.md +0 -892
  459. package/one/knowledge/one-protocol-executive-report.md +0 -617
  460. package/one/knowledge/one-protocol-standard.md +0 -869
  461. package/one/knowledge/one-protocol-whitepaper.md +0 -756
  462. package/one/knowledge/ontology-blog.yaml +0 -47
  463. package/one/knowledge/ontology-cheatsheet.md +0 -617
  464. package/one/knowledge/ontology-community.yaml +0 -65
  465. package/one/knowledge/ontology-core-universal.md +0 -740
  466. package/one/knowledge/ontology-core.yaml +0 -63
  467. package/one/knowledge/ontology-courses.yaml +0 -76
  468. package/one/knowledge/ontology-creator.md +0 -402
  469. package/one/knowledge/ontology-crypto.md +0 -1603
  470. package/one/knowledge/ontology-developer-guide.md +0 -814
  471. package/one/knowledge/ontology-documentation.md +0 -377
  472. package/one/knowledge/ontology-ecommerce.md +0 -269
  473. package/one/knowledge/ontology-education-game.md +0 -1654
  474. package/one/knowledge/ontology-education.md +0 -938
  475. package/one/knowledge/ontology-engineering-specification.md +0 -1310
  476. package/one/knowledge/ontology-engineering.md +0 -1676
  477. package/one/knowledge/ontology-files.yaml +0 -525
  478. package/one/knowledge/ontology-frontend-master.md +0 -2898
  479. package/one/knowledge/ontology-frontend-specifications.md +0 -2196
  480. package/one/knowledge/ontology-frontend.md +0 -2475
  481. package/one/knowledge/ontology-index.md +0 -397
  482. package/one/knowledge/ontology-minimal.yaml +0 -301
  483. package/one/knowledge/ontology-portfolio.yaml +0 -45
  484. package/one/knowledge/ontology-quickstart.md +0 -602
  485. package/one/knowledge/ontology-release.md +0 -317
  486. package/one/knowledge/ontology-shop.yaml +0 -148
  487. package/one/knowledge/ontology-tokens.yaml +0 -51
  488. package/one/knowledge/ontology-tutorial.md +0 -455
  489. package/one/knowledge/ontology-v2.md +0 -4449
  490. package/one/knowledge/ontology-video-script.md +0 -939
  491. package/one/knowledge/ontology-visual-guide.md +0 -378
  492. package/one/knowledge/ontology.md +0 -3847
  493. package/one/knowledge/ontology.yaml +0 -1653
  494. package/one/knowledge/parallel-agents.md +0 -932
  495. package/one/knowledge/patterns/backend/convex-mutation-pattern.md +0 -130
  496. package/one/knowledge/patterns/backend/convex-query-pattern.md +0 -143
  497. package/one/knowledge/patterns/backend/mutation-template.md +0 -249
  498. package/one/knowledge/patterns/backend/query-template.md +0 -286
  499. package/one/knowledge/patterns/backend/service-template.md +0 -258
  500. package/one/knowledge/patterns/design/component-architecture.md +0 -435
  501. package/one/knowledge/patterns/design/index.md +0 -160
  502. package/one/knowledge/patterns/design/test-driven-design-pattern.md +0 -196
  503. package/one/knowledge/patterns/design/wireframe-template.md +0 -250
  504. package/one/knowledge/patterns/frontend/component-template.md +0 -246
  505. package/one/knowledge/patterns/frontend/form-template.md +0 -348
  506. package/one/knowledge/patterns/frontend/page-template.md +0 -209
  507. package/one/knowledge/patterns/frontend/react-component-pattern.md +0 -188
  508. package/one/knowledge/patterns/test/acceptance-criteria-template.md +0 -396
  509. package/one/knowledge/patterns/test/technical-test-template.md +0 -566
  510. package/one/knowledge/patterns/test/test-driven-pattern.md +0 -160
  511. package/one/knowledge/patterns/test/user-flow-template.md +0 -272
  512. package/one/knowledge/performance.md +0 -459
  513. package/one/knowledge/provider-agnostic-content.md +0 -995
  514. package/one/knowledge/provider-creation-guide.md +0 -1082
  515. package/one/knowledge/quality-loop.md +0 -419
  516. package/one/knowledge/quick-start-ontology-mapping.md +0 -773
  517. package/one/knowledge/readme-architecture.md +0 -158
  518. package/one/knowledge/readme.md +0 -149
  519. package/one/knowledge/rules.md +0 -644
  520. package/one/knowledge/score.md +0 -85
  521. package/one/knowledge/specifications.md +0 -873
  522. package/one/knowledge/tags.md +0 -148
  523. package/one/knowledge/todo-template.md +0 -269
  524. package/one/knowledge/todo.md +0 -269
  525. package/one/knowledge/troubleshooting.md +0 -434
  526. package/one/knowledge/typescript-patterns.md +0 -321
  527. package/one/knowledge/universal-generation-language.md +0 -827
  528. package/one/knowledge/x402-research.md +0 -104
  529. package/one/license.md +0 -107
  530. package/one/people/anthony-o-connell.md +0 -469
  531. package/one/people/people.md +0 -590
  532. package/one/things/ALIGNMENT_AUDIT_QUALITY_AGENT.md +0 -401
  533. package/one/things/AUDIT_AGENT_INTEGRATOR_ALIGNMENT.md +0 -588
  534. package/one/things/AUDIT_REPORT_AGENT_CLEAN.md +0 -461
  535. package/one/things/CHECKLIST.md +0 -407
  536. package/one/things/IMPLEMENTATION_STATUS.md +0 -379
  537. package/one/things/ONE.md +0 -529
  538. package/one/things/agents/agent-backend.md +0 -1501
  539. package/one/things/agents/agent-builder.md +0 -1064
  540. package/one/things/agents/agent-clean.md +0 -1112
  541. package/one/things/agents/agent-clone.md +0 -1324
  542. package/one/things/agents/agent-deploy.md +0 -986
  543. package/one/things/agents/agent-designer.md +0 -2305
  544. package/one/things/agents/agent-director.md +0 -1526
  545. package/one/things/agents/agent-documenter.md +0 -1129
  546. package/one/things/agents/agent-frontend.md +0 -1201
  547. package/one/things/agents/agent-integrator.md +0 -1269
  548. package/one/things/agents/agent-lawyer.md +0 -1371
  549. package/one/things/agents/agent-problem-solver.md +0 -1457
  550. package/one/things/agents/agent-quality.md +0 -1483
  551. package/one/things/agents/agent-sales.md +0 -1074
  552. package/one/things/cascade/cascade.yaml +0 -481
  553. package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +0 -523
  554. package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +0 -314
  555. package/one/things/cascade/docs/examples/1-1-agent-prompts.md +0 -562
  556. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +0 -543
  557. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +0 -272
  558. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +0 -548
  559. package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +0 -586
  560. package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +0 -267
  561. package/one/things/cascade/docs/examples/1-3-event-coordination.md +0 -547
  562. package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +0 -665
  563. package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +0 -236
  564. package/one/things/cascade/docs/examples/1-4-knowledge-management.md +0 -652
  565. package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +0 -860
  566. package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +0 -255
  567. package/one/things/cascade/docs/examples/1-5-quality-loops.md +0 -725
  568. package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +0 -659
  569. package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +0 -256
  570. package/one/things/cascade/docs/examples/1-6-numbering-structure.md +0 -639
  571. package/one/things/cascade/docs/examples/readme.md +0 -259
  572. package/one/things/cascade/docs/getting-started.md +0 -533
  573. package/one/things/cascade/docs/workflow.md +0 -1378
  574. package/one/things/cascade/readme.md +0 -379
  575. package/one/things/cascade/templates/feature-template.md +0 -289
  576. package/one/things/claude/agents/advocacy-activation-manager.md +0 -710
  577. package/one/things/claude/agents/advocacy-campaign-designer.md +0 -688
  578. package/one/things/claude/agents/analyst.md +0 -508
  579. package/one/things/claude/agents/architect.md +0 -505
  580. package/one/things/claude/agents/brand-identity-specialist.md +0 -538
  581. package/one/things/claude/agents/bstp-token-strategist.md +0 -690
  582. package/one/things/claude/agents/builder-repo.md +0 -532
  583. package/one/things/claude/agents/bullstamp-community-builder.md +0 -597
  584. package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +0 -529
  585. package/one/things/claude/agents/bulltilt-platform-growth.md +0 -590
  586. package/one/things/claude/agents/company-bullstamp-character.md +0 -602
  587. package/one/things/claude/agents/company-bullstamp-community.md +0 -307
  588. package/one/things/claude/agents/company-bullstamp-marketing.md +0 -307
  589. package/one/things/claude/agents/company-bullstamp-token.md +0 -307
  590. package/one/things/claude/agents/company-bulltilt-growth.md +0 -307
  591. package/one/things/claude/agents/content-bibliography-formatter.md +0 -404
  592. package/one/things/claude/agents/content-calendar-planner.md +0 -473
  593. package/one/things/claude/agents/content-chapter-formatter.md +0 -513
  594. package/one/things/claude/agents/content-formatter.md +0 -571
  595. package/one/things/claude/agents/content-hook-specialist.md +0 -485
  596. package/one/things/claude/agents/content-image-formatter.md +0 -560
  597. package/one/things/claude/agents/content-introduction-formatter.md +0 -510
  598. package/one/things/claude/agents/content-multiplication-engine.md +0 -579
  599. package/one/things/claude/agents/content-playbook-writer.md +0 -473
  600. package/one/things/claude/agents/content-team-manager.md +0 -647
  601. package/one/things/claude/agents/content-toc-formatter.md +0 -547
  602. package/one/things/claude/agents/convex-backend-specialist.md +0 -2725
  603. package/one/things/claude/agents/core-manager.md +0 -607
  604. package/one/things/claude/agents/core-master.md +0 -426
  605. package/one/things/claude/agents/cross-functional-manager.md +0 -476
  606. package/one/things/claude/agents/crypto-airdrop-strategist.md +0 -622
  607. package/one/things/claude/agents/crypto-analytics-educator.md +0 -596
  608. package/one/things/claude/agents/crypto-architecture-specialist.md +0 -497
  609. package/one/things/claude/agents/crypto-community-analyst.md +0 -314
  610. package/one/things/claude/agents/crypto-community-psychologist.md +0 -546
  611. package/one/things/claude/agents/crypto-dex-optimization-expert.md +0 -579
  612. package/one/things/claude/agents/crypto-dex-optimizer.md +0 -307
  613. package/one/things/claude/agents/crypto-diamond-formation-specialist.md +0 -552
  614. package/one/things/claude/agents/crypto-diamond-hands.md +0 -307
  615. package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +0 -597
  616. package/one/things/claude/agents/crypto-engagement-specialist.md +0 -581
  617. package/one/things/claude/agents/crypto-market-researcher.md +0 -307
  618. package/one/things/claude/agents/crypto-marketing-orchestrator.md +0 -563
  619. package/one/things/claude/agents/crypto-network-effect-amplifier.md +0 -614
  620. package/one/things/claude/agents/crypto-optimization-analyst.md +0 -597
  621. package/one/things/claude/agents/crypto-strategic-synthesizer.md +0 -556
  622. package/one/things/claude/agents/crypto-team-manager.md +0 -392
  623. package/one/things/claude/agents/crypto-token-analyst.md +0 -319
  624. package/one/things/claude/agents/crypto-viral-content-creator.md +0 -549
  625. package/one/things/claude/agents/crypto-wallet-identification-expert.md +0 -527
  626. package/one/things/claude/agents/crypto-wallet-identifier.md +0 -307
  627. package/one/things/claude/agents/customer-journey-designer.md +0 -474
  628. package/one/things/claude/agents/customer-success-manager.md +0 -574
  629. package/one/things/claude/agents/dev.md +0 -406
  630. package/one/things/claude/agents/documenter.md +0 -548
  631. package/one/things/claude/agents/elevate-marketing-orchestrator.md +0 -403
  632. package/one/things/claude/agents/engagement-specialist.md +0 -502
  633. package/one/things/claude/agents/engineering-architect.md +0 -387
  634. package/one/things/claude/agents/engineering-business-analyst.md +0 -527
  635. package/one/things/claude/agents/engineering-developer.md +0 -386
  636. package/one/things/claude/agents/engineering-director.md +0 -322
  637. package/one/things/claude/agents/engineering-ingestor.md +0 -659
  638. package/one/things/claude/agents/engineering-product-manager.md +0 -525
  639. package/one/things/claude/agents/engineering-product-owner.md +0 -527
  640. package/one/things/claude/agents/engineering-project-coordinator.md +0 -525
  641. package/one/things/claude/agents/engineering-quality-assurance.md +0 -392
  642. package/one/things/claude/agents/engineering-team-manager.md +0 -515
  643. package/one/things/claude/agents/engineering-user-experience.md +0 -386
  644. package/one/things/claude/agents/framework-elevate-manager.md +0 -309
  645. package/one/things/claude/agents/improver.md +0 -805
  646. package/one/things/claude/agents/intelligence-team-manager.md +0 -390
  647. package/one/things/claude/agents/lead-capture-expert.md +0 -459
  648. package/one/things/claude/agents/lead-magnet-creator.md +0 -446
  649. package/one/things/claude/agents/market-research-analyst.md +0 -435
  650. package/one/things/claude/agents/marketing-brand-identity.md +0 -344
  651. package/one/things/claude/agents/marketing-content-hooks.md +0 -455
  652. package/one/things/claude/agents/marketing-content-multiplier.md +0 -331
  653. package/one/things/claude/agents/marketing-content-poster.md +0 -372
  654. package/one/things/claude/agents/marketing-customer-journey.md +0 -331
  655. package/one/things/claude/agents/marketing-director.md +0 -402
  656. package/one/things/claude/agents/marketing-engagement.md +0 -331
  657. package/one/things/claude/agents/marketing-lead-capture.md +0 -331
  658. package/one/things/claude/agents/marketing-lead-magnet.md +0 -331
  659. package/one/things/claude/agents/marketing-network-effects.md +0 -331
  660. package/one/things/claude/agents/marketing-nurture-campaigns.md +0 -331
  661. package/one/things/claude/agents/marketing-share-optimizer.md +0 -331
  662. package/one/things/claude/agents/marketing-team-manager.md +0 -451
  663. package/one/things/claude/agents/marketing-viral-growth.md +0 -232
  664. package/one/things/claude/agents/mission-commander.md +0 -378
  665. package/one/things/claude/agents/network-effect-analyst.md +0 -604
  666. package/one/things/claude/agents/nextjs-15-specialist.md +0 -1634
  667. package/one/things/claude/agents/npx.md +0 -946
  668. package/one/things/claude/agents/nurture-campaign-manager.md +0 -554
  669. package/one/things/claude/agents/one-master.md +0 -378
  670. package/one/things/claude/agents/one-orchestrator.md +0 -345
  671. package/one/things/claude/agents/one.md +0 -658
  672. package/one/things/claude/agents/playbook-generator.md +0 -526
  673. package/one/things/claude/agents/pm.md +0 -349
  674. package/one/things/claude/agents/po.md +0 -370
  675. package/one/things/claude/agents/qa.md +0 -361
  676. package/one/things/claude/agents/research-foundation-analyst.md +0 -324
  677. package/one/things/claude/agents/research-intelligence-gatherer.md +0 -435
  678. package/one/things/claude/agents/research-market-analyst.md +0 -324
  679. package/one/things/claude/agents/research-team-manager.md +0 -489
  680. package/one/things/claude/agents/sales-environment-optimizer.md +0 -519
  681. package/one/things/claude/agents/sales-team-manager.md +0 -407
  682. package/one/things/claude/agents/sales-upsell-strategist.md +0 -324
  683. package/one/things/claude/agents/service-advocacy-campaigns.md +0 -324
  684. package/one/things/claude/agents/service-advocacy-manager.md +0 -324
  685. package/one/things/claude/agents/service-success-manager.md +0 -324
  686. package/one/things/claude/agents/service-team-manager.md +0 -405
  687. package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +0 -2357
  688. package/one/things/claude/agents/share-optimization-specialist.md +0 -576
  689. package/one/things/claude/agents/sm.md +0 -352
  690. package/one/things/claude/agents/story-teller.md +0 -498
  691. package/one/things/claude/agents/task-master.md +0 -621
  692. package/one/things/claude/agents/tauri-cross-platform-specialist.md +0 -1912
  693. package/one/things/claude/agents/tester.md +0 -595
  694. package/one/things/claude/agents/the-bull-character-manager.md +0 -603
  695. package/one/things/claude/agents/tools-playbook-generator.md +0 -492
  696. package/one/things/claude/agents/turbo-repo-builder.md +0 -346
  697. package/one/things/claude/agents/upsell-strategist.md +0 -503
  698. package/one/things/claude/agents/ux-expert.md +0 -360
  699. package/one/things/claude/agents/viral-growth-orchestrator.md +0 -520
  700. package/one/things/claude/claude-code-hooks-development.json +0 -21
  701. package/one/things/claude/claude-code-hooks-production.json +0 -21
  702. package/one/things/claude/claude-code-hooks.json +0 -25
  703. package/one/things/claude/commands/agent.md +0 -124
  704. package/one/things/claude/commands/cascade-status.md +0 -153
  705. package/one/things/claude/commands/ingest.md +0 -343
  706. package/one/things/claude/commands/ingestor.md +0 -158
  707. package/one/things/claude/commands/mission.md +0 -103
  708. package/one/things/claude/commands/npx.md +0 -156
  709. package/one/things/claude/commands/one.md +0 -486
  710. package/one/things/claude/commands/quality-check.md +0 -252
  711. package/one/things/claude/commands/smart-route.md +0 -261
  712. package/one/things/claude/commands/start.md +0 -139
  713. package/one/things/claude/commands/story.md +0 -103
  714. package/one/things/claude/commands/task.md +0 -193
  715. package/one/things/claude/hook-bypass.json +0 -32
  716. package/one/things/claude/hooks/agent-hook-config.json +0 -427
  717. package/one/things/claude/hooks/build-hook.sh +0 -156
  718. package/one/things/claude/hooks/cleanup-hook.sh +0 -201
  719. package/one/things/claude/hooks/file-organization-hook.sh +0 -80
  720. package/one/things/claude/hooks/format-hook.sh +0 -43
  721. package/one/things/claude/hooks/hook-bypass.sh +0 -293
  722. package/one/things/claude/hooks/hook-debouncer.sh +0 -62
  723. package/one/things/claude/hooks/hook-logger.sh +0 -89
  724. package/one/things/claude/hooks/lint-hook.sh +0 -140
  725. package/one/things/claude/hooks/notification-hook.sh +0 -204
  726. package/one/things/claude/hooks/ontology-validation-hook.sh +0 -86
  727. package/one/things/claude/hooks/performance-metrics.json +0 -25
  728. package/one/things/claude/hooks/security-hook.sh +0 -256
  729. package/one/things/claude/hooks/story-validation-hook-enhanced.sh +0 -210
  730. package/one/things/claude/hooks/story-validation-hook.sh +0 -145
  731. package/one/things/claude/hooks/test-hook.sh +0 -145
  732. package/one/things/claude/hooks/test-story-validation.sh +0 -170
  733. package/one/things/claude/settings-local.json +0 -86
  734. package/one/things/cli/cli-code.md +0 -677
  735. package/one/things/cli/cli-compiler-code.md +0 -677
  736. package/one/things/cli/cli.md +0 -871
  737. package/one/things/components/card-shadcn.md +0 -953
  738. package/one/things/components/card.md +0 -1041
  739. package/one/things/components.md +0 -1743
  740. package/one/things/componets.md +0 -19
  741. package/one/things/contracts/Move.toml +0 -12
  742. package/one/things/contracts/README.md +0 -288
  743. package/one/things/contracts/one.move +0 -762
  744. package/one/things/contracts/sdk.ts +0 -578
  745. package/one/things/creator-diagram.md +0 -184
  746. package/one/things/crypto/FEATURES.md +0 -78
  747. package/one/things/crypto/ONECORE.md +0 -62
  748. package/one/things/crypto/ONECOREFAQ.md +0 -22
  749. package/one/things/crypto/ONECOREHOW.md +0 -46
  750. package/one/things/crypto/ONEENTERPRISE.md +0 -64
  751. package/one/things/crypto/ONEENTERPRISEFAQ.md +0 -64
  752. package/one/things/crypto/ONEENTERPRISEHOW.md +0 -53
  753. package/one/things/crypto/ONEPRO.md +0 -60
  754. package/one/things/crypto/ONEPROFAQ.md +0 -22
  755. package/one/things/crypto/ONEPROHOW.md +0 -53
  756. package/one/things/crypto/READMEAGENCY.md +0 -64
  757. package/one/things/crypto/VSL.md +0 -45
  758. package/one/things/crypto/WebsiteCopy.md +0 -176
  759. package/one/things/demo-accessibility-animations.md +0 -1025
  760. package/one/things/demo-components.md +0 -1310
  761. package/one/things/demo-design-summary.md +0 -692
  762. package/one/things/demo-design-system.md +0 -973
  763. package/one/things/demo-page-layouts.md +0 -1016
  764. package/one/things/design-system.md +0 -832
  765. package/one/things/designs/accessibility-audit.md +0 -877
  766. package/one/things/designs/component-specifications.md +0 -855
  767. package/one/things/designs/design-overview.md +0 -377
  768. package/one/things/designs/design-tokens.md +0 -448
  769. package/one/things/designs/wireframes-dashboard.md +0 -710
  770. package/one/things/docs/api-requests.md +0 -987
  771. package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +0 -485
  772. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +0 -465
  773. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +0 -425
  774. package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +0 -451
  775. package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +0 -536
  776. package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +0 -650
  777. package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +0 -473
  778. package/one/things/docs/ecommerce/QUICK-START.md +0 -405
  779. package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +0 -567
  780. package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +0 -271
  781. package/one/things/docs/ecommerce/USAGE-EXAMPLE.astro +0 -171
  782. package/one/things/docs/ecommerce/demo.astro +0 -309
  783. package/one/things/examples/children/lemonade-stand.md +0 -404
  784. package/one/things/examples/enterprise/crm-saas.md +0 -1444
  785. package/one/things/features/1-1-agent-prompts.md +0 -562
  786. package/one/things/features/1-2-yaml-orchestrator.md +0 -548
  787. package/one/things/features/1-3-event-coordination.md +0 -547
  788. package/one/things/features/1-4-knowledge-management.md +0 -652
  789. package/one/things/features/1-5-quality-loops.md +0 -725
  790. package/one/things/features/1-6-numbering-structure.md +0 -639
  791. package/one/things/features/2-1-dataprovider-interface.md +0 -2583
  792. package/one/things/features/2-2-config-system.md +0 -3242
  793. package/one/things/features/2-3-effectts-services.md +0 -1645
  794. package/one/things/features/2-4-react-hooks.md +0 -2136
  795. package/one/things/features/2-5-auth-migration.md +0 -2144
  796. package/one/things/features/2-6-dashboard-migration.md +0 -2084
  797. package/one/things/features/2-7-alternative-providers.md +0 -2578
  798. package/one/things/features/2-7-implementation-report.md +0 -724
  799. package/one/things/features/2-cli.md +0 -1720
  800. package/one/things/features/2-design.md +0 -1770
  801. package/one/things/features/2-tests.md +0 -576
  802. package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +0 -576
  803. package/one/things/features/DECOUPLING.md +0 -290
  804. package/one/things/features/DEPLOYMENT.md +0 -470
  805. package/one/things/features/IMPLEMENTATION_SUMMARY.md +0 -362
  806. package/one/things/features/improve.md +0 -861
  807. package/one/things/features/remove-convex-deps.md +0 -63
  808. package/one/things/features/top-features.md +0 -87
  809. package/one/things/features/use-one-backend.md +0 -1217
  810. package/one/things/features-in-english.md +0 -200
  811. package/one/things/files.yaml +0 -721
  812. package/one/things/ideas/1-create-workflow.md +0 -207
  813. package/one/things/ideas/2-backend-agnostic-frontend.md +0 -439
  814. package/one/things/implementation/backend-guide.md +0 -457
  815. package/one/things/interface.md +0 -257
  816. package/one/things/landing-page-implementation.md +0 -455
  817. package/one/things/legal/README.md +0 -234
  818. package/one/things/legal/privacy-policy.md +0 -1227
  819. package/one/things/legal/terms-of-service.md +0 -1432
  820. package/one/things/master-workflow-plan.md +0 -806
  821. package/one/things/pay.one.ie.md +0 -53
  822. package/one/things/plans/0-in-sync.md +0 -136
  823. package/one/things/plans/0-timeline.md +0 -36
  824. package/one/things/plans/1-create-workflow.md +0 -732
  825. package/one/things/plans/QUICK-START-SIMPLIFICATION.md +0 -333
  826. package/one/things/plans/README-SIMPLIFICATION.md +0 -349
  827. package/one/things/plans/SIMPLIFICATION-EXAMPLES.md +0 -16
  828. package/one/things/plans/SIMPLIFICATION-SUMMARY.md +0 -455
  829. package/one/things/plans/ai-elements-integration.md +0 -483
  830. package/one/things/plans/ai-elements.md +0 -1278
  831. package/one/things/plans/ai-integration-plan.md +0 -263
  832. package/one/things/plans/ai-integration.md +0 -996
  833. package/one/things/plans/ai-sdk.md +0 -798
  834. package/one/things/plans/ai-tools.md +0 -621
  835. package/one/things/plans/app.md +0 -832
  836. package/one/things/plans/architecture-summary.md +0 -312
  837. package/one/things/plans/async-ai-agents.md +0 -233
  838. package/one/things/plans/backend-agnostic-frontend.md +0 -390
  839. package/one/things/plans/backend-cleanup-quickstart.md +0 -380
  840. package/one/things/plans/backend-ontology-conformance.md +0 -475
  841. package/one/things/plans/backend-status.md +0 -599
  842. package/one/things/plans/backend-structure.md +0 -847
  843. package/one/things/plans/backend-target-structure.md +0 -482
  844. package/one/things/plans/backend.md +0 -1175
  845. package/one/things/plans/better-auth-any-backend-revised.md +0 -1103
  846. package/one/things/plans/better-auth-any-backend.md +0 -1896
  847. package/one/things/plans/better-auth-available-features.md +0 -273
  848. package/one/things/plans/big-plan.md +0 -52
  849. package/one/things/plans/cli-updates-required.md +0 -320
  850. package/one/things/plans/complete-step-by-step.md +0 -1409
  851. package/one/things/plans/components.md +0 -709
  852. package/one/things/plans/convex-agents.md +0 -1034
  853. package/one/things/plans/convex-better-auth.md +0 -1141
  854. package/one/things/plans/convex-on-off.md +0 -407
  855. package/one/things/plans/crypto-token-researcher.md +0 -629
  856. package/one/things/plans/data-quality-metrics.md +0 -745
  857. package/one/things/plans/deep-researcher-agent.md +0 -466
  858. package/one/things/plans/deploy-to-cloudflare.md +0 -623
  859. package/one/things/plans/deployment-architecture.md +0 -469
  860. package/one/things/plans/desktop.md +0 -1139
  861. package/one/things/plans/development-plan.md +0 -1283
  862. package/one/things/plans/development-workflow-tldr.md +0 -207
  863. package/one/things/plans/development-workflow.md +0 -959
  864. package/one/things/plans/dsl-claude-code.md +0 -1011
  865. package/one/things/plans/effect-components.md +0 -1743
  866. package/one/things/plans/effect-patterns-reference.md +0 -2235
  867. package/one/things/plans/effect.md +0 -1806
  868. package/one/things/plans/email.md +0 -966
  869. package/one/things/plans/enhance-auth.md +0 -1692
  870. package/one/things/plans/execution-strategy.md +0 -1291
  871. package/one/things/plans/existing-infrastructure.md +0 -712
  872. package/one/things/plans/feature-based-sites.md +0 -894
  873. package/one/things/plans/frontend-effects.md +0 -1276
  874. package/one/things/plans/group-folder-multi-tenancy.md +0 -893
  875. package/one/things/plans/improve-codebase.md +0 -1811
  876. package/one/things/plans/install-components.md +0 -215
  877. package/one/things/plans/integrate-frontend-and-backend.md +0 -603
  878. package/one/things/plans/landing.md +0 -820
  879. package/one/things/plans/layout.md +0 -249
  880. package/one/things/plans/mail-backend.md +0 -1361
  881. package/one/things/plans/mail.md +0 -2677
  882. package/one/things/plans/mcp-clear-context-prompt.md +0 -81
  883. package/one/things/plans/mcp-simple.md +0 -248
  884. package/one/things/plans/multi-ontology-architecture.md +0 -885
  885. package/one/things/plans/next-features.md +0 -114
  886. package/one/things/plans/npx-agent-safety.md +0 -785
  887. package/one/things/plans/npx-agent.md +0 -1089
  888. package/one/things/plans/onboarding.md +0 -51
  889. package/one/things/plans/one-protocol-and-payone-usage.md +0 -82
  890. package/one/things/plans/one.md +0 -677
  891. package/one/things/plans/ontology-6-dimensions.md +0 -2201
  892. package/one/things/plans/ontology-compliance-audit.md +0 -342
  893. package/one/things/plans/ontology-driven-strategy.md +0 -882
  894. package/one/things/plans/ontology-refine.md +0 -586
  895. package/one/things/plans/ontology-ui-approach.md +0 -375
  896. package/one/things/plans/open-agent.md +0 -840
  897. package/one/things/plans/performace.md +0 -122
  898. package/one/things/plans/phase-1-foundation.md +0 -620
  899. package/one/things/plans/phase-3-implementation.md +0 -1037
  900. package/one/things/plans/plan-connect-to-api.md +0 -146
  901. package/one/things/plans/quick-wins.md +0 -1428
  902. package/one/things/plans/r2.md +0 -777
  903. package/one/things/plans/readme-backend-cleanup.md +0 -402
  904. package/one/things/plans/release.md +0 -507
  905. package/one/things/plans/remove-backend-development-from-agents.md +0 -1331
  906. package/one/things/plans/repos.md +0 -98
  907. package/one/things/plans/separate-copy-2.md +0 -1349
  908. package/one/things/plans/separate-copy-3.md +0 -2479
  909. package/one/things/plans/separate-copy.md +0 -1349
  910. package/one/things/plans/separate-demo.md +0 -864
  911. package/one/things/plans/separate.md +0 -1999
  912. package/one/things/plans/sequence.md +0 -2040
  913. package/one/things/plans/shadcn-integration-summary.md +0 -510
  914. package/one/things/plans/sidebar.md +0 -206
  915. package/one/things/plans/skills.md +0 -709
  916. package/one/things/plans/small-fixes.md +0 -23
  917. package/one/things/plans/start-new.md +0 -764
  918. package/one/things/plans/switch-off-auth.md +0 -42
  919. package/one/things/plans/sync-checklist.md +0 -351
  920. package/one/things/plans/test-backend-connection.md +0 -514
  921. package/one/things/plans/unified-implementation-plan.md +0 -934
  922. package/one/things/plans/update-demos.md +0 -581
  923. package/one/things/plans/use-our-backend.md +0 -572
  924. package/one/things/plans/video-backend.md +0 -638
  925. package/one/things/plans/video-frontend.md +0 -490
  926. package/one/things/plans/video-old-archived.md +0 -656
  927. package/one/things/plans/wave1-onboarding-100-inferences.md +0 -1686
  928. package/one/things/plans/wave1-onboarding-vision.md +0 -744
  929. package/one/things/plans/wave1-orchestration-summary.md +0 -604
  930. package/one/things/plans/wave1-specialist-assignments.md +0 -1413
  931. package/one/things/plans/workflow-files.md +0 -1210
  932. package/one/things/plans/workflow.md +0 -1378
  933. package/one/things/plans-u.md +0 -905
  934. package/one/things/products/Blockchain Products.md +0 -6278
  935. package/one/things/products/cascade-landing-page.md +0 -841
  936. package/one/things/products/cascade.md +0 -1568
  937. package/one/things/products/context-engineering.md +0 -1488
  938. package/one/things/products/onthology.md +0 -15
  939. package/one/things/products/ontology-ui-shadcn.md +0 -1302
  940. package/one/things/products/ontology-ui.md +0 -1429
  941. package/one/things/products/ontology.md +0 -789
  942. package/one/things/products/sdk.md +0 -573
  943. package/one/things/promptkit.md +0 -930
  944. package/one/things/repos/all-repos.md +0 -0
  945. package/one/things/scripts-clean-mac.sh +0 -409
  946. package/one/things/service-providers-new.md +0 -1052
  947. package/one/things/service-providers.md +0 -1121
  948. package/one/things/structure.md +0 -532
  949. package/one/things/system.md +0 -618
  950. package/one/things/templates.md +0 -294
  951. package/one/things/tests/2-1-dataprovider-interface.md +0 -1216
  952. package/one/things/tests/2-1-test-analysis.md +0 -544
  953. package/one/things/things.md +0 -384
  954. package/one/things/todo-acp-integration.md +0 -744
  955. package/one/things/todo-ai.md +0 -933
  956. package/one/things/todo-api.md +0 -1078
  957. package/one/things/todo-assignment.md +0 -580
  958. package/one/things/todo-buy-chatgpt.md +0 -1450
  959. package/one/things/todo-components.md +0 -1683
  960. package/one/things/todo-connections.md +0 -278
  961. package/one/things/todo-ecommerce-frontend.md +0 -1313
  962. package/one/things/todo-ecommerce.md +0 -569
  963. package/one/things/todo-effects.md +0 -1075
  964. package/one/things/todo-frontend-effects.md +0 -977
  965. package/one/things/todo-landing-page.md +0 -1091
  966. package/one/things/todo-mail.md +0 -1160
  967. package/one/things/todo-master-plan.md +0 -490
  968. package/one/things/todo-onboard.md +0 -666
  969. package/one/things/todo-one-ie.md +0 -538
  970. package/one/things/todo-page.md +0 -606
  971. package/one/things/todo-plans.md +0 -282
  972. package/one/things/todo-projects.md +0 -241
  973. package/one/things/todo-refactoring-plan.md +0 -366
  974. package/one/things/todo-release.md +0 -654
  975. package/one/things/todo-sequence.md +0 -1621
  976. package/one/things/todo-use-our-backend.md +0 -1908
  977. package/one/things/todo-workflow.md +0 -626
  978. package/one/things/todo-x402.md +0 -2047
  979. package/one/things/todo.md +0 -21
  980. package/one/things/video/scripts-crypto.md +0 -835
  981. package/one/things/video-script-backup.md +0 -318
  982. package/one/things/video-script-demo.md +0 -382
  983. package/one/things/video-script-ontology.md +0 -333
  984. 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.**