@virtualkitchenco/multiverse-sdk 0.0.17 → 0.0.18
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 +16 -40
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install @virtualkitchenco/multiverse-sdk
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { multiverse
|
|
14
|
+
import { multiverse } from '@virtualkitchenco/multiverse-sdk';
|
|
15
15
|
import { z } from 'zod';
|
|
16
16
|
|
|
17
17
|
// 1. Configure
|
|
@@ -21,53 +21,29 @@ multiverse.configure({
|
|
|
21
21
|
apiKey: process.env.MULTIVERSE_API_KEY,
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
// 2.
|
|
25
|
-
const SearchResultSchema = z.object({
|
|
26
|
-
flights: z.array(z.object({
|
|
27
|
-
id: z.string(),
|
|
28
|
-
from: z.string(),
|
|
29
|
-
to: z.string(),
|
|
30
|
-
price: z.number(),
|
|
31
|
-
airline: z.string(),
|
|
32
|
-
})),
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const BookingSchema = z.object({
|
|
36
|
-
bookingId: z.string(),
|
|
37
|
-
flightId: z.string(),
|
|
38
|
-
passengerName: z.string(),
|
|
39
|
-
status: z.enum(['confirmed', 'pending', 'failed']),
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// 3. Wrap your tools
|
|
43
|
-
const searchFlights = wrap(searchFlightsTool, {
|
|
44
|
-
output: SearchResultSchema,
|
|
45
|
-
effects: (output) =>
|
|
46
|
-
output.flights.map((f) => ({
|
|
47
|
-
operation: 'create' as const,
|
|
48
|
-
collection: 'flights',
|
|
49
|
-
id: f.id,
|
|
50
|
-
data: f,
|
|
51
|
-
})),
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const bookFlight = wrap(bookFlightTool, {
|
|
55
|
-
output: BookingSchema,
|
|
56
|
-
effects: (output) => [
|
|
57
|
-
{ operation: 'create', collection: 'bookings', id: output.bookingId, data: output },
|
|
58
|
-
],
|
|
59
|
-
});
|
|
24
|
+
// 2. Register tools (see multiverse.tool() and wrap() below)
|
|
60
25
|
|
|
61
|
-
//
|
|
26
|
+
// 3. Describe what you're testing
|
|
62
27
|
const test = multiverse.describe({
|
|
63
28
|
name: 'flight-booking-agent',
|
|
64
|
-
task: '
|
|
29
|
+
task: 'Help the user book a flight',
|
|
65
30
|
agent: runAgent,
|
|
66
31
|
});
|
|
67
32
|
|
|
33
|
+
// 4. Generate scenarios with typed variables
|
|
34
|
+
const scenarios = await test.generateScenarios({
|
|
35
|
+
count: 5,
|
|
36
|
+
variables: z.object({
|
|
37
|
+
expectedBookings: z.number().describe('Total flight bookings expected'),
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// 5. Run
|
|
68
42
|
const results = await test.run({
|
|
43
|
+
scenarios,
|
|
69
44
|
simulateUser: true,
|
|
70
|
-
success: (world
|
|
45
|
+
success: (world, trace, scenario) =>
|
|
46
|
+
world.getCollection('bookings').size === scenario.variables.expectedBookings,
|
|
71
47
|
});
|
|
72
48
|
|
|
73
49
|
console.log(`${results.passRate}% pass`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virtualkitchenco/multiverse-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Simulated worlds for AI agents - 6 months production in 6 minutes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"nanoid": "^5.0.4",
|
|
28
|
-
"@virtualkitchenco/multiverse-types": "0.0.
|
|
28
|
+
"@virtualkitchenco/multiverse-types": "0.0.18"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.11.0",
|