mindsim 0.1.1 → 0.1.2
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 +84 -1
- package/dist/cli.js +105 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/mind-topics.d.ts +11 -0
- package/dist/resources/mind-topics.d.ts.map +1 -0
- package/dist/resources/mind-topics.js +18 -0
- package/dist/resources/mind-topics.js.map +1 -0
- package/dist/resources/snapshots.d.ts +29 -1
- package/dist/resources/snapshots.d.ts.map +1 -1
- package/dist/resources/snapshots.js +30 -0
- package/dist/resources/snapshots.js.map +1 -1
- package/dist/resources/usage.d.ts +14 -0
- package/dist/resources/usage.d.ts.map +1 -0
- package/dist/resources/usage.js +20 -0
- package/dist/resources/usage.js.map +1 -0
- package/dist/resources/users.d.ts +14 -0
- package/dist/resources/users.d.ts.map +1 -0
- package/dist/resources/users.js +20 -0
- package/dist/resources/users.js.map +1 -0
- package/dist/types.d.ts +51 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +105 -0
- package/src/index.ts +9 -0
- package/src/resources/mind-topics.ts +16 -0
- package/src/resources/snapshots.ts +60 -0
- package/src/resources/usage.ts +16 -0
- package/src/resources/users.ts +16 -0
- package/src/types.ts +61 -0
- package/tests/resources/mind-topics.test.ts +69 -0
- package/tests/resources/snapshots.test.ts +46 -0
- package/tests/resources/usage.test.ts +34 -0
- package/tests/resources/users.test.ts +54 -0
package/dist/types.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export interface Mind {
|
|
|
31
31
|
createdAt?: string;
|
|
32
32
|
updatedAt?: string;
|
|
33
33
|
tags: Tag[];
|
|
34
|
+
snapshotCount?: number;
|
|
34
35
|
}
|
|
35
36
|
export interface CreateMindRequest {
|
|
36
37
|
name: string;
|
|
@@ -57,6 +58,8 @@ export interface SimulationScenario {
|
|
|
57
58
|
export interface RunSimulationRequest {
|
|
58
59
|
mindId: string;
|
|
59
60
|
scenario: SimulationScenario;
|
|
61
|
+
conversationId?: string;
|
|
62
|
+
stream?: boolean;
|
|
60
63
|
runInBackground?: boolean;
|
|
61
64
|
}
|
|
62
65
|
export interface SimulationResponse {
|
|
@@ -139,10 +142,21 @@ export interface MindAssessment {
|
|
|
139
142
|
keyTopicCount?: number | null;
|
|
140
143
|
findingCount?: number | null;
|
|
141
144
|
}
|
|
145
|
+
export interface SnapshotDetailResponse extends MindAssessment {
|
|
146
|
+
transcripts?: any[];
|
|
147
|
+
psychometrics?: any;
|
|
148
|
+
}
|
|
142
149
|
export interface ListSnapshotsResponse {
|
|
143
150
|
snapshots: MindAssessment[];
|
|
144
151
|
count: number;
|
|
145
152
|
}
|
|
153
|
+
export interface DigitalTwinMindAssessment {
|
|
154
|
+
id: string;
|
|
155
|
+
digitalTwinId: string;
|
|
156
|
+
mindAssessmentId: string;
|
|
157
|
+
createdAt: string;
|
|
158
|
+
updatedAt: string;
|
|
159
|
+
}
|
|
146
160
|
export interface PersonDetails {
|
|
147
161
|
id: string;
|
|
148
162
|
slug?: string | null;
|
|
@@ -158,4 +172,41 @@ export interface GetPsychometricsResponse {
|
|
|
158
172
|
topicsSentimentSummary?: Record<string, any> | null;
|
|
159
173
|
mindReasonerStopError?: any | null;
|
|
160
174
|
}
|
|
175
|
+
export interface GetMindTopicsResponse {
|
|
176
|
+
personDetails: PersonDetails;
|
|
177
|
+
topicsSentimentSummary?: Record<string, any> | null;
|
|
178
|
+
mindReasonerStopError?: any | null;
|
|
179
|
+
}
|
|
180
|
+
export interface User {
|
|
181
|
+
id: string;
|
|
182
|
+
name: string;
|
|
183
|
+
email: string;
|
|
184
|
+
imageUrl?: string | null;
|
|
185
|
+
createdAt?: string;
|
|
186
|
+
updatedAt?: string;
|
|
187
|
+
}
|
|
188
|
+
export interface ListUsersResponse {
|
|
189
|
+
users: User[];
|
|
190
|
+
count: number;
|
|
191
|
+
}
|
|
192
|
+
export interface ApiKeyUsage {
|
|
193
|
+
successCount: number;
|
|
194
|
+
errorCount: number;
|
|
195
|
+
totalCount: number;
|
|
196
|
+
averageLatency: number;
|
|
197
|
+
maxLatency: number;
|
|
198
|
+
minLatency: number;
|
|
199
|
+
medianLatency: number;
|
|
200
|
+
p90Latency: number;
|
|
201
|
+
p95Latency: number;
|
|
202
|
+
p99Latency: number;
|
|
203
|
+
p999Latency: number;
|
|
204
|
+
numberOfSimulations: number;
|
|
205
|
+
numberOfSimulatedTwins: number;
|
|
206
|
+
numberOfSnapshotsCreated: number;
|
|
207
|
+
numberOfSnapshotsTotal: number;
|
|
208
|
+
numberOfCoresReprocessed: number;
|
|
209
|
+
numberOfPsychometricsRequests: number;
|
|
210
|
+
numberOfMindTopicsRequests: number;
|
|
211
|
+
}
|
|
161
212
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,IAA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,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAID,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,wBAAwB,EAAE,MAAM,CAAC;IACjC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,wBAAwB,EAAE,MAAM,CAAC;IACjC,6BAA6B,EAAE,MAAM,CAAC;IACtC,0BAA0B,EAAE,MAAM,CAAC;CACpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindsim",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "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.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
package/src/cli.ts
CHANGED
|
@@ -213,6 +213,26 @@ const main = async () => {
|
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
215
|
|
|
216
|
+
snapshots
|
|
217
|
+
.command("get")
|
|
218
|
+
.description("Get snapshot detail")
|
|
219
|
+
.argument("<mindId>", "ID of the mind")
|
|
220
|
+
.argument("<snapshotId>", "ID of the snapshot")
|
|
221
|
+
.option("--transcript", "Include transcript")
|
|
222
|
+
.option("--psychometrics", "Include psychometrics")
|
|
223
|
+
.action(async (mindId, snapshotId, options) => {
|
|
224
|
+
try {
|
|
225
|
+
const client = getSDK();
|
|
226
|
+
const result = await client.snapshots.getDetail(mindId, snapshotId, {
|
|
227
|
+
includeTranscript: options.transcript,
|
|
228
|
+
includePsychometrics: options.psychometrics,
|
|
229
|
+
});
|
|
230
|
+
printOutput(result);
|
|
231
|
+
} catch (err) {
|
|
232
|
+
handleError(err);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
216
236
|
snapshots
|
|
217
237
|
.command("create")
|
|
218
238
|
.description("Upload a file to create a snapshot")
|
|
@@ -260,6 +280,51 @@ const main = async () => {
|
|
|
260
280
|
}
|
|
261
281
|
});
|
|
262
282
|
|
|
283
|
+
snapshots
|
|
284
|
+
.command("delete")
|
|
285
|
+
.description("Delete a snapshot")
|
|
286
|
+
.argument("<mindId>", "ID of the mind")
|
|
287
|
+
.argument("<snapshotId>", "ID of the snapshot")
|
|
288
|
+
.action(async (mindId, snapshotId) => {
|
|
289
|
+
try {
|
|
290
|
+
const client = getSDK();
|
|
291
|
+
const result = await client.snapshots.delete(mindId, snapshotId);
|
|
292
|
+
printOutput(result);
|
|
293
|
+
} catch (err) {
|
|
294
|
+
handleError(err);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
snapshots
|
|
299
|
+
.command("link")
|
|
300
|
+
.description("Link snapshot to digital twin")
|
|
301
|
+
.argument("<mindId>", "ID of the mind")
|
|
302
|
+
.argument("<snapshotId>", "ID of the snapshot")
|
|
303
|
+
.action(async (mindId, snapshotId) => {
|
|
304
|
+
try {
|
|
305
|
+
const client = getSDK();
|
|
306
|
+
const result = await client.snapshots.link(mindId, snapshotId);
|
|
307
|
+
printOutput(result);
|
|
308
|
+
} catch (err) {
|
|
309
|
+
handleError(err);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
snapshots
|
|
314
|
+
.command("unlink")
|
|
315
|
+
.description("Unlink snapshot from digital twin")
|
|
316
|
+
.argument("<mindId>", "ID of the mind")
|
|
317
|
+
.argument("<snapshotId>", "ID of the snapshot")
|
|
318
|
+
.action(async (mindId, snapshotId) => {
|
|
319
|
+
try {
|
|
320
|
+
const client = getSDK();
|
|
321
|
+
const result = await client.snapshots.unlink(mindId, snapshotId);
|
|
322
|
+
printOutput(result);
|
|
323
|
+
} catch (err) {
|
|
324
|
+
handleError(err);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
|
|
263
328
|
// ==========================================
|
|
264
329
|
// SIMULATIONS RESOURCES
|
|
265
330
|
// ==========================================
|
|
@@ -399,6 +464,46 @@ const main = async () => {
|
|
|
399
464
|
}
|
|
400
465
|
});
|
|
401
466
|
|
|
467
|
+
psychometrics
|
|
468
|
+
.command("topics")
|
|
469
|
+
.description("Get topic analysis")
|
|
470
|
+
.argument("<snapshotId>")
|
|
471
|
+
.action(async (sid) => {
|
|
472
|
+
try {
|
|
473
|
+
const client = getSDK();
|
|
474
|
+
printOutput(await client.mindTopics.get(sid));
|
|
475
|
+
} catch (e) {
|
|
476
|
+
handleError(e);
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
// USAGE & USERS
|
|
481
|
+
program
|
|
482
|
+
.command("usage")
|
|
483
|
+
.description("Get API key usage")
|
|
484
|
+
.option("--from <date>", "From date (YYYY-MM-DD)")
|
|
485
|
+
.option("--to <date>", "To date (YYYY-MM-DD)")
|
|
486
|
+
.action(async (opts) => {
|
|
487
|
+
try {
|
|
488
|
+
const client = getSDK();
|
|
489
|
+
printOutput(await client.usage.get({ from: opts.from, to: opts.to }));
|
|
490
|
+
} catch (e) {
|
|
491
|
+
handleError(e);
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
program
|
|
496
|
+
.command("users")
|
|
497
|
+
.description("List organization users")
|
|
498
|
+
.action(async () => {
|
|
499
|
+
try {
|
|
500
|
+
const client = getSDK();
|
|
501
|
+
printOutput(await client.users.list());
|
|
502
|
+
} catch (e) {
|
|
503
|
+
handleError(e);
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
|
|
402
507
|
program.parse(process.argv);
|
|
403
508
|
};
|
|
404
509
|
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import axios, { type AxiosInstance } from "axios";
|
|
2
2
|
import { getApiBaseUrl, loadApiKey } from "./config";
|
|
3
3
|
import { ArtifactsResource } from "./resources/artifacts";
|
|
4
|
+
import { MindTopicsResource } from "./resources/mind-topics";
|
|
4
5
|
import { MindsResource } from "./resources/minds";
|
|
5
6
|
import { PsychometricsResource } from "./resources/psychometrics";
|
|
6
7
|
import { SimulationsResource } from "./resources/simulations";
|
|
7
8
|
import { SnapshotsResource } from "./resources/snapshots";
|
|
8
9
|
import { TagsResource } from "./resources/tags";
|
|
10
|
+
import { UsageResource } from "./resources/usage";
|
|
11
|
+
import { UsersResource } from "./resources/users";
|
|
9
12
|
import { checkForUpdates, getPackageVersion } from "./version";
|
|
10
13
|
|
|
11
14
|
export class MindSim {
|
|
@@ -13,10 +16,13 @@ export class MindSim {
|
|
|
13
16
|
|
|
14
17
|
public artifacts: ArtifactsResource;
|
|
15
18
|
public minds: MindsResource;
|
|
19
|
+
public mindTopics: MindTopicsResource;
|
|
16
20
|
public psychometrics: PsychometricsResource;
|
|
17
21
|
public snapshots: SnapshotsResource;
|
|
18
22
|
public simulations: SimulationsResource;
|
|
19
23
|
public tags: TagsResource;
|
|
24
|
+
public usage: UsageResource;
|
|
25
|
+
public users: UsersResource;
|
|
20
26
|
|
|
21
27
|
constructor(apiKey?: string, options?: { apiBaseUrl?: string }) {
|
|
22
28
|
// 1. Trigger the auto-update check (Fire and forget, do not await)
|
|
@@ -48,10 +54,13 @@ export class MindSim {
|
|
|
48
54
|
|
|
49
55
|
this.artifacts = new ArtifactsResource(this.client);
|
|
50
56
|
this.minds = new MindsResource(this.client);
|
|
57
|
+
this.mindTopics = new MindTopicsResource(this.client);
|
|
51
58
|
this.psychometrics = new PsychometricsResource(this.client);
|
|
52
59
|
this.snapshots = new SnapshotsResource(this.client);
|
|
53
60
|
this.simulations = new SimulationsResource(this.client);
|
|
54
61
|
this.tags = new TagsResource(this.client);
|
|
62
|
+
this.usage = new UsageResource(this.client);
|
|
63
|
+
this.users = new UsersResource(this.client);
|
|
55
64
|
}
|
|
56
65
|
}
|
|
57
66
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
import type { GetMindTopicsResponse } from "../types";
|
|
3
|
+
|
|
4
|
+
export class MindTopicsResource {
|
|
5
|
+
constructor(private client: AxiosInstance) {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get topic analysis for a specific snapshot
|
|
9
|
+
*/
|
|
10
|
+
async get(snapshotId: string): Promise<GetMindTopicsResponse> {
|
|
11
|
+
const response = await this.client.get<GetMindTopicsResponse>(
|
|
12
|
+
`/snapshots/${snapshotId}/mind-topics`,
|
|
13
|
+
);
|
|
14
|
+
return response.data;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -5,8 +5,10 @@ import type {
|
|
|
5
5
|
CreateSnapshotFromFileParams,
|
|
6
6
|
CreateSnapshotParams,
|
|
7
7
|
CreateSnapshotResponse,
|
|
8
|
+
DigitalTwinMindAssessment,
|
|
8
9
|
GetSignedUrlResponse,
|
|
9
10
|
ListSnapshotsResponse,
|
|
11
|
+
SnapshotDetailResponse,
|
|
10
12
|
SnapshotStatus,
|
|
11
13
|
} from "../types";
|
|
12
14
|
|
|
@@ -41,6 +43,36 @@ export class SnapshotsResource {
|
|
|
41
43
|
return response.data;
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Get details of a specific snapshot, optionally including transcripts and psychometrics
|
|
48
|
+
*/
|
|
49
|
+
async getDetail(
|
|
50
|
+
mindId: string,
|
|
51
|
+
snapshotId: string,
|
|
52
|
+
options?: { includeTranscript?: boolean; includePsychometrics?: boolean },
|
|
53
|
+
): Promise<SnapshotDetailResponse> {
|
|
54
|
+
const response = await this.client.get<SnapshotDetailResponse>(
|
|
55
|
+
`/minds/${mindId}/snapshots/${snapshotId}`,
|
|
56
|
+
{
|
|
57
|
+
params: options,
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
return response.data;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Delete a snapshot
|
|
65
|
+
*/
|
|
66
|
+
async delete(
|
|
67
|
+
mindId: string,
|
|
68
|
+
snapshotId: string,
|
|
69
|
+
): Promise<{ message: string; snapshotId: string }> {
|
|
70
|
+
const response = await this.client.delete<{ message: string; snapshotId: string }>(
|
|
71
|
+
`/minds/${mindId}/snapshots/${snapshotId}`,
|
|
72
|
+
);
|
|
73
|
+
return response.data;
|
|
74
|
+
}
|
|
75
|
+
|
|
44
76
|
/**
|
|
45
77
|
* Create a snapshot via a signed url. Recommended for large files.
|
|
46
78
|
*/
|
|
@@ -123,4 +155,32 @@ export class SnapshotsResource {
|
|
|
123
155
|
);
|
|
124
156
|
return response.data;
|
|
125
157
|
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Link a snapshot to the Digital Twin
|
|
161
|
+
*/
|
|
162
|
+
async link(
|
|
163
|
+
mindId: string,
|
|
164
|
+
snapshotId: string,
|
|
165
|
+
): Promise<{ message: string; snapshot: DigitalTwinMindAssessment }> {
|
|
166
|
+
const response = await this.client.post<{
|
|
167
|
+
message: string;
|
|
168
|
+
snapshot: DigitalTwinMindAssessment;
|
|
169
|
+
}>(`/minds/${mindId}/snapshots/${snapshotId}/link`);
|
|
170
|
+
return response.data;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Unlink a snapshot from the Digital Twin
|
|
175
|
+
*/
|
|
176
|
+
async unlink(
|
|
177
|
+
mindId: string,
|
|
178
|
+
snapshotId: string,
|
|
179
|
+
): Promise<{ message: string; snapshot: DigitalTwinMindAssessment[] }> {
|
|
180
|
+
const response = await this.client.post<{
|
|
181
|
+
message: string;
|
|
182
|
+
snapshot: DigitalTwinMindAssessment[];
|
|
183
|
+
}>(`/minds/${mindId}/snapshots/${snapshotId}/unlink`);
|
|
184
|
+
return response.data;
|
|
185
|
+
}
|
|
126
186
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
import type { ApiKeyUsage } from "../types";
|
|
3
|
+
|
|
4
|
+
export class UsageResource {
|
|
5
|
+
constructor(private client: AxiosInstance) {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get API Key Usage stats
|
|
9
|
+
*/
|
|
10
|
+
async get(params?: { from?: string; to?: string }): Promise<ApiKeyUsage> {
|
|
11
|
+
const response = await this.client.get<ApiKeyUsage>("/usage", {
|
|
12
|
+
params,
|
|
13
|
+
});
|
|
14
|
+
return response.data;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
import type { ListUsersResponse } from "../types";
|
|
3
|
+
|
|
4
|
+
export class UsersResource {
|
|
5
|
+
constructor(private client: AxiosInstance) {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* List users in the organization
|
|
9
|
+
*/
|
|
10
|
+
async list(params?: { limit?: number; offset?: number }): Promise<ListUsersResponse> {
|
|
11
|
+
const response = await this.client.get<ListUsersResponse>("/organizations/users", {
|
|
12
|
+
params,
|
|
13
|
+
});
|
|
14
|
+
return response.data;
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -34,6 +34,7 @@ export interface Mind {
|
|
|
34
34
|
createdAt?: string;
|
|
35
35
|
updatedAt?: string;
|
|
36
36
|
tags: Tag[];
|
|
37
|
+
snapshotCount?: number;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export interface CreateMindRequest {
|
|
@@ -66,6 +67,8 @@ export interface SimulationScenario {
|
|
|
66
67
|
export interface RunSimulationRequest {
|
|
67
68
|
mindId: string;
|
|
68
69
|
scenario: SimulationScenario;
|
|
70
|
+
conversationId?: string;
|
|
71
|
+
stream?: boolean;
|
|
69
72
|
runInBackground?: boolean;
|
|
70
73
|
}
|
|
71
74
|
|
|
@@ -160,11 +163,24 @@ export interface MindAssessment {
|
|
|
160
163
|
findingCount?: number | null;
|
|
161
164
|
}
|
|
162
165
|
|
|
166
|
+
export interface SnapshotDetailResponse extends MindAssessment {
|
|
167
|
+
transcripts?: any[];
|
|
168
|
+
psychometrics?: any;
|
|
169
|
+
}
|
|
170
|
+
|
|
163
171
|
export interface ListSnapshotsResponse {
|
|
164
172
|
snapshots: MindAssessment[];
|
|
165
173
|
count: number;
|
|
166
174
|
}
|
|
167
175
|
|
|
176
|
+
export interface DigitalTwinMindAssessment {
|
|
177
|
+
id: string;
|
|
178
|
+
digitalTwinId: string;
|
|
179
|
+
mindAssessmentId: string;
|
|
180
|
+
createdAt: string;
|
|
181
|
+
updatedAt: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
168
184
|
// -- Psychometrics --
|
|
169
185
|
|
|
170
186
|
export interface PersonDetails {
|
|
@@ -183,3 +199,48 @@ export interface GetPsychometricsResponse {
|
|
|
183
199
|
topicsSentimentSummary?: Record<string, any> | null;
|
|
184
200
|
mindReasonerStopError?: any | null;
|
|
185
201
|
}
|
|
202
|
+
|
|
203
|
+
export interface GetMindTopicsResponse {
|
|
204
|
+
personDetails: PersonDetails;
|
|
205
|
+
topicsSentimentSummary?: Record<string, any> | null;
|
|
206
|
+
mindReasonerStopError?: any | null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// -- Users --
|
|
210
|
+
|
|
211
|
+
export interface User {
|
|
212
|
+
id: string;
|
|
213
|
+
name: string;
|
|
214
|
+
email: string;
|
|
215
|
+
imageUrl?: string | null;
|
|
216
|
+
createdAt?: string;
|
|
217
|
+
updatedAt?: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface ListUsersResponse {
|
|
221
|
+
users: User[];
|
|
222
|
+
count: number;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// -- Usage --
|
|
226
|
+
|
|
227
|
+
export interface ApiKeyUsage {
|
|
228
|
+
successCount: number;
|
|
229
|
+
errorCount: number;
|
|
230
|
+
totalCount: number;
|
|
231
|
+
averageLatency: number;
|
|
232
|
+
maxLatency: number;
|
|
233
|
+
minLatency: number;
|
|
234
|
+
medianLatency: number;
|
|
235
|
+
p90Latency: number;
|
|
236
|
+
p95Latency: number;
|
|
237
|
+
p99Latency: number;
|
|
238
|
+
p999Latency: number;
|
|
239
|
+
numberOfSimulations: number;
|
|
240
|
+
numberOfSimulatedTwins: number;
|
|
241
|
+
numberOfSnapshotsCreated: number;
|
|
242
|
+
numberOfSnapshotsTotal: number;
|
|
243
|
+
numberOfCoresReprocessed: number;
|
|
244
|
+
numberOfPsychometricsRequests: number;
|
|
245
|
+
numberOfMindTopicsRequests: number;
|
|
246
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { beforeEach, describe, expect, it, type Mocked, vi } from "vitest";
|
|
3
|
+
import { MindSim } from "../../src/index";
|
|
4
|
+
import type { GetMindTopicsResponse } from "../../src/types";
|
|
5
|
+
|
|
6
|
+
vi.mock("axios");
|
|
7
|
+
const mockedAxios = axios as Mocked<typeof axios>;
|
|
8
|
+
|
|
9
|
+
describe("MindSim Mind Topics Resource", () => {
|
|
10
|
+
let mindsim: MindSim;
|
|
11
|
+
const SNAPSHOT_ID = "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11";
|
|
12
|
+
|
|
13
|
+
const mockClient = {
|
|
14
|
+
get: vi.fn(),
|
|
15
|
+
defaults: { headers: { common: {} } },
|
|
16
|
+
interceptors: { request: { use: vi.fn() }, response: { use: vi.fn() } },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
mockedAxios.create.mockReturnValue(mockClient as any);
|
|
21
|
+
mindsim = new MindSim("test-api-key");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("get() should retrieve topic analysis for a snapshot", async () => {
|
|
25
|
+
const mockResponse: GetMindTopicsResponse = {
|
|
26
|
+
personDetails: {
|
|
27
|
+
id: "p1",
|
|
28
|
+
name: "Test Subject",
|
|
29
|
+
mindDate: "2023-01-01",
|
|
30
|
+
mindAssesssmentId: SNAPSHOT_ID,
|
|
31
|
+
},
|
|
32
|
+
topicsSentimentSummary: {
|
|
33
|
+
topics: [
|
|
34
|
+
{ name: "Coding", sentiment: "Positive" },
|
|
35
|
+
{ name: "Meetings", sentiment: "Negative" },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
mindReasonerStopError: null,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
mockClient.get.mockResolvedValue({ data: mockResponse });
|
|
42
|
+
|
|
43
|
+
const result = await mindsim.mindTopics.get(SNAPSHOT_ID);
|
|
44
|
+
|
|
45
|
+
expect(mockClient.get).toHaveBeenCalledWith(`/snapshots/${SNAPSHOT_ID}/mind-topics`);
|
|
46
|
+
expect(result.personDetails.name).toBe("Test Subject");
|
|
47
|
+
expect(result.topicsSentimentSummary?.topics).toHaveLength(2);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("get() should handle missing optional fields gracefully", async () => {
|
|
51
|
+
// API might return minimal data if processing isn't fully complete or data is sparse
|
|
52
|
+
const mockResponse: GetMindTopicsResponse = {
|
|
53
|
+
personDetails: {
|
|
54
|
+
id: "p1",
|
|
55
|
+
name: "Test Subject",
|
|
56
|
+
mindDate: "2023-01-01",
|
|
57
|
+
mindAssesssmentId: SNAPSHOT_ID,
|
|
58
|
+
},
|
|
59
|
+
topicsSentimentSummary: null,
|
|
60
|
+
mindReasonerStopError: null,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
mockClient.get.mockResolvedValue({ data: mockResponse });
|
|
64
|
+
|
|
65
|
+
const result = await mindsim.mindTopics.get(SNAPSHOT_ID);
|
|
66
|
+
|
|
67
|
+
expect(result.topicsSentimentSummary).toBeNull();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -17,6 +17,7 @@ describe("MindSim Snapshots Resource", () => {
|
|
|
17
17
|
get: vi.fn(),
|
|
18
18
|
post: vi.fn(),
|
|
19
19
|
put: vi.fn(),
|
|
20
|
+
delete: vi.fn(), // Added delete mock
|
|
20
21
|
defaults: { headers: { common: {} } },
|
|
21
22
|
interceptors: { request: { use: vi.fn() }, response: { use: vi.fn() } },
|
|
22
23
|
};
|
|
@@ -26,6 +27,7 @@ describe("MindSim Snapshots Resource", () => {
|
|
|
26
27
|
mindsim = new MindSim("fake-key");
|
|
27
28
|
});
|
|
28
29
|
|
|
30
|
+
// ... (Existing list, create, createFromFile, getStatus tests remain unchanged) ...
|
|
29
31
|
it("list() should retrieve snapshots for a mind", async () => {
|
|
30
32
|
const mockList = {
|
|
31
33
|
snapshots: [{ id: ASSESSMENT_ID, status: "completed" }],
|
|
@@ -132,4 +134,48 @@ describe("MindSim Snapshots Resource", () => {
|
|
|
132
134
|
`/minds/${MIND_ID}/snapshots/${ASSESSMENT_ID}/status`,
|
|
133
135
|
);
|
|
134
136
|
});
|
|
137
|
+
|
|
138
|
+
// NEW TESTS
|
|
139
|
+
|
|
140
|
+
it("getDetail() should retrieve details with query params", async () => {
|
|
141
|
+
mockApiClient.get.mockResolvedValue({
|
|
142
|
+
data: { id: ASSESSMENT_ID, status: "completed", transcripts: ["foo"] },
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const result = await mindsim.snapshots.getDetail(MIND_ID, ASSESSMENT_ID, {
|
|
146
|
+
includeTranscript: true,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
expect(mockApiClient.get).toHaveBeenCalledWith(`/minds/${MIND_ID}/snapshots/${ASSESSMENT_ID}`, {
|
|
150
|
+
params: { includeTranscript: true },
|
|
151
|
+
});
|
|
152
|
+
expect(result.transcripts).toHaveLength(1);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("delete() should remove snapshot", async () => {
|
|
156
|
+
mockApiClient.delete.mockResolvedValue({
|
|
157
|
+
data: { message: "deleted", snapshotId: ASSESSMENT_ID },
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
await mindsim.snapshots.delete(MIND_ID, ASSESSMENT_ID);
|
|
161
|
+
expect(mockApiClient.delete).toHaveBeenCalledWith(
|
|
162
|
+
`/minds/${MIND_ID}/snapshots/${ASSESSMENT_ID}`,
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("link() should post to link endpoint", async () => {
|
|
167
|
+
mockApiClient.post.mockResolvedValue({ data: { message: "linked" } });
|
|
168
|
+
await mindsim.snapshots.link(MIND_ID, ASSESSMENT_ID);
|
|
169
|
+
expect(mockApiClient.post).toHaveBeenCalledWith(
|
|
170
|
+
`/minds/${MIND_ID}/snapshots/${ASSESSMENT_ID}/link`,
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("unlink() should post to unlink endpoint", async () => {
|
|
175
|
+
mockApiClient.post.mockResolvedValue({ data: { message: "unlinked" } });
|
|
176
|
+
await mindsim.snapshots.unlink(MIND_ID, ASSESSMENT_ID);
|
|
177
|
+
expect(mockApiClient.post).toHaveBeenCalledWith(
|
|
178
|
+
`/minds/${MIND_ID}/snapshots/${ASSESSMENT_ID}/unlink`,
|
|
179
|
+
);
|
|
180
|
+
});
|
|
135
181
|
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { beforeEach, describe, expect, it, type Mocked, vi } from "vitest";
|
|
3
|
+
import { MindSim } from "../../src/index";
|
|
4
|
+
|
|
5
|
+
vi.mock("axios");
|
|
6
|
+
const mockedAxios = axios as Mocked<typeof axios>;
|
|
7
|
+
|
|
8
|
+
describe("MindSim Usage Resource", () => {
|
|
9
|
+
let mindsim: MindSim;
|
|
10
|
+
|
|
11
|
+
const mockClient = {
|
|
12
|
+
get: vi.fn(),
|
|
13
|
+
defaults: { headers: { common: {} } },
|
|
14
|
+
interceptors: { request: { use: vi.fn() }, response: { use: vi.fn() } },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
mockedAxios.create.mockReturnValue(mockClient as any);
|
|
19
|
+
mindsim = new MindSim("test-key");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("get() should call /usage with date params", async () => {
|
|
23
|
+
mockClient.get.mockResolvedValue({
|
|
24
|
+
data: { totalCount: 100, successCount: 99 },
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const result = await mindsim.usage.get({ from: "2023-01-01", to: "2023-01-31" });
|
|
28
|
+
|
|
29
|
+
expect(mockClient.get).toHaveBeenCalledWith("/usage", {
|
|
30
|
+
params: { from: "2023-01-01", to: "2023-01-31" },
|
|
31
|
+
});
|
|
32
|
+
expect(result.totalCount).toBe(100);
|
|
33
|
+
});
|
|
34
|
+
});
|