@mindstudio-ai/remy 0.1.333 → 0.1.334
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/headless.js +258 -268
- package/dist/index.js +206 -204
- package/dist/prompt/skills/auth.md +1 -0
- package/dist/prompt/skills/scenarios.md +13 -3
- package/package.json +1 -1
|
@@ -100,6 +100,7 @@ export const Users = db.defineTable<{
|
|
|
100
100
|
|
|
101
101
|
### Platform-Managed Column Behavior
|
|
102
102
|
|
|
103
|
+
- **`id`** — the platform-assigned managed-user UUID. Omit it on every insert (`Users.push({ email, ... })`) and let it default; never hand-write one (`id: 'analyst-test'`, etc.). A non-UUID id can't map to the platform user record — it silently never syncs and orphans the row. Reference a user by the id returned from `Users.push(...)`, never a made-up string. (This is the trap scenario seeds fall into — see the `scenarios` skill.)
|
|
103
104
|
- **`email` / `phone` / `apiKey`** — read-only from code. Writing via `update()` or `push()` throws a `MindStudioError`. Use the auth API to change a user's email or phone, and `auth.createApiKey()` / `auth.revokeApiKey()` for API keys.
|
|
104
105
|
- **`roles`** — read/write from both code and the dashboard. `Users.update(userId, { roles: ['admin'] })` works and syncs to the platform. Dashboard role changes sync back to the table.
|
|
105
106
|
- All other columns are fully the developer's. When auth creates a user row, only the managed columns (email/phone, roles) are populated. All user-defined columns start as null until the user completes onboarding — type them as optional and guard against null.
|
|
@@ -52,11 +52,20 @@ Scenarios live at `dist/methods/.scenarios/` — inside the methods package scop
|
|
|
52
52
|
// dist/methods/.scenarios/apOverdueInvoices.ts
|
|
53
53
|
|
|
54
54
|
import { db } from '@mindstudio-ai/agent';
|
|
55
|
+
import { Users } from '../src/tables/users';
|
|
55
56
|
import { Vendors } from '../src/tables/vendors';
|
|
56
57
|
import { PurchaseOrders } from '../src/tables/purchase-orders';
|
|
57
58
|
import { Invoices } from '../src/tables/invoices';
|
|
58
59
|
|
|
59
60
|
export async function apOverdueInvoices() {
|
|
61
|
+
// Seed an app user through the auth-mapped table. Never set `id` — omit it so
|
|
62
|
+
// the platform assigns the UUID that maps this row to its managed user. A
|
|
63
|
+
// hand-written id ('user-requester-1', etc.) can't sync and orphans the row.
|
|
64
|
+
const requester = await Users.push({
|
|
65
|
+
email: 'jordan@example.com',
|
|
66
|
+
roles: ['requester'],
|
|
67
|
+
});
|
|
68
|
+
|
|
60
69
|
const vendor = await Vendors.push({
|
|
61
70
|
name: 'Acme Corp',
|
|
62
71
|
contactEmail: 'billing@acme.com',
|
|
@@ -65,7 +74,7 @@ export async function apOverdueInvoices() {
|
|
|
65
74
|
|
|
66
75
|
const po = await PurchaseOrders.push({
|
|
67
76
|
vendorId: vendor.id,
|
|
68
|
-
requestedBy:
|
|
77
|
+
requestedBy: requester.id,
|
|
69
78
|
totalAmountCents: 500000,
|
|
70
79
|
status: 'active',
|
|
71
80
|
});
|
|
@@ -93,7 +102,8 @@ An empty scenario is valid — it exists so you can switch to "clean slate" stat
|
|
|
93
102
|
|
|
94
103
|
```typescript
|
|
95
104
|
export async function emptyRequester() {
|
|
96
|
-
// No data — the truncate clears
|
|
105
|
+
// No data — the truncate clears every table (the auth users table aside,
|
|
106
|
+
// whose real accounts are preserved).
|
|
97
107
|
}
|
|
98
108
|
```
|
|
99
109
|
|
|
@@ -102,7 +112,7 @@ Shared setup code can go in `dist/methods/.scenarios/_helpers/`.
|
|
|
102
112
|
## How Scenarios Run
|
|
103
113
|
|
|
104
114
|
When a scenario runs, the platform:
|
|
105
|
-
1. **Truncates** all tables (deletes all rows, preserves schema - unless skipTruncate is true)
|
|
115
|
+
1. **Truncates** all tables (deletes all rows, preserves schema - unless skipTruncate is true). The auth-mapped users table is the exception — it's preserved, because its rows are real app accounts mirrored to the platform, so a reseed must never delete them. Seed users additively with `Users.push(...)` (id omitted); they persist across reseeds.
|
|
106
116
|
2. **Executes** the seed function (your `db.push()` calls populate the clean database)
|
|
107
117
|
3. **Assigns** the roles from the scenario's `roles` field to the dev test user — a real write to that user's row, so it requires app auth to be enabled
|
|
108
118
|
|