oneie 3.6.7 → 3.6.12

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 (168) hide show
  1. package/.claude/agents/agent-backend.md +83 -0
  2. package/.claude/agents/agent-designer.md +97 -0
  3. package/.claude/agents/agent-director.md +118 -7
  4. package/.claude/agents/agent-documenter.md +93 -0
  5. package/.claude/agents/agent-frontend.md +96 -0
  6. package/.claude/agents/agent-ops.md +264 -32
  7. package/.claude/agents/agent-problem-solver.md +166 -0
  8. package/.claude/agents/agent-quality.md +127 -0
  9. package/.claude/commands/build.md +293 -0
  10. package/.claude/commands/cascade.md +231 -127
  11. package/.claude/commands/deploy.md +56 -17
  12. package/.claude/commands/mcp-toggle.md +93 -0
  13. package/.claude/commands/one.md +78 -127
  14. package/.claude/commands/plan.md +394 -80
  15. package/.claude/commands/push.md +75 -14
  16. package/.claude/commands/release.md +89 -25
  17. package/.claude/commands/server.md +2 -0
  18. package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
  19. package/.claude/hooks/root-cleanup.py +75 -0
  20. package/.claude/skills/INDEX.md +523 -0
  21. package/.claude/skills/REGISTRY.md +529 -0
  22. package/.claude/skills/agent-backend-create-mutation.md +319 -0
  23. package/.claude/skills/agent-designer-create-wireframe.md +341 -0
  24. package/.claude/skills/agent-frontend-create-page.md +413 -0
  25. package/.claude/skills/agents/README.md +238 -0
  26. package/dist/clone-web.js +1 -1
  27. package/dist/clone-web.js.map +1 -1
  28. package/folders.yaml +1 -1
  29. package/one/.obsidian/workspace.json +38 -38
  30. package/one/connections/api/queries-reference.md +842 -0
  31. package/one/connections/api-reference.md +1011 -0
  32. package/one/connections/integration-examples.md +875 -0
  33. package/one/connections/integration-guide.md +869 -0
  34. package/one/connections/integration-phase2.md +736 -0
  35. package/one/events/API_ROUTES_FIXES_SUMMARY.md +262 -0
  36. package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +636 -0
  37. package/one/events/BEFORE_AFTER_COMPARISON.md +960 -0
  38. package/one/events/CONNECTIONS_DEMO.md +501 -0
  39. package/one/events/DELIVERABLES.md +432 -0
  40. package/one/events/DEMO-GROUPS-PAGE.md +392 -0
  41. package/one/events/DEMO-TESTING-SUMMARY.md +518 -0
  42. package/one/events/DEMO_COMPONENTS.md +487 -0
  43. package/one/events/DEMO_HOOKS_INDEX.md +334 -0
  44. package/one/events/DEMO_INFRASTRUCTURE.md +905 -0
  45. package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +570 -0
  46. package/one/events/DEMO_INTEGRATION_CHECKLIST.md +431 -0
  47. package/one/events/DEMO_QUICK_REFERENCE.md +441 -0
  48. package/one/events/DEMO_SETUP.md +476 -0
  49. package/one/events/EFFECT_TS_API_PATTERN.md +478 -0
  50. package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +414 -0
  51. package/one/events/HOOKS-DEMO.md +441 -0
  52. package/one/events/ONTOLOGY-HOOKS-README.md +700 -0
  53. package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +365 -0
  54. package/one/events/QA-CHECKLIST.md +674 -0
  55. package/one/events/QUICK-START-ONTOLOGY.md +408 -0
  56. package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +639 -0
  57. package/one/events/SEARCH_DEMO_DELIVERY.md +415 -0
  58. package/one/events/SEARCH_DEMO_SUMMARY.md +303 -0
  59. package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +381 -0
  60. package/one/events/TEST-PLAN-INDEX.md +346 -0
  61. package/one/events/TEST-PLAN.md +1417 -0
  62. package/one/events/TESTING-DELIVERY.txt +372 -0
  63. package/one/events/TRANSITIONS-QUICK-START.md +141 -0
  64. package/one/events/TYPESCRIPT_FIXES.md +152 -0
  65. package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +412 -0
  66. package/one/events/TYPESCRIPT_FIXES_INDEX.md +341 -0
  67. package/one/events/VIEW-TRANSITIONS.md +428 -0
  68. package/one/events/backend-integration-tests.md +606 -0
  69. package/one/events/backend-structure-diagram.txt +393 -0
  70. package/one/events/backend-structure-summary.txt +269 -0
  71. package/one/events/cloudflare-pages-infrastructure-setup.md +264 -0
  72. package/one/events/convex-analysis-index.md +304 -0
  73. package/one/events/convex-structure-analysis.md +700 -0
  74. package/one/events/design-spec-complete.md +208 -0
  75. package/one/events/ontology-test-examples.md +562 -0
  76. package/one/events/phase1-backend-implementation-complete.md +518 -0
  77. package/one/events/test-dashboard.md +345 -0
  78. package/one/events/test-index.md +361 -0
  79. package/one/events/test-report-ontology.md +582 -0
  80. package/one/events/testing-summary.md +344 -0
  81. package/one/groups/features.md +2878 -0
  82. package/one/groups/strategy copy.md +869 -0
  83. package/one/knowledge/backend-api-reference.md +710 -0
  84. package/one/knowledge/documentation-summary.md +285 -0
  85. package/one/knowledge/lessons-learned.md +294 -4
  86. package/one/knowledge/ontology-visual-guide.md +360 -0
  87. package/one/knowledge/ontology.md +9 -17
  88. package/one/things/demo-accessibility-animations.md +999 -0
  89. package/one/things/demo-components.md +1304 -0
  90. package/one/things/demo-design-summary.md +629 -0
  91. package/one/things/demo-design-system.md +919 -0
  92. package/one/things/demo-page-layouts.md +989 -0
  93. package/one/things/designs/accessibility-audit.md +790 -0
  94. package/one/things/designs/component-specifications.md +757 -0
  95. package/one/things/designs/design-overview.md +318 -0
  96. package/one/things/designs/design-tokens.md +414 -0
  97. package/one/things/designs/wireframes-dashboard.md +653 -0
  98. package/one/things/docs/api-requests.md +923 -0
  99. package/one/things/features/0 All Features.md +2 -0
  100. package/one/things/implementation/backend-guide.md +412 -0
  101. package/one/things/plans/2-backend-agnostic-frontend.md +11 -8
  102. package/one/things/plans/2-sites.md +895 -0
  103. package/one/things/plans/ai-elements.md +1259 -0
  104. package/one/things/plans/ai-integration.md +947 -0
  105. package/one/things/plans/ai-sdk.md +761 -0
  106. package/one/things/plans/app.md +1 -1
  107. package/one/things/plans/architecture-summary.md +283 -0
  108. package/one/things/plans/async-ai-agents.md +215 -0
  109. package/one/things/plans/backend-agnostic-frontend.md +11 -6
  110. package/one/things/plans/backend-cleanup-quickstart.md +346 -0
  111. package/one/things/plans/backend-ontology-conformance.md +416 -0
  112. package/one/things/plans/backend-status.md +541 -0
  113. package/one/things/plans/backend-structure.md +799 -0
  114. package/one/things/plans/backend-target-structure.md +438 -0
  115. package/one/things/plans/backend.md +1133 -0
  116. package/one/things/plans/better-auth-any-backend.md +11 -11
  117. package/one/things/plans/cli-updates-required.md +280 -0
  118. package/one/things/plans/complete-step-by-step.md +1302 -0
  119. package/one/things/plans/convex-agents.md +1005 -0
  120. package/one/things/plans/deployment-architecture.md +426 -0
  121. package/one/things/plans/development-plan.md +1220 -0
  122. package/one/things/plans/effect.md +808 -48
  123. package/one/things/plans/integrate-frontend-and-backend.md +579 -0
  124. package/one/things/plans/mcp-clear-context-prompt.md +60 -0
  125. package/one/things/plans/mcp-simple.md +228 -0
  126. package/one/things/plans/one.md +8 -7
  127. package/one/things/plans/ontology-6-dimensions.md +20 -14
  128. package/one/things/plans/quick-wins.md +1273 -0
  129. package/one/things/plans/readme-backend-cleanup.md +361 -0
  130. package/one/things/plans/separate-demo.md +830 -0
  131. package/one/things/plans/separate.md +3 -3
  132. package/one/things/plans/sequence.md +1897 -0
  133. package/one/things/plans/sync-checklist.md +321 -0
  134. package/one/things/plans/unified-implementation-plan.md +3 -3
  135. package/one/things/plans/update-demos.md +513 -0
  136. package/package.json +1 -1
  137. package/.claude/agents/backend-specialist.md +0 -169
  138. package/.claude/agents/designer.md +0 -216
  139. package/.claude/agents/frontend-specialist.md +0 -236
  140. package/.claude/commands/done.md +0 -35
  141. package/.claude/commands/infer.md +0 -138
  142. package/.claude/commands/next.md +0 -53
  143. package/.claude/commands/one copy.md +0 -565
  144. package/.claude/commands/one-template.md +0 -106
  145. package/.claude/commands/one-v1.md +0 -609
  146. package/.claude/hooks/__pycache__/knowledge-post.cpython-313.pyc +0 -0
  147. package/.claude/hooks/__pycache__/knowledge-pre.cpython-313.pyc +0 -0
  148. package/one/groups/nine-padel-customers.md +0 -138
  149. package/one/groups/nine-padel-data-structure.md +0 -167
  150. package/one/groups/nine-padel-ontology-specification.md +0 -359
  151. package/one/groups/nine-padel-ontology.md +0 -143
  152. package/one/groups/nine-padel-strategy.md +0 -234
  153. package/one/groups/nine-padel.md +0 -211
  154. package/one/groups/nine-padle-contents.baked.md +0 -1252
  155. package/one/groups/nine-padle-contents.md +0 -6
  156. package/one/things/features/1-1-agent-prompts/design.md +0 -470
  157. package/one/things/features/1-1-agent-prompts/tests.md +0 -264
  158. package/one/things/features/1-2-yaml-orchestrator/design.md +0 -497
  159. package/one/things/features/1-2-yaml-orchestrator/tests.md +0 -227
  160. package/one/things/features/1-3-event-coordination/design.md +0 -544
  161. package/one/things/features/1-3-event-coordination/tests.md +0 -223
  162. package/one/things/features/1-4-knowledge-management/design.md +0 -609
  163. package/one/things/features/1-4-knowledge-management/tests.md +0 -195
  164. package/one/things/features/1-5-quality-loops/design.md +0 -797
  165. package/one/things/features/1-5-quality-loops/tests.md +0 -212
  166. package/one/things/features/1-6-numbering-structure/design.md +0 -610
  167. package/one/things/features/1-6-numbering-structure/tests.md +0 -213
  168. package/one/things/features/dataprovider-interface/1-tests.md +0 -1522
@@ -70,7 +70,7 @@ Transform the mail UI into `src/pages/app/index.astro` - matching the exact Figm
70
70
  **Ontology Mapping:**
71
71
  ```
72
72
  Messages → Things (all entities)
73
- Groups → Org View (organization-scoped)
73
+ Groups → Group View (group-scoped)
74
74
  Agents → AI Agents (type: "agent")
75
75
  Tools → Protocols (integrations/services)
76
76
  People → Users (type: "user")
@@ -0,0 +1,283 @@
1
+ # ONE Platform Deployment Architecture - Quick Reference
2
+
3
+ ## ✅ CORRECT Architecture
4
+
5
+ ```
6
+ /web (development - single source of truth)
7
+ ├─→ git push → one-ie/web (website source repo)
8
+ ├─→ sync to apps/oneie/ → git push → one-ie/oneie → one.ie
9
+ └─→ sync to apps/one/ → git push → one-ie/one → demo.one.ie
10
+ ↓
11
+ npx oneie clones
12
+ ```
13
+
14
+ ---
15
+
16
+ ## Projects & Repositories
17
+
18
+ | Purpose | Project Name | GitHub Repo | Cloudflare Project | Domain |
19
+ |---------|-------------|-------------|-------------------|---------|
20
+ | **Website Source** | web | one-ie/web | N/A | (source only) |
21
+ | **Main Website** | oneie | one-ie/oneie | oneie | one.ie |
22
+ | **Demo/Starter** | one | one-ie/one | one | demo.one.ie |
23
+
24
+ ---
25
+
26
+ ## Key Mappings
27
+
28
+ ### Website Source (one-ie/web)
29
+ - **Source:** Local `/web` (development - single source of truth)
30
+ - **Repo:** `one-ie/web` (website code only, git repo)
31
+ - **Purpose:** Website source repository
32
+ - **Usage:** Pushed from local `/web` development
33
+
34
+ ### Main Website (one.ie)
35
+ - **Source:** Local `/web`, `/one`, `/.claude` synced to `apps/oneie/`
36
+ - **Repo:** `one-ie/oneie` (full structure: web/, one/, .claude/)
37
+ - **Cloudflare:** `oneie` project
38
+ - **Domain:** https://one.ie
39
+ - **Purpose:** Full platform + marketing
40
+ - **Features:** Backend ON, Admin OFF, Full navigation
41
+
42
+ ### Demo/Starter (demo.one.ie)
43
+ - **Source:** Local `/web`, `/one`, `/.claude` synced to `apps/one/`
44
+ - **Repo:** `one-ie/one` (full structure: web/, one/, .claude/)
45
+ - **Cloudflare:** `one` project
46
+ - **Domain:** https://demo.one.ie
47
+ - **Also:** `npx oneie` clones `one-ie/web` for website
48
+ - **Purpose:** Starter template for developers
49
+ - **Features:** Backend OFF, No admin, Minimal navigation
50
+
51
+ ---
52
+
53
+ ## Release Commands
54
+
55
+ ```bash
56
+ # Push website source
57
+ cd web && git push origin main
58
+ # → Updates one-ie/web (single source of truth)
59
+
60
+ # Deploy main website
61
+ ./scripts/release.sh patch main
62
+ # → Syncs /web, /one, /.claude to apps/oneie/
63
+ # → Pushes apps/oneie/ to one-ie/oneie
64
+ # → Deploys to one.ie
65
+
66
+ # Deploy demo/starter
67
+ ./scripts/release.sh patch demo
68
+ # → Syncs /web, /one, /.claude to apps/one/
69
+ # → Pushes apps/one/ to one-ie/one
70
+ # → Deploys to demo.one.ie
71
+
72
+ # Deploy all
73
+ cd web && git push && cd .. && ./scripts/release.sh patch main && ./scripts/release.sh patch demo
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Environment Files
79
+
80
+ ```bash
81
+ # web/.env.local (development - full features)
82
+ ORG_NAME=one
83
+ ORG_WEBSITE=https://one.ie
84
+ ONE_BACKEND=on
85
+ ENABLE_ADMIN_FEATURES=true
86
+ SITE_TYPE=development
87
+
88
+ # web/.env.main (for one.ie)
89
+ ORG_NAME=one
90
+ ORG_WEBSITE=https://one.ie
91
+ ONE_BACKEND=on
92
+ ENABLE_ADMIN_FEATURES=false
93
+ SITE_TYPE=main
94
+
95
+ # web/.env.demo (for demo.one.ie)
96
+ ORG_NAME=one
97
+ ORG_WEBSITE=https://demo.one.ie
98
+ ONE_BACKEND=off
99
+ ENABLE_ADMIN_FEATURES=false
100
+ SITE_TYPE=demo
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Directory Structure
106
+
107
+ ```
108
+ ONE/ # Local workspace
109
+ ├── web/ # Development website (all features)
110
+ ├── one/ # Documentation
111
+ ├── .claude/ # Claude configuration
112
+ │
113
+ └── apps/
114
+ ├── oneie/ # Main site assembly
115
+ │ ├── web/ # → one.ie
116
+ │ ├── one/ # Documentation copy
117
+ │ └── .claude/ # Claude config copy
118
+ │
119
+ └── one/ # Demo site assembly
120
+ ├── web/ # → demo.one.ie
121
+ ├── one/ # Documentation copy
122
+ └── .claude/ # Claude config copy
123
+
124
+ GitHub Repositories (synced from apps/):
125
+
126
+ one-ie/oneie/ # Main site repo
127
+ ├── web/ # Main website code
128
+ ├── one/ # Documentation
129
+ └── .claude/ # Claude config
130
+
131
+ one-ie/one/ # Demo/starter repo
132
+ ├── web/ # Demo website code
133
+ ├── one/ # Documentation
134
+ └── .claude/ # Claude config
135
+ ```
136
+
137
+ ---
138
+
139
+ ## User Flows
140
+
141
+ ### Flow 1: Visit Main Website
142
+ ```
143
+ User → one.ie
144
+ → Full platform experience
145
+ → Backend enabled
146
+ → Can sign up/sign in
147
+ → Access all features
148
+ ```
149
+
150
+ ### Flow 2: Try Demo Online
151
+ ```
152
+ User → demo.one.ie
153
+ → Starter template preview
154
+ → Backend disabled (frontend-only)
155
+ → See what they'll download
156
+ → No signup required
157
+ ```
158
+
159
+ ### Flow 3: Download Starter
160
+ ```
161
+ Developer → npx oneie
162
+ → Clones entire one-ie/one repo
163
+ → Gets:
164
+ • web/ (same as demo.one.ie)
165
+ • one/ (full documentation)
166
+ • .claude/ (Claude config)
167
+ → Complete starter kit
168
+ → Can customize locally
169
+ → Can connect own backend
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Cloudflare Projects to Create
175
+
176
+ 1. **Project: oneie**
177
+ - Custom domain: one.ie
178
+ - Build command: `cd web && bun run build`
179
+ - Build output: `web/dist`
180
+ - Root directory: `/` (repo has web/, one/, .claude/)
181
+ - Environment: Production (main site)
182
+
183
+ 2. **Project: one**
184
+ - Custom domain: demo.one.ie
185
+ - Build command: `cd web && bun run build`
186
+ - Build output: `web/dist`
187
+ - Root directory: `/` (repo has web/, one/, .claude/)
188
+ - Environment: Demo (starter)
189
+
190
+ ---
191
+
192
+ ## GitHub Repositories
193
+
194
+ 1. **one-ie/web** (EXISTING)
195
+ - Website source code only
196
+ - Pushed from: `/web` (local development)
197
+ - Cloned by: `npx oneie` (for website)
198
+ - Purpose: Single source of truth for website
199
+
200
+ 2. **one-ie/oneie** (NEW - create this)
201
+ - Full structure: `web/`, `one/`, `.claude/`
202
+ - Synced from: `apps/oneie/`
203
+ - Deploys: `web/` to one.ie
204
+ - Purpose: Main website assembly
205
+
206
+ 3. **one-ie/one** (EXISTING)
207
+ - Full structure: `web/`, `one/`, `.claude/`
208
+ - Synced from: `apps/one/`
209
+ - Deploys: `web/` to demo.one.ie
210
+ - Purpose: Demo/starter assembly
211
+
212
+ 4. **one-ie/cli** (EXISTING)
213
+ - CLI package on npm
214
+ - Clones `one-ie/web` for website
215
+ - Bundles `one/` and `.claude/` docs
216
+
217
+ ---
218
+
219
+ ## Quick Checklist
220
+
221
+ **Setup:**
222
+ - [ ] Create `one-ie/oneie` repo on GitHub
223
+ - [ ] Create Cloudflare project `oneie` → one.ie
224
+ - [ ] Create Cloudflare project `one` → demo.one.ie
225
+ - [ ] Create environment files (`.env.main`, `.env.demo`)
226
+ - [ ] Create feature flags config (`src/config/features.ts`)
227
+
228
+ **Test:**
229
+ - [ ] Build main site locally: `cp .env.main .env.local && bun run build`
230
+ - [ ] Build demo locally: `cp .env.demo .env.local && bun run build`
231
+ - [ ] Verify feature flags work correctly
232
+
233
+ **Deploy:**
234
+ - [ ] Deploy main: `./scripts/release.sh patch main`
235
+ - [ ] Deploy demo: `./scripts/release.sh patch demo`
236
+ - [ ] Verify one.ie works (full platform)
237
+ - [ ] Verify demo.one.ie works (starter)
238
+ - [ ] Test `npx oneie` downloads correct version
239
+
240
+ ---
241
+
242
+ ## Common Mistakes to Avoid
243
+
244
+ ❌ **DON'T:**
245
+ - Deploy development environment to production
246
+ - Mix main site and demo features
247
+ - Forget to sync demo to one-ie/one repo
248
+ - Use wrong Cloudflare project for deployment
249
+
250
+ ✅ **DO:**
251
+ - Keep `/web` as single source of truth
252
+ - Use environment files to control features
253
+ - Test both builds before deploying
254
+ - Sync demo to one-ie/one for npx distribution
255
+
256
+ ---
257
+
258
+ ## Summary
259
+
260
+ **One Codebase, Two Outputs:**
261
+
262
+ 1. **one.ie** (oneie project)
263
+ - Full platform
264
+ - Marketing site
265
+ - Backend enabled
266
+ - For: Public visitors
267
+
268
+ 2. **demo.one.ie + npx oneie** (one project)
269
+ - Starter template
270
+ - Minimal features
271
+ - Backend disabled
272
+ - For: Developers
273
+
274
+ **Single command to deploy both:**
275
+ ```bash
276
+ ./scripts/release.sh patch main && ./scripts/release.sh patch demo
277
+ ```
278
+
279
+ ---
280
+
281
+ **For complete documentation, see:**
282
+ - `separate-demo.md` - Full implementation guide
283
+ - `deployment-architecture.md` - Visual architecture overview
@@ -0,0 +1,215 @@
1
+ Here’s a **detailed and production-ready “build-agents” prompt** that you can give to **Claude Code, Codex, or any autonomous builder agent** to implement AI systems like those described by Ian from Convex.
2
+ It’s written in a _mission / story / task_ structure optimized for your Codex + ElizaOS workflow.
3
+
4
+ ---
5
+
6
+ # 🧭 Prompt: Build Async AI Agents with Convex
7
+
8
+ ## 🎯 Mission
9
+
10
+ Create a fully asynchronous AI agent system built on **Convex** that demonstrates how LLM-driven workflows, database persistence, and real-time reactivity combine into a durable, resilient architecture for AI applications.
11
+
12
+ The goal is to move away from long-running synchronous API calls toward a **persistent async model**:
13
+ LLMs write and read from a reactive database, enabling background processing, live UI updates, and fault-tolerant task orchestration.
14
+
15
+ ---
16
+
17
+ ## 🪶 Story Context
18
+
19
+ You are building an **AI agent orchestration framework** on top of **Convex**, inspired by Ian’s async talk.
20
+
21
+ Imagine two developers opening the same chat app:
22
+
23
+ - User A sends a prompt to an AI agent.
24
+ - User B, connected via a separate WebSocket session, instantly sees the streaming response as it’s generated.
25
+ - The backend processes the AI reasoning asynchronously — retrying, journaling, or resuming even if the client disconnects.
26
+
27
+ This system will support **AI agents that persist, resume, and self-coordinate**, without relying on synchronous HTTP calls.
28
+
29
+ ---
30
+
31
+ ## 🧩 Core Architecture Overview
32
+
33
+ ### 1. **Frontend**
34
+
35
+ - Built with React or SvelteKit.
36
+ - Uses Convex React hooks (`useQuery`, `useMutation`) for live data.
37
+ - Messages are displayed reactively from the database (no polling).
38
+ - Supports “optimistic UI” for pending messages.
39
+
40
+ ### 2. **Convex Backend**
41
+
42
+ - Located in `/convex/`.
43
+ - Contains:
44
+ - `schema.ts`: Defines message, agent, and workflow collections.
45
+ - `functions/`: Contains queries, mutations, and async workflows.
46
+ - `ai/`: Manages async calls to OpenAI, Anthropic, or other LLMs.
47
+
48
+ ### 3. **Database Schema (schema.ts)**
49
+
50
+ ```ts
51
+ export default defineSchema({
52
+ messages: defineTable({
53
+ threadId: v.string(),
54
+ role: v.union(
55
+ v.literal("user"),
56
+ v.literal("assistant"),
57
+ v.literal("system")
58
+ ),
59
+ content: v.string(),
60
+ status: v.optional(v.string()), // "pending" | "completed" | "error"
61
+ createdAt: v.number(),
62
+ }),
63
+ threads: defineTable({
64
+ title: v.string(),
65
+ lastUpdated: v.number(),
66
+ }),
67
+ workflows: defineTable({
68
+ step: v.string(),
69
+ status: v.string(), // "running", "paused", "failed", "done"
70
+ data: v.any(),
71
+ }),
72
+ });
73
+ ```
74
+
75
+ ---
76
+
77
+ ## ⚙️ Implementation Tasks
78
+
79
+ ### **Task 1: Reactive Queries**
80
+
81
+ - Create `getMessages` query:
82
+ - Returns all messages for a thread.
83
+ - Automatically re-runs whenever a new message is added.
84
+
85
+ - Frontend subscribes via `useQuery`.
86
+
87
+ ### **Task 2: Message Mutations**
88
+
89
+ - `sendMessage`: Insert user prompt with `status = "pending"`.
90
+ - `updateMessage`: Update assistant’s response progressively as tokens stream in.
91
+
92
+ ### **Task 3: Async AI Workflow**
93
+
94
+ - Create `functions/ai/runAgent.ts`:
95
+ - Triggered by `sendMessage`.
96
+ - Uses `convex.workflow` or `convex.backgroundFunction`.
97
+ - Journals progress and retries automatically.
98
+ - Calls an LLM (e.g., OpenAI, Claude) asynchronously.
99
+ - Writes partial responses (`sentence by sentence`) into the database.
100
+ - Supports resumable checkpoints.
101
+
102
+ ```ts
103
+ export const runAgent = async (ctx, { threadId, messageId }) => {
104
+ await ctx.db.patch(messageId, { status: "running" });
105
+ const prompt = await ctx.db.get(messageId);
106
+
107
+ for await (const chunk of streamLLM(prompt.content)) {
108
+ await ctx.db.patch(messageId, { content: chunk });
109
+ }
110
+
111
+ await ctx.db.patch(messageId, { status: "completed" });
112
+ };
113
+ ```
114
+
115
+ ---
116
+
117
+ ### **Task 4: Durable Workflows**
118
+
119
+ - Implement Convex Workflows (durable journaled tasks).
120
+ - Automatically resume after server restart.
121
+ - Support “pause for human input” or “schedule resume” after hours.
122
+
123
+ Example:
124
+
125
+ ```ts
126
+ export const workflow = convex.workflow(async (ctx, { input }) => {
127
+ await ctx.step("analyze", async () => analyzePrompt(input));
128
+ await ctx.step("generate", async () => callLLM(input));
129
+ await ctx.step("finalize", async () => saveToDB(ctx, result));
130
+ });
131
+ ```
132
+
133
+ ---
134
+
135
+ ### **Task 5: Multi-Agent Coordination**
136
+
137
+ - Allow multiple agents to operate on shared threads.
138
+ - Use separate collections or namespaces for each.
139
+ - Agents can append or edit messages based on system prompts.
140
+ - Implement an “agent router” that dispatches tasks to specialized agents.
141
+
142
+ ---
143
+
144
+ ### **Task 6: Fault Tolerance**
145
+
146
+ - If client disconnects → background task continues.
147
+ - On error → automatic retry.
148
+ - Support resumable async steps.
149
+ - Logs and metrics are written to `workflows` table.
150
+
151
+ ---
152
+
153
+ ### **Task 7: Developer Ergonomics**
154
+
155
+ - Type-safe schema validation (runtime + compile-time).
156
+ - Type propagation to frontend.
157
+ - Automatic schema validation on deploy (Convex blocks schema mismatch).
158
+
159
+ ---
160
+
161
+ ## 🧠 Key Concepts to Demonstrate
162
+
163
+ | Concept | Description | Implementation |
164
+ | ----------------------------- | -------------------------------------- | ------------------------------------------ |
165
+ | **Reactive DB** | Queries auto-update when data changes | `useQuery`, Convex reactive subscriptions |
166
+ | **Async AI Execution** | LLM runs in background, updates DB | Workflows or background functions |
167
+ | **Optimistic UI** | Frontend updates before LLM response | `optimisticUpdate` pattern |
168
+ | **Durable Tasks** | Retryable, journaled async logic | `convex.workflow` |
169
+ | **Multi-Agent Collaboration** | Several async tasks update same thread | Multiple workflows writing to shared table |
170
+ | **Failure Resilience** | Retries, resumption after failure | Built-in Convex durability |
171
+ | **Real-time UX** | WebSockets auto-sync UI state | Convex reactive queries |
172
+
173
+ ---
174
+
175
+ ## 🧪 Demo Plan
176
+
177
+ 1. Open two browser tabs with same chat thread.
178
+ 2. User A sends a prompt.
179
+ 3. LLM begins generating message asynchronously.
180
+ 4. Both UIs update live (sentence-level streaming).
181
+ 5. User B aborts the generation → both sessions reflect cancellation.
182
+ 6. Task retries automatically if a worker fails.
183
+
184
+ ---
185
+
186
+ ## 🧰 Tech Stack
187
+
188
+ - **Frontend:** React + Convex React hooks + Tailwind + Shadcn
189
+ - **Backend:** Convex TypeScript functions + workflows
190
+ - **LLM API:** OpenAI / Claude / Anthropic SDK
191
+ - **Infra:** Convex hosted runtime
192
+ - **Optional:** Supabase for external analytics or embeddings
193
+
194
+ ---
195
+
196
+ ## 📜 Deliverables
197
+
198
+ - [ ] `convex/schema.ts`
199
+ - [ ] `convex/functions/ai/runAgent.ts`
200
+ - [ ] `convex/functions/messages.ts`
201
+ - [ ] `convex/workflows/agentWorkflow.ts`
202
+ - [ ] React frontend (`Chat.tsx`, `MessageList.tsx`, `MessageInput.tsx`)
203
+ - [ ] Documentation (README.md explaining async architecture)
204
+ - [ ] Demo: two users, reactive streaming, cancel + resume behavior
205
+
206
+ ---
207
+
208
+ ## 🧩 Extension Ideas
209
+
210
+ - Add **agent memory** (embed messages into vector store).
211
+ - Add **tools** (API calling, web search, code execution).
212
+ - Add **multi-threaded reasoning** (agents coordinating across tables).
213
+ - Add **scheduler** for long-running jobs (e.g., every hour).
214
+
215
+ ---
@@ -18,35 +18,40 @@ Transform the current tightly-coupled Astro/React frontend + Convex backend arch
18
18
 
19
19
  ## Ontology Validation
20
20
 
21
- ### ✅ Organizations (Dimension 1)
22
- - Each organization configures `properties.backendProvider`
21
+ ### ✅ Groups (Dimension 1)
22
+ - Each group configures `properties.backendProvider` (optional)
23
23
  - Multi-tenant isolation maintained across all providers
24
- - Organizations can swap providers independently
24
+ - Groups can swap providers independently
25
+ - Hierarchical nesting supported (parent/child groups can use different backends)
25
26
 
26
27
  ### ✅ People (Dimension 2)
27
- - Only `org_owner` role can configure backend providers
28
+ - Only `group_owner` role can configure backend providers
28
29
  - Authorization enforced at backend, not frontend
29
- - All 4 roles work identically across providers
30
+ - All 4 roles work identically across providers (platform_owner, group_owner, group_user, customer)
30
31
 
31
32
  ### ✅ Things (Dimension 3)
32
33
  - New thing type: `external_connection` (backend configurations)
33
34
  - All 66 thing types work through DataProvider interface
34
35
  - Generic ThingService handles all types uniformly
36
+ - Things scoped to groups via `groupId`
35
37
 
36
38
  ### ✅ Connections (Dimension 4)
37
- - New relationship: `configured_by` (org → external_connection)
39
+ - New relationship: `configured_by` (group → external_connection)
38
40
  - Uses consolidated type: `communicated` with protocol metadata
39
41
  - Cross-backend connections supported
42
+ - Connections scoped to groups via `groupId`
40
43
 
41
44
  ### ✅ Events (Dimension 5)
42
45
  - New event: `provider_changed` (when backend swaps)
43
46
  - Uses consolidated type: `communication_event` with protocol metadata
44
47
  - Complete audit trail preserved
48
+ - Events scoped to groups via `groupId`
45
49
 
46
50
  ### ✅ Knowledge (Dimension 6)
47
51
  - Labels: Backend provider capabilities
48
52
  - Tags: `protocol:data_provider`, `provider:convex`, `status:active`
49
53
  - RAG can index provider documentation
54
+ - Knowledge scoped to groups via `groupId`
50
55
 
51
56
  **Verdict:** ✅ PASS - All 6 dimensions successfully mapped
52
57