@mindstudio-ai/agent 0.1.6 → 0.1.9
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/README.md +35 -0
- package/dist/cli.js +1960 -253
- package/dist/index.d.ts +1274 -100
- package/dist/index.js +1719 -24
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +1960 -253
- package/llms.txt +53 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -334,6 +334,37 @@ await agent.generateText({ message: 'My name is Alice' }); // creates a thread
|
|
|
334
334
|
await agent.generateText({ message: 'What is my name?' }); // reuses it automatically
|
|
335
335
|
```
|
|
336
336
|
|
|
337
|
+
## Managed databases and auth
|
|
338
|
+
|
|
339
|
+
When running inside a MindStudio app (managed mode), the SDK provides `db`, `auth`, and `resolveUser` for working with the app's managed SQLite databases and role-based access control. These are available as top-level imports:
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
import { db, auth, Roles, resolveUser, User } from '@mindstudio-ai/agent';
|
|
343
|
+
|
|
344
|
+
// Define a typed table
|
|
345
|
+
const Orders = db.defineTable<Order>('orders');
|
|
346
|
+
|
|
347
|
+
// Query with a chainable API
|
|
348
|
+
const pending = await Orders
|
|
349
|
+
.filter(o => o.status === 'pending')
|
|
350
|
+
.sortBy(o => o.createdAt)
|
|
351
|
+
.reverse()
|
|
352
|
+
.take(20);
|
|
353
|
+
|
|
354
|
+
// Write
|
|
355
|
+
const order = await Orders.push({ item: 'Laptop', amount: 999, status: 'pending' });
|
|
356
|
+
await Orders.update(order.id, { status: 'approved' });
|
|
357
|
+
|
|
358
|
+
// Role-based access control
|
|
359
|
+
auth.requireRole(Roles.admin);
|
|
360
|
+
const admins = auth.getUsersByRole(Roles.admin);
|
|
361
|
+
|
|
362
|
+
// Resolve user display info
|
|
363
|
+
const user = await resolveUser(order.requestedBy);
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
See `src/db/README.md` and `src/auth/README.md` for the full API reference.
|
|
367
|
+
|
|
337
368
|
## Configuration
|
|
338
369
|
|
|
339
370
|
```typescript
|
|
@@ -351,6 +382,10 @@ const agent = new MindStudioAgent({
|
|
|
351
382
|
// Auto-reuse the first returned thread ID for all subsequent calls (default: false)
|
|
352
383
|
// Or set MINDSTUDIO_REUSE_THREAD_ID=true env var
|
|
353
384
|
reuseThreadId: true,
|
|
385
|
+
|
|
386
|
+
// App ID for managed database/auth context (managed mode only)
|
|
387
|
+
// Or set MINDSTUDIO_APP_ID env var. Auto-detected in sandbox.
|
|
388
|
+
appId: 'your-app-id',
|
|
354
389
|
});
|
|
355
390
|
```
|
|
356
391
|
|