mindsim 0.1.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 (79) hide show
  1. package/.github/workflows/publish.yml +32 -0
  2. package/.github/workflows/test.yml +28 -0
  3. package/.github/workflows/type-checks.yml +29 -0
  4. package/LICENSE +21 -0
  5. package/README.md +748 -0
  6. package/assets/mindsim-logo.svg +15 -0
  7. package/biome.jsonc +43 -0
  8. package/dist/auth.d.ts +5 -0
  9. package/dist/auth.d.ts.map +1 -0
  10. package/dist/auth.js +115 -0
  11. package/dist/auth.js.map +1 -0
  12. package/dist/cli.d.ts +3 -0
  13. package/dist/cli.d.ts.map +1 -0
  14. package/dist/cli.js +36 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/config.d.ts +8 -0
  17. package/dist/config.d.ts.map +1 -0
  18. package/dist/config.js +63 -0
  19. package/dist/config.js.map +1 -0
  20. package/dist/index.d.ts +20 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +71 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/resources/artifacts.d.ts +8 -0
  25. package/dist/resources/artifacts.d.ts.map +1 -0
  26. package/dist/resources/artifacts.js +17 -0
  27. package/dist/resources/artifacts.js.map +1 -0
  28. package/dist/resources/minds.d.ts +39 -0
  29. package/dist/resources/minds.d.ts.map +1 -0
  30. package/dist/resources/minds.js +85 -0
  31. package/dist/resources/minds.js.map +1 -0
  32. package/dist/resources/psychometrics.d.ts +11 -0
  33. package/dist/resources/psychometrics.d.ts.map +1 -0
  34. package/dist/resources/psychometrics.js +18 -0
  35. package/dist/resources/psychometrics.js.map +1 -0
  36. package/dist/resources/simulations.d.ts +26 -0
  37. package/dist/resources/simulations.d.ts.map +1 -0
  38. package/dist/resources/simulations.js +41 -0
  39. package/dist/resources/simulations.js.map +1 -0
  40. package/dist/resources/snapshots.d.ts +27 -0
  41. package/dist/resources/snapshots.d.ts.map +1 -0
  42. package/dist/resources/snapshots.js +101 -0
  43. package/dist/resources/snapshots.js.map +1 -0
  44. package/dist/resources/tags.d.ts +23 -0
  45. package/dist/resources/tags.d.ts.map +1 -0
  46. package/dist/resources/tags.js +32 -0
  47. package/dist/resources/tags.js.map +1 -0
  48. package/dist/types.d.ts +161 -0
  49. package/dist/types.d.ts.map +1 -0
  50. package/dist/types.js +3 -0
  51. package/dist/types.js.map +1 -0
  52. package/dist/version.d.ts +15 -0
  53. package/dist/version.d.ts.map +1 -0
  54. package/dist/version.js +105 -0
  55. package/dist/version.js.map +1 -0
  56. package/package.json +55 -0
  57. package/src/auth.ts +131 -0
  58. package/src/cli.ts +41 -0
  59. package/src/config.ts +60 -0
  60. package/src/index.ts +59 -0
  61. package/src/resources/artifacts.ts +13 -0
  62. package/src/resources/minds.ts +98 -0
  63. package/src/resources/psychometrics.ts +16 -0
  64. package/src/resources/simulations.ts +49 -0
  65. package/src/resources/snapshots.ts +126 -0
  66. package/src/resources/tags.ts +30 -0
  67. package/src/types.ts +185 -0
  68. package/src/version.ts +111 -0
  69. package/tests/auth.test.ts +41 -0
  70. package/tests/config.test.ts +129 -0
  71. package/tests/resources/minds.test.ts +119 -0
  72. package/tests/resources/psychometrics.test.ts +38 -0
  73. package/tests/resources/simulation.test.ts +94 -0
  74. package/tests/resources/snapshots.test.ts +135 -0
  75. package/tests/resources/tags.test.ts +87 -0
  76. package/tests/use-cases/quickstart.test.ts +84 -0
  77. package/tests/version.test.ts +221 -0
  78. package/tsconfig.json +29 -0
  79. package/vitest.config.ts +12 -0
package/README.md ADDED
@@ -0,0 +1,748 @@
1
+ <br/>
2
+ <br/>
3
+ <div align="center">
4
+ <img style="display: block; width: 250px;" src="assets/mindsim-logo.svg"/>
5
+ </div>
6
+ <br/>
7
+ <br/>
8
+ <br/>
9
+
10
+ # mindsim-sdk-typescript
11
+ The official MindSim typescript SDK allows you to programmatically create digital minds, populate them with conversational data, and run powerful simulations to get an accurate preview of how the person will think, feel, say, and act in any scenario.
12
+
13
+ Refer to our technical [documentation](https://docs.workflows.com/) to learn more about how to use MinSim.
14
+
15
+
16
+ ## 📦 Installation
17
+ Pre-requisites before installation
18
+ - Node.js version 24 or higher
19
+ - macOS, Linux, or Windows
20
+
21
+
22
+ ### Install with NPM
23
+ ```
24
+ npm install -g @mindsim/mindsim-sdk-typescript
25
+ ```
26
+
27
+
28
+ ## 🔐 Authentication
29
+
30
+ The mindsim SDK provides several ways for you to authenticate:
31
+
32
+ ### 1. Using `mindsim auth`
33
+ - Ideal for local development and when you're exploring the possibilities of MindSim and how to integrate the MindSim SDK into your workflows
34
+
35
+ Example:
36
+ ```
37
+ mindsim auth
38
+ ```
39
+
40
+ Then follow the prompts to complete the authentication process.
41
+
42
+ ### 2. Using environment variables
43
+ - Ideal for deployment scenarios, e.g. CI/CD or in your production applications
44
+ - Set the environment variable `MINDSIM_API_KEY`
45
+
46
+ Example:
47
+ ```bash
48
+ export MINDSIM_API_KEY=<your-api-key>
49
+ ```
50
+
51
+
52
+ ### 3. Passed to the constructor
53
+ - Ideal for deployment scenarios where secrets are retrieved from a secrets manager at runtime
54
+
55
+ Example:
56
+ ```typescript
57
+ const apiKey = await secrets.load('mindsim_api_key');
58
+ const mindsim = MindSim(apiKey);
59
+ ```
60
+
61
+
62
+ ## 💡 Quick Start Guide
63
+
64
+ ### Build a Mind
65
+
66
+ The following example shows how you can use the mindsim SDK to create a mind:
67
+
68
+ ```typescript
69
+ import { MindSim } from "@mindsim/mindsim-sdk-typescript";
70
+ import fs from "node:fs";
71
+ import path from "node:path";
72
+
73
+ const main = async () => {
74
+ // 1. Instantiate a MindSim client
75
+ // Ensure you've run `mindsim auth` or MINDSIM_API_KEY is set in env or pass it explicitly
76
+ const mindsim = new MindSim();
77
+
78
+ try {
79
+ // 2. Create a mind for Bobby Tables
80
+ const bobby = await mindsim.minds.create({
81
+ name: "Bobby Tables",
82
+ email: "bobby@test.com",
83
+ tags: ["developer"],
84
+ });
85
+
86
+ console.log(`Created Mind: ${bobby.name} (ID: ${bobby.id})`);
87
+
88
+ // List of files to process
89
+ const filePaths = [
90
+ "./data/chat-history.pdf",
91
+ "./data/transcript.vtt",
92
+ "./data/diarized.json"
93
+ ];
94
+
95
+ // 3. Create snapshots for all file
96
+ await Promise.all(
97
+ filePaths.map(async (filePath) => {
98
+ const fileBuffer = fs.readFileSync(filePath);
99
+ const fileName = path.basename(filePath);
100
+
101
+ const response = await mindsim.snapshots.create(bobby.id, {
102
+ file: fileBuffer,
103
+ fileName: fileName,
104
+ });
105
+
106
+ // 4. Log status
107
+ const status = await mindsim.snapshots.getStatus(
108
+ bobby.id,
109
+ response.mindAssessmentId
110
+ );
111
+
112
+ console.log(`File: ${fileName} | Status: ${status.status}`);
113
+ })
114
+ );
115
+
116
+ console.log("All snapshots processed.");
117
+
118
+ } catch (error) {
119
+ console.error("Error running MindSim workflow:", error);
120
+ }
121
+ };
122
+
123
+ main();
124
+ ```
125
+
126
+ ### Run Simulations
127
+
128
+ When MindSim has finished building your mind, you can run simulations on your mind:
129
+
130
+ ```typescript
131
+ import { MindSim } from "@mindsim/mindsim-sdk-typescript";
132
+
133
+ const main = async () => {
134
+ const mindsim = new MindSim(process.env.MINDSIM_API_KEY);
135
+
136
+ // Existing IDs (e.g., retrieved from database or previous API calls)
137
+ const mindId = "bobby-tables-id";
138
+ const snapshotId = "snapshot-123-id";
139
+
140
+ try {
141
+ // 1. Check the status of the snapshot
142
+ const snapshot = await mindsim.snapshots.getStatus(mindId, snapshotId);
143
+
144
+ console.log(`Current Snapshot Status: ${snapshot.status}`);
145
+
146
+ switch (snapshot.status) {
147
+ case "failed":
148
+ console.error("Error: The snapshot failed to process. Please check file validity.");
149
+ break;
150
+
151
+ case "processing":
152
+ console.log("Snapshot is still processing. Cannot run simulation yet.");
153
+ break;
154
+
155
+ case "completed":
156
+ console.log("Snapshot ready. Initiating simulation...");
157
+
158
+ // 2. Run the simulation
159
+ const simulation = await mindsim.simulations.run({
160
+ mindId: mindId,
161
+ scenario: {
162
+ message: "Hey Bobby, I want to merge this PR. What should I include in my PR to maximize the likelihood that you'll accept my changes into the main branch?",
163
+ },
164
+ });
165
+
166
+ console.log("Simulation Response:", simulation.message);
167
+ break;
168
+
169
+ default:
170
+ console.log(`Unknown status: ${snapshot.status}`);
171
+ }
172
+ } catch (error) {
173
+ console.error("An error occurred:", error);
174
+ }
175
+ };
176
+
177
+ main();
178
+ ```
179
+
180
+
181
+ ## ⚡ Features
182
+
183
+ ### Create Minds
184
+ A mind is a container that represents a person. Think of it as a digital profile.
185
+
186
+ **What it does**
187
+ - *Stores conversation transcripts* — Upload and manage training data
188
+ - *Holds metadata* — Name, creation date, and configuration
189
+ - *Creates snapshots* — Generate multiple AI models over time as data evolves
190
+
191
+ Minds are the foundation of MindSim. Each mind represents one person and can have unlimited snapshots trained from different datasets or time periods.
192
+
193
+ #### Examples
194
+
195
+ Create a mind
196
+
197
+ ```typescript
198
+ const newMind = await mindsim.minds.create({
199
+ name: "Sarah Connor",
200
+ email: "sarah@resistance.org",
201
+ tags: ["leader", "target"]
202
+ });
203
+
204
+ console.log(newMind);
205
+ ```
206
+ Response:
207
+ ```json
208
+ {
209
+ "id": "ac8ac8c4-05e9-4046-a919-4cbae2f49f22",
210
+ "name": "Sarah Connor",
211
+ "email": "sarah@resistance.org",
212
+ "slug": "sarah-connor",
213
+ "scope": "private",
214
+ "isSelf": false,
215
+ "organizationId": "961b1800-6bd2-444c-8bfa-8dd82b5e80f3",
216
+ "createdAt": "2023-10-27T10:00:00Z",
217
+ "updatedAt": "2023-10-27T10:00:00Z",
218
+ "tags": [
219
+ { "id": "56255954-189f-4a1e-a355-08a1704af943", "name": "leader" },
220
+ { "id": "e4d98950-0556-40da-95c8-7de77b3dcbb0", "name": "target" }
221
+ ]
222
+ }
223
+ ```
224
+ ---
225
+ List Minds
226
+
227
+ You can filter the list by passing an array of tag names.
228
+ ```typescript
229
+ const developers = await mindsim.minds.list({
230
+ tags: ["developer", "typescript"], // Passed as an array of strings
231
+ });
232
+
233
+ console.log(developers);
234
+ ```
235
+
236
+ Response:
237
+ ```json
238
+ [
239
+ {
240
+ "id": "779e640c-67c2-44e5-bc91-b3b43eeaead8",
241
+ "name": "Bobby Tables",
242
+ "email": "bobby@test.com",
243
+ "scope": "public",
244
+ "isSelf": false,
245
+ "tags": [
246
+ { "id": "e40059db-6bf4-4ef7-ab5b-65ab8610c628", "name": "developer" },
247
+ { "id": "10eeabd7-96ba-487b-a1e9-2e22957f8536", "name": "typescript" }
248
+ ]
249
+ },
250
+ {
251
+ "id": "368fcac9-27d8-4cc1-b479-5b9601110086",
252
+ "name": "Grace Hopper",
253
+ "email": "grace@navy.mil",
254
+ "scope": "public",
255
+ "isSelf": false,
256
+ "tags": [
257
+ { "id": "e40059db-6bf4-4ef7-ab5b-65ab8610c628", "name": "developer" }
258
+ ]
259
+ }
260
+ ]
261
+ ```
262
+
263
+ ___
264
+
265
+ **Search Minds**
266
+
267
+ ```typescript
268
+ const searchResults = await mindsim.minds.search({
269
+ query: "sarah@resistance.org",
270
+ });
271
+
272
+ console.log(searchResults);
273
+ ```
274
+
275
+ Response:
276
+ ```json
277
+ [
278
+ {
279
+ "id": "ac8ac8c4-05e9-4046-a919-4cbae2f49f22",
280
+ "name": "Sarah Connor",
281
+ "email": "sarah@resistance.org",
282
+ "scope": "private",
283
+ "isSelf": false,
284
+ "tags": [
285
+ { "id": "56255954-189f-4a1e-a355-08a1704af943", "name": "leader" }
286
+ ]
287
+ }
288
+ ]
289
+ ```
290
+ ---
291
+ Retrieve a Mind
292
+
293
+ Get the full details of a specific mind by its ID.
294
+
295
+ ```typescript
296
+ const mindId = "ac8ac8c4-05e9-4046-a919-4cbae2f49f22";
297
+ const mind = await mindsim.minds.get(mindId);
298
+ ```
299
+
300
+ Response:
301
+ ```json
302
+ {
303
+ "id": "ac8ac8c4-05e9-4046-a919-4cbae2f49f22",
304
+ "name": "Sarah Connor",
305
+ "email": "sarah@resistance.org",
306
+ "scope": "private",
307
+ "isSelf": false,
308
+ "socialMedia": {
309
+ "twitter": "@sarah_c"
310
+ },
311
+ "tags": [
312
+ { "id": "56255954-189f-4a1e-a355-08a1704af943", "name": "leader" }
313
+ ]
314
+ }
315
+ ```
316
+ ---
317
+ Update a Mind
318
+
319
+ Update the details of an existing mind.
320
+
321
+ ```typescript
322
+ const mindId = "ac8ac8c4-05e9-4046-a919-4cbae2f49f22";
323
+
324
+ const updatedMind = await mindsim.minds.update(mindId, {
325
+ name: "Sarah J. Connor",
326
+ email: "sarah.connor@resistance.net",
327
+ socialMedia: {
328
+ twitter: "@sarah_chronicles",
329
+ },
330
+ tags: ["leader", "strategist", "human"] // Replaces existing tags
331
+ });
332
+ ```
333
+
334
+ Response:
335
+ ```json
336
+ {
337
+ "id": "ac8ac8c4-05e9-4046-a919-4cbae2f49f22",
338
+ "name": "Sarah J. Connor",
339
+ "email": "sarah.connor@resistance.net",
340
+ "slug": "sarah-j-connor",
341
+ "scope": "private",
342
+ "isSelf": false,
343
+ "organizationId": "961b1800-6bd2-444c-8bfa-8dd82b5e80f3",
344
+ "createdAt": "2023-10-27T10:00:00Z",
345
+ "updatedAt": "2023-11-20T14:15:00Z",
346
+ "socialMedia": {
347
+ "twitter": "@sarah_chronicles"
348
+ },
349
+ "tags": [
350
+ { "id": "56255954-189f-4a1e-a355-08a1704af943", "name": "leader" },
351
+ { "id": "a1ca5e66-6f3a-4d92-ab25-8a86fdb111c1", "name": "strategist" },
352
+ { "id": "b2db6f77-8a4b-5e12-bc36-9b97aec222d2", "name": "human" }
353
+ ]
354
+ }
355
+ ```
356
+
357
+ **Delete a Mind**
358
+
359
+ Permanently remove a mind and its associated data.
360
+
361
+ ```typescript
362
+ const mindId = "ac8ac8c4-05e9-4046-a919-4cbae2f49f22";
363
+ const result = await mindsim.minds.delete(mindId);
364
+ ```
365
+
366
+ Response:
367
+ ```json
368
+ {
369
+ "success": true
370
+ }
371
+ ```
372
+ ---
373
+ Set Tags for a Mind
374
+
375
+ This operation replaces the existing tags on the mind with the new list provided.
376
+
377
+ ```typescript
378
+ const updatedMind = await mindsim.minds.setTags("ac8ac8c4-05e9-4046-a919-4cbae2f49f22", {
379
+ tags: ["hero", "survivor"], // Replaces existing tags
380
+ });
381
+
382
+ console.log(updatedMind.tags);
383
+ ```
384
+
385
+ Response:
386
+ ```json
387
+ {
388
+ "id": "ac8ac8c4-05e9-4046-a919-4cbae2f49f22",
389
+ "name": "Sarah Connor",
390
+ "tags": [
391
+ {
392
+ "id": "47a09167-3b9f-442c-a19c-96398cf238fb",
393
+ "name": "hero",
394
+ "mindCount": 1
395
+ },
396
+ {
397
+ "id": "a1ca5e66-6f3a-4d92-ab25-8a86fdb111c1",
398
+ "name": "survivor",
399
+ "mindCount": 1
400
+ }
401
+ ],
402
+ // ... other mind properties
403
+ }
404
+ ```
405
+
406
+
407
+
408
+ ### Upload Snapshots
409
+ A snapshot is a trained AI model built from conversation transcripts. It captures how someone thinks and communicates at a specific point in time.
410
+
411
+ #### Examples
412
+
413
+ Create a snapshot (Recommended)
414
+
415
+ This method automatically generates a signed URL, uploads the file content to the storage provider, and then creates the snapshot record.
416
+
417
+ ```typescript
418
+ import fs from 'node:fs';
419
+
420
+ const buffer = fs.readFileSync('./data/contract.pdf');
421
+ const mindId = "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d";
422
+
423
+ const snapshot = await mindsim.snapshots.create(mindId, {
424
+ file: buffer,
425
+ fileName: "contract.pdf",
426
+ contentType: "application/pdf", // If omitted, content type will be inferred from the fileName's extension
427
+ mindsetDate: "2023-11-01" // Optional: Date associated with the document
428
+ });
429
+
430
+ console.log(`Snapshot Created! Assessment ID: ${snapshot.mindAssessmentId}`);
431
+ ```
432
+
433
+ Response:
434
+ ```json
435
+ {
436
+ "message": "Snapshot created successfully.",
437
+ "mindAssessmentId": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
438
+ "artifactId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
439
+ }
440
+ ```
441
+ ---
442
+
443
+ Create Snapshot from a file
444
+
445
+ This method uploads the file directly to the MindSim API.
446
+
447
+ ```typescript
448
+ import fs from 'node:fs';
449
+
450
+ const buffer = fs.readFileSync('./data/chat_logs.txt');
451
+ const mindId = "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d";
452
+
453
+ const snapshot = await mindsim.snapshots.createFromFile(mindId, {
454
+ file: buffer,
455
+ fileName: "chat_logs.txt",
456
+ // contentType is handled automatically by FormData boundaries
457
+ });
458
+
459
+ console.log(`Upload Complete. Artifact ID: ${snapshot.artifactId}`);
460
+ ```
461
+
462
+ Response:
463
+ ```json
464
+ {
465
+ "message": "File uploaded successfully.",
466
+ "mindAssessmentId": "550e8400-e29b-41d4-a716-446655440000",
467
+ "artifactId": "c56a4180-65aa-42ec-a945-5fd21dec0538"
468
+ }
469
+ ```
470
+ ---
471
+
472
+ Snapshot Status
473
+
474
+ Snapshots process asynchronously. You use the mindAssessmentId (returned from the create calls) as the snapshotId to check progress.
475
+
476
+ ```typescript
477
+ const mindId = "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d";
478
+ const snapshotId = "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11";
479
+
480
+ const statusInfo = await mindsim.snapshots.getStatus(mindId, snapshotId);
481
+
482
+ if (statusInfo.status === 'completed') {
483
+ console.log(`Ready! Finished at: ${statusInfo.completedAt}`);
484
+ } else if (statusInfo.status === 'processing') {
485
+ console.log(`Still working... Started at: ${statusInfo.startedAt}`);
486
+ } else if (statusInfo.status === 'failed') {
487
+ console.error("Processing failed.");
488
+ }
489
+ ```
490
+
491
+ Response (Processing):
492
+ ```json
493
+ {
494
+ "id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
495
+ "mindId": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
496
+ "status": "processing",
497
+ "startedAt": "2023-11-15T14:30:00Z",
498
+ "completedAt": null
499
+ }
500
+ ```
501
+
502
+ Response (Completed):
503
+ ```json
504
+ {
505
+ "id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
506
+ "mindId": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
507
+ "status": "completed",
508
+ "startedAt": "2023-11-15T14:30:00Z",
509
+ "completedAt": "2023-11-15T14:30:45Z"
510
+ }
511
+ ```
512
+ ---
513
+ List Snapshots
514
+
515
+ Retrieve a list of all snapshots (memory banks) associated with a specific mind to track training history.
516
+
517
+ ```typescript
518
+ const mindId = "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d";
519
+ const result = await mindsim.snapshots.list(mindId);
520
+ ```
521
+
522
+ Response:
523
+ ```json
524
+ {
525
+ "count": 2,
526
+ "snapshots": [
527
+ {
528
+ "id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
529
+ "mindId": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
530
+ "artifactId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
531
+ "status": "completed",
532
+ "mindsetDate": "2023-11-01T00:00:00Z",
533
+ "createdAt": "2023-11-15T14:30:00Z",
534
+ "completedAt": "2023-11-15T14:30:45Z",
535
+ "psychometricCount": 12,
536
+ "keyTopicCount": 5
537
+ },
538
+ {
539
+ "id": "c1ffbd88-0d1a-5fe9-cc7e-7cc8ae491b22",
540
+ "mindId": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
541
+ "artifactId": null,
542
+ "status": "processing",
543
+ "mindsetDate": "2023-12-01T00:00:00Z",
544
+ "createdAt": "2023-12-02T09:15:00Z",
545
+ "completedAt": null
546
+ }
547
+ ]
548
+ }
549
+ ```
550
+
551
+ #### Data Requirements
552
+
553
+ For the most accurate results, ensure that snapshots conform to the following guidelines.
554
+
555
+ Minimum data:
556
+ - 10-20 conversations, OR
557
+ - 5,000+ words total
558
+
559
+ Supported formats:
560
+ - .vtt — Video transcripts (Zoom, Teams, Meet)
561
+ - .pdf — Documents with text
562
+ - .docx — Word documents
563
+
564
+ Best practices:
565
+ - Use recent data (last 6 months)
566
+ - Include diverse conversation types
567
+ - Ensure transcripts are clean and accurate
568
+ - More data improves accuracy
569
+
570
+ ### Run Simulations
571
+ A simulation predicts how someone would respond to any scenario based on their trained snapshot.
572
+
573
+ #### Examples
574
+
575
+ Run a Simulation
576
+
577
+ This is the default mode. The request waits until the mind processes the scenario and returns a response.
578
+ ```typescript
579
+ const mindId = "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d";
580
+
581
+ const simulation = await mindsim.simulations.run({
582
+ mindId: mindId,
583
+ scenario: {
584
+ message: "Based on your experience with Python, how would you approach a large data migration?"
585
+ },
586
+ });
587
+
588
+ console.log("Mind Response:", simulation.message);
589
+ ```
590
+
591
+ Response:
592
+ ```json
593
+ {
594
+ "message": "Given my background in backend systems, I would prioritize data integrity over speed. I'd likely use a staged approach with Python scripts using Pandas for validation, ensuring we have comprehensive logging for any transformation errors before committing to the production database."
595
+ }
596
+ ```
597
+ ---
598
+
599
+ Run a Background Simulation
600
+
601
+ For automation use cases, it is possible to start simulations without waiting for them to finish. Simulations can then later be retrieved after they have completed for further action.
602
+
603
+ ```typescript
604
+ const mindId = "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d";
605
+
606
+ // The "reasoning" model performs a chain-of-thought analysis before answering
607
+ const simulation = await mindsim.simulations.run({
608
+ mindId: mindId,
609
+ scenario: {
610
+ message: "Review this git diff and analyze the potential security implications of the auth changes."
611
+ },
612
+ runInBackground: true
613
+ });
614
+
615
+ // When running in background, the API typically acknowledges the queueing of the task
616
+ console.log("Status:", simulation.message);
617
+ ```
618
+
619
+ Response:
620
+ ```json
621
+ {
622
+ "message": "Simulation queued successfully. You will be notified upon completion."
623
+ }
624
+ ```
625
+
626
+ ---
627
+ List Simulation History
628
+
629
+ Retrieve a paginated list of past simulations run by your organization.
630
+
631
+ ```typescript
632
+ const history = await mindsim.simulations.list({
633
+ limit: 20,
634
+ offset: 0
635
+ });
636
+ ```
637
+
638
+ Response:
639
+ ```json
640
+ {
641
+ "count": 15,
642
+ "simulations": [
643
+ {
644
+ "id": "123e4567-e89b-12d3-a456-426614174000",
645
+ "userId": "961b1800-6bd2-444c-8bfa-8dd82b5e80f3",
646
+ "title": "Simulation with Sarah Connor",
647
+ "mindId": "ac8ac8c4-05e9-4046-a919-4cbae2f49f22",
648
+ "createdAt": "2023-11-16T10:00:00Z",
649
+ "updatedAt": "2023-11-16T10:05:00Z"
650
+ },
651
+ {
652
+ "id": "555e4567-a89b-12d3-b456-426614174999",
653
+ "userId": "961b1800-6bd2-444c-8bfa-8dd82b5e80f3",
654
+ "title": "Strategy Meeting Prep",
655
+ "mindId": "ac8ac8c4-05e9-4046-a919-4cbae2f49f22",
656
+ "createdAt": "2023-11-14T08:30:00Z",
657
+ "updatedAt": "2023-11-14T08:35:00Z"
658
+ },
659
+ //... the rest of the simulations
660
+ ]
661
+ }
662
+ ```
663
+
664
+ ---
665
+ Retrieve Simulation Details
666
+
667
+ Get the full transcript (messages) and metadata of a specific simulation.
668
+
669
+ ```typescript
670
+ const simulationId = "123e4567-e89b-12d3-a456-426614174000";
671
+ const fullSimulation = await mindsim.simulations.get(simulationId);
672
+ ```
673
+
674
+ Response:
675
+ ```json
676
+ {
677
+ "simulation": {
678
+ "id": "123e4567-e89b-12d3-a456-426614174000",
679
+ "title": "Simulation with Sarah Connor",
680
+ "userId": "961b1800-6bd2-444c-8bfa-8dd82b5e80f3",
681
+ "mindId": "ac8ac8c4-05e9-4046-a919-4cbae2f49f22",
682
+ "createdAt": "2023-11-16T10:00:00Z"
683
+ },
684
+ "messages": [
685
+ {
686
+ "id": "msg-1",
687
+ "role": "user",
688
+ "content": { "text": "What is the biggest threat we face?" },
689
+ "status": "completed",
690
+ "createdAt": "2023-11-16T10:00:01Z"
691
+ },
692
+ {
693
+ "id": "msg-2",
694
+ "role": "assistant",
695
+ "content": { "text": "Complacency. If we assume the machines are dormant, we lose." },
696
+ "status": "completed",
697
+ "createdAt": "2023-11-16T10:00:05Z"
698
+ }
699
+ ]
700
+ }
701
+ ```
702
+
703
+ ---
704
+ Delete a Simulation
705
+
706
+ Remove a simulation record from history.
707
+
708
+ ```typescript
709
+ const simulationId = "123e4567-e89b-12d3-a456-426614174000";
710
+ const result = await mindsim.simulations.delete(simulationId);
711
+ ```
712
+
713
+ Response:
714
+ ```json
715
+ {
716
+ "message": "Simulation deleted successfully",
717
+ "simulationId": "123e4567-e89b-12d3-a456-426614174000"
718
+ }
719
+ ```
720
+
721
+ ---
722
+
723
+ #### Writing Scenarios
724
+ To get the best simulation results, the following best practices are recommended.
725
+
726
+ **Be Specific**
727
+
728
+ - ❌ _Vague_: “How would they handle a complaint?”
729
+ - ✅ _Specific_: “A customer received a damaged product 3 days before their event. They need a replacement by tomorrow, but the product is out of stock. How would you respond?”
730
+
731
+ **Include Context**
732
+
733
+ - Emotional state — frustrated, confused, urgent
734
+ - Time constraints — by tomorrow, within 24 hours
735
+ - Constraints — out of stock, over budget
736
+ - Desired outcome — resolution, information
737
+
738
+ **Add Relevant Details**
739
+
740
+ - Background information
741
+ - Stakeholder concerns
742
+ - Business constraints
743
+ - Historical context
744
+
745
+ <br>
746
+ <div align="center">
747
+ <img style="display: block; margin: auto;" src="assets/mindsim-logo.svg"/>
748
+ </div>