oneie 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CLAUDE.md +220 -29
  2. package/LICENSE.md +84 -0
  3. package/README.md +489 -931
  4. package/folders.yaml +78 -17
  5. package/one/.obsidian/workspace.json +6 -6
  6. package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +412 -0
  7. package/one/events/FEATURE-2-4-COMPLETE.md +302 -0
  8. package/one/events/FEATURE_2_3_COMPLETE.md +575 -0
  9. package/one/events/GROUPS-MIGRATION.md +625 -0
  10. package/one/events/INSTALL-TESTS.md +293 -0
  11. package/one/events/INTEGRATION-ARCHITECTURE.md +561 -0
  12. package/one/events/INTEGRATION-CHECKLIST.md +1234 -0
  13. package/one/events/INTEGRATION-ORCHESTRATION.md +2623 -0
  14. package/one/events/INTEGRATION-SUMMARY.md +653 -0
  15. package/one/events/MIGRATION-REPORT.md +435 -0
  16. package/one/events/MIGRATION.md +69 -0
  17. package/one/events/README-archived.md +519 -0
  18. package/one/events/TEST-SUMMARY.md +393 -0
  19. package/one/events/TESTS-QUICK-REF.md +262 -0
  20. package/one/groups/groups.md +543 -0
  21. package/one/knowledge/CLOUDFLARE_ENV_SETUP.md +49 -0
  22. package/one/knowledge/architecture-any-backend.md +1366 -0
  23. package/one/knowledge/docs/flow.md +0 -0
  24. package/one/knowledge/ontology-documentation.md +18 -18
  25. package/one/knowledge/ontology.md +154 -143
  26. package/one/knowledge/ontology.md.backup +2822 -0
  27. package/one/knowledge/ontology.yaml +87 -87
  28. package/one/knowledge/provider-creation-guide.md +1064 -0
  29. package/one/knowledge/todo.md +251 -0
  30. package/one/license.md +84 -0
  31. package/one/things/CHECKLIST.md +356 -0
  32. package/one/things/ONE.md +510 -0
  33. package/one/things/{cli.md → cli/cli.md} +27 -4
  34. package/one/things/features/2-1-dataprovider-interface.md +2358 -0
  35. package/one/things/features/2-2-config-system.md +3075 -0
  36. package/one/things/features/2-3-effectts-services.md +1498 -0
  37. package/one/things/features/2-4-react-hooks.md +2120 -0
  38. package/one/things/features/2-5-auth-migration.md +2046 -0
  39. package/one/things/features/2-6-dashboard-migration.md +1985 -0
  40. package/one/things/features/2-7-alternative-providers.md +2505 -0
  41. package/one/things/features/2-7-implementation-report.md +680 -0
  42. package/one/things/features/2-cli.md +39 -39
  43. package/one/things/features/2-design.md +1738 -0
  44. package/one/things/features/2-tests.md +520 -0
  45. package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +521 -0
  46. package/one/things/features/DECOUPLING.md +272 -0
  47. package/one/things/features/DEPLOYMENT.md +452 -0
  48. package/one/things/features/IMPLEMENTATION_SUMMARY.md +316 -0
  49. package/one/things/features/dataprovider-interface/1-tests.md +1522 -0
  50. package/one/things/features/improve.md +843 -0
  51. package/one/things/features/remove-convex-deps.md +45 -0
  52. package/one/things/features/top-features.md +79 -0
  53. package/one/things/ideas/2-backend-agnostic-frontend.md +384 -0
  54. package/one/things/plans/2-backend-agnostic-frontend.md +543 -0
  55. package/one/things/plans/3-groups.md +502 -0
  56. package/one/things/plans/backend-agnostic-frontend.md +323 -0
  57. package/one/things/plans/deploy-to-cloudflare.md +581 -0
  58. package/one/things/plans/organizations-to-groups.md +705 -0
  59. package/one/things/plans/release.md +432 -0
  60. package/one/things/products/ontology.md +1 -1
  61. package/one/things/system.md +600 -0
  62. package/one/things/tests/2-1-dataprovider-interface.md +1144 -0
  63. package/one/things/tests/2-1-test-analysis.md +496 -0
  64. package/one/things/vision/elegant-interface.md +214 -0
  65. package/package.json +1 -1
  66. package/one/organisation/organisation.md +0 -438
  67. package/one/repomix-output.md +0 -92634
  68. /package/one/{things → connections}/agentkit.md +0 -0
  69. /package/one/{things → connections}/copilotkit.md +0 -0
  70. /package/one/{organisation → groups}/one.md +0 -0
  71. /package/one/{organisation → groups}/revenue.md +0 -0
  72. /package/one/{organisation → groups}/strategy.md +0 -0
  73. /package/one/{organisation → groups}/vision.md +0 -0
  74. /package/one/things/{cli-code.md → cli/cli-code.md} +0 -0
  75. /package/one/things/{cli-compiler-code.md → cli/cli-compiler-code.md} +0 -0
@@ -1,438 +0,0 @@
1
- # Organisation: Multi-Tenant Platform Structure
2
-
3
- **Organizations are the isolation boundary for multi-tenancy in the ONE Platform.**
4
-
5
- For details on the ONE organization (vision, strategy, revenue), see **[ONE Organization →](./one.md)**
6
-
7
- ## Overview
8
-
9
- The ONE Platform operates as a multi-tenant system where:
10
- - **Platform Owner (Anthony)** owns the infrastructure and smart contracts (100%)
11
- - **Organizations** are tenant containers for resources and users
12
- - **Org Owners** manage their organizations and members
13
- - **Org Users** have scoped access to organization resources
14
-
15
- ## Thing Type: `organization`
16
-
17
- **Properties Structure:**
18
- ```typescript
19
- {
20
- type: "organization",
21
- name: string,
22
- properties: {
23
- // Identity
24
- slug: string, // URL-friendly (e.g., "acme")
25
- domain?: string, // Custom domain (e.g., "acme.one.ie")
26
- logo?: string,
27
- description?: string,
28
-
29
- // Status & Plan
30
- status: "active" | "suspended" | "trial" | "cancelled",
31
- plan: "starter" | "pro" | "enterprise",
32
-
33
- // Limits & Usage
34
- limits: {
35
- users: number,
36
- storage: number, // GB
37
- apiCalls: number, // Per month
38
- inferences: number, // Per month (NEW)
39
- },
40
- usage: {
41
- users: number,
42
- storage: number,
43
- apiCalls: number,
44
- inferences: number, // (NEW)
45
- },
46
-
47
- // Billing
48
- billing: {
49
- customerId?: string, // Stripe customer ID
50
- subscriptionId?: string,
51
- currentPeriodEnd?: number,
52
- // Blockchain billing (NEW)
53
- cryptoEnabled: boolean,
54
- treasuryAddress?: {
55
- sui?: string,
56
- solana?: string,
57
- base?: string,
58
- },
59
- },
60
-
61
- // Settings
62
- settings: {
63
- allowSignups: boolean,
64
- requireEmailVerification: boolean,
65
- enableTwoFactor: boolean,
66
- allowedDomains?: string[],
67
- // Inference settings (NEW)
68
- inferenceEnabled: boolean,
69
- inferenceModels: string[], // ["gpt-4", "claude-3.5", "llama-3"]
70
- },
71
-
72
- // Revenue share (if org generates platform revenue)
73
- revenueShare?: number, // 0.0 to 1.0 (0 = platform keeps all)
74
-
75
- createdAt: number,
76
- trialEndsAt?: number,
77
- },
78
- status: "active",
79
- }
80
- ```
81
-
82
- ## Core Relationships (Connections)
83
-
84
- **Membership:** `creator` → `organization` via `member_of`
85
- - `metadata.role`: `"org_owner"` | `"org_user"`
86
- - `metadata.permissions`: Array of permission strings
87
-
88
- **Ownership:** `creator` → `organization` via `owns`
89
- - Platform owner (Anthony) owns the ONE organization at 100%
90
- - Org owners may own their organizations
91
-
92
- **Resource Ownership:** `organization` → resources via `owns`
93
- - Content, workflows, tokens, products, websites
94
- - All org resources link back to org via ownership connection
95
-
96
- ## Core Events
97
-
98
- **Organization Lifecycle:**
99
- - `organization_created` - When organization is created
100
- - `organization_updated` - Settings, plan, or limits changed
101
- - `user_invited_to_org` - Invitation sent
102
- - `user_joined_org` - User accepts invitation
103
- - `user_removed_from_org` - User removed from org
104
-
105
- **Billing Events:**
106
- - `payment_event` - Subscription payments (Stripe or crypto)
107
- - `subscription_event` - Plan changes (starter → pro → enterprise)
108
-
109
- **Inference Events (NEW):**
110
- - `inference_request` - Org member requests inference
111
- - `inference_completed` - Result delivered
112
- - `inference_quota_exceeded` - Monthly limit hit
113
-
114
- **Revenue Events (NEW):**
115
- - `org_revenue_generated` - When org's activity generates platform revenue
116
- - `revenue_share_distributed` - If org has revenue share agreement
117
-
118
- ## Code Examples
119
-
120
- ### Create ONE Platform Organization (Anthony's)
121
-
122
- ```typescript
123
- // Create the ONE organization (owned by Anthony)
124
- const oneOrgId = await db.insert("entities", {
125
- type: "organization",
126
- name: "ONE Platform",
127
- properties: {
128
- slug: "one",
129
- domain: "one.ie",
130
- status: "active",
131
- plan: "enterprise",
132
- limits: {
133
- users: 1000000, // Unlimited for platform
134
- storage: 1000000, // 1PB
135
- apiCalls: -1, // Unlimited
136
- inferences: -1, // Unlimited
137
- },
138
- usage: {
139
- users: 0,
140
- storage: 0,
141
- apiCalls: 0,
142
- inferences: 0,
143
- },
144
- billing: {
145
- cryptoEnabled: true,
146
- treasuryAddress: {
147
- sui: process.env.PLATFORM_TREASURY_SUI,
148
- solana: process.env.PLATFORM_TREASURY_SOLANA,
149
- base: process.env.PLATFORM_TREASURY_BASE,
150
- },
151
- },
152
- settings: {
153
- allowSignups: true,
154
- requireEmailVerification: true,
155
- enableTwoFactor: true,
156
- inferenceEnabled: true,
157
- inferenceModels: ["gpt-4", "claude-3.5", "llama-3"],
158
- },
159
- revenueShare: 0, // Anthony keeps 100% of revenue
160
- },
161
- status: "active",
162
- createdAt: Date.now(),
163
- updatedAt: Date.now(),
164
- });
165
-
166
- // Anthony owns the ONE organization (100%)
167
- await db.insert("connections", {
168
- fromThingId: anthonyId,
169
- toThingId: oneOrgId,
170
- relationshipType: "owns",
171
- metadata: {
172
- ownershipPercentage: 100,
173
- },
174
- createdAt: Date.now(),
175
- });
176
-
177
- // Anthony is also a member with org_owner role
178
- await db.insert("connections", {
179
- fromThingId: anthonyId,
180
- toThingId: oneOrgId,
181
- relationshipType: "member_of",
182
- metadata: {
183
- role: "org_owner",
184
- permissions: ["*"], // All permissions
185
- },
186
- createdAt: Date.now(),
187
- });
188
-
189
- // Log creation event
190
- await ctx.db.insert("events", {
191
- eventType: "organization_created",
192
- actorId: anthonyId,
193
- targetId: oneOrgId,
194
- timestamp: Date.now(),
195
- metadata: {
196
- name: "ONE Platform",
197
- slug: "one",
198
- plan: "enterprise",
199
- },
200
- });
201
- ```
202
-
203
- ### Create Customer Organization (Multi-Tenant)
204
-
205
- ```typescript
206
- // Customer creates their own organization
207
- const customerOrgId = await db.insert("entities", {
208
- type: "organization",
209
- name: "Acme Corp",
210
- properties: {
211
- slug: "acme",
212
- domain: "acme.one.ie",
213
- plan: "pro",
214
- limits: {
215
- users: 50,
216
- storage: 100, // GB
217
- apiCalls: 100000,
218
- inferences: 10000, // 10K inferences/month
219
- },
220
- usage: {
221
- users: 0,
222
- storage: 0,
223
- apiCalls: 0,
224
- inferences: 0,
225
- },
226
- billing: {
227
- customerId: "cus_stripe123",
228
- subscriptionId: "sub_stripe456",
229
- cryptoEnabled: false,
230
- },
231
- settings: {
232
- allowSignups: false,
233
- requireEmailVerification: true,
234
- enableTwoFactor: false,
235
- inferenceEnabled: true,
236
- inferenceModels: ["gpt-4", "claude-3.5"],
237
- },
238
- revenueShare: 0.1, // Customer gets 10% revenue share if they refer users
239
- },
240
- status: "active",
241
- createdAt: Date.now(),
242
- updatedAt: Date.now(),
243
- });
244
-
245
- // Customer is org_owner
246
- await db.insert("connections", {
247
- fromThingId: customerId,
248
- toThingId: customerOrgId,
249
- relationshipType: "member_of",
250
- metadata: {
251
- role: "org_owner",
252
- permissions: ["read", "write", "admin", "billing"],
253
- },
254
- createdAt: Date.now(),
255
- });
256
- ```
257
-
258
- ### Track Organization Inference Usage
259
-
260
- ```typescript
261
- // User in org requests inference
262
- await ctx.db.insert("events", {
263
- eventType: "inference_request",
264
- actorId: userId,
265
- targetId: inferenceRequestId,
266
- timestamp: Date.now(),
267
- metadata: {
268
- organizationId: customerOrgId,
269
- model: "gpt-4",
270
- cost: 0.045,
271
- price: 0.10,
272
- },
273
- });
274
-
275
- // Update org usage
276
- const org = await db.get(customerOrgId);
277
- await db.patch(customerOrgId, {
278
- properties: {
279
- ...org.properties,
280
- usage: {
281
- ...org.properties.usage,
282
- inferences: org.properties.usage.inferences + 1,
283
- },
284
- },
285
- updatedAt: Date.now(),
286
- });
287
-
288
- // Check if quota exceeded
289
- if (org.properties.usage.inferences >= org.properties.limits.inferences) {
290
- await ctx.db.insert("events", {
291
- eventType: "inference_quota_exceeded",
292
- actorId: "system",
293
- targetId: customerOrgId,
294
- timestamp: Date.now(),
295
- metadata: {
296
- limit: org.properties.limits.inferences,
297
- usage: org.properties.usage.inferences,
298
- },
299
- });
300
- }
301
- ```
302
-
303
- ### Revenue Share Distribution
304
-
305
- ```typescript
306
- // When customer org generates platform revenue
307
- await ctx.db.insert("events", {
308
- eventType: "org_revenue_generated",
309
- actorId: customerOrgId,
310
- targetId: anthonyId, // Platform owner
311
- timestamp: Date.now(),
312
- metadata: {
313
- totalRevenue: 1000.00, // $1K generated by org
314
- orgShare: 100.00, // 10% to org
315
- platformShare: 900.00, // 90% to Anthony
316
- revenueSharePercentage: 0.1,
317
- },
318
- });
319
-
320
- // Distribute revenue share (if configured)
321
- if (org.properties.revenueShare > 0) {
322
- await ctx.db.insert("events", {
323
- eventType: "revenue_share_distributed",
324
- actorId: anthonyId,
325
- targetId: customerId,
326
- timestamp: Date.now(),
327
- metadata: {
328
- amount: 100.00,
329
- percentage: 0.1,
330
- network: "sui",
331
- txDigest: "...",
332
- },
333
- });
334
- }
335
- ```
336
-
337
- ## Queries
338
-
339
- **List organization members:**
340
- ```typescript
341
- const members = await db
342
- .query("connections")
343
- .withIndex("to_type", q =>
344
- q.eq("toThingId", organizationId)
345
- .eq("relationshipType", "member_of")
346
- )
347
- .collect();
348
-
349
- const memberEntities = await Promise.all(
350
- members.map(m => db.get(m.fromThingId))
351
- );
352
- ```
353
-
354
- **List organization resources:**
355
- ```typescript
356
- const resources = await db
357
- .query("connections")
358
- .withIndex("from_type", q =>
359
- q.eq("fromThingId", organizationId)
360
- .eq("relationshipType", "owns")
361
- )
362
- .collect();
363
- ```
364
-
365
- **Get organization inference usage:**
366
- ```typescript
367
- const org = await db.get(organizationId);
368
- const usage = org.properties.usage.inferences;
369
- const limit = org.properties.limits.inferences;
370
- const percentageUsed = (usage / limit) * 100;
371
- ```
372
-
373
- **Recent organization activity:**
374
- ```typescript
375
- const events = await db
376
- .query("events")
377
- .withIndex("type_time", q => q.eq("targetId", organizationId))
378
- .order("desc")
379
- .take(100)
380
- .collect();
381
- ```
382
-
383
- **Calculate organization revenue (for revenue share):**
384
- ```typescript
385
- const revenueEvents = await db
386
- .query("events")
387
- .withIndex("type_time", q =>
388
- q.eq("type", "org_revenue_generated")
389
- )
390
- .filter(q => q.eq(q.field("actorId"), organizationId))
391
- .collect();
392
-
393
- const totalRevenue = revenueEvents.reduce(
394
- (sum, e) => sum + e.metadata.totalRevenue,
395
- 0
396
- );
397
- const orgShare = revenueEvents.reduce(
398
- (sum, e) => sum + e.metadata.orgShare,
399
- 0
400
- );
401
- ```
402
-
403
- ## Multi-Tenant Isolation
404
-
405
- **Access Control Pattern:**
406
- ```typescript
407
- // Check if user can access org resource
408
- export const canAccess = async (
409
- userId: Id<"entities">,
410
- organizationId: Id<"entities">,
411
- requiredPermission: string
412
- ) => {
413
- const membership = await db
414
- .query("connections")
415
- .withIndex("from_type", q =>
416
- q.eq("fromThingId", userId)
417
- .eq("toThingId", organizationId)
418
- .eq("relationshipType", "member_of")
419
- )
420
- .first();
421
-
422
- if (!membership) return false;
423
-
424
- const permissions = membership.metadata.permissions || [];
425
- return permissions.includes("*") || permissions.includes(requiredPermission);
426
- };
427
- ```
428
-
429
- ## Notes
430
-
431
- - **Platform Owner (Anthony)** - Owns ONE organization at 100%, receives all platform revenue
432
- - **Multi-tenant** - Each organization isolated via membership connections
433
- - **Protocol-agnostic** - Blockchain interactions via `metadata.network`
434
- - **Inference quotas** - Monthly limits enforced per organization
435
- - **Revenue share** - Optional revenue split for referring orgs (configurable 0-100%)
436
- - **Blockchain billing** - Organizations can pay via crypto (SUI/Solana/Base)
437
- - **Usage tracking** - All inference/API usage tracked in org properties
438
- - **Event history** - Complete audit trail of org activity