@virtualkitchenco/multiverse-sdk 0.0.16 → 0.0.17
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 +38 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -90,9 +90,46 @@ multiverse.configure({
|
|
|
90
90
|
});
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
### `multiverse.tool(def)`
|
|
94
|
+
|
|
95
|
+
Register a tool for simulation. Works with any plain function — no framework required.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const searchFlights = multiverse.tool({
|
|
99
|
+
name: 'searchFlights',
|
|
100
|
+
description: 'Search for available flights',
|
|
101
|
+
input: z.object({
|
|
102
|
+
from: z.string().describe('Departure airport code'),
|
|
103
|
+
to: z.string().describe('Arrival airport code'),
|
|
104
|
+
date: z.string().describe('Departure date (YYYY-MM-DD)'),
|
|
105
|
+
}),
|
|
106
|
+
output: SearchResultSchema,
|
|
107
|
+
execute: async (input) => realSearchFlights(input),
|
|
108
|
+
effects: (output) =>
|
|
109
|
+
output.flights.map((f) => ({
|
|
110
|
+
operation: 'create' as const,
|
|
111
|
+
collection: 'flights',
|
|
112
|
+
id: f.id,
|
|
113
|
+
data: f,
|
|
114
|
+
})),
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Returns a callable function `(input) => Promise<output>`. During tests, calls are intercepted and simulated. Outside tests, `execute` is called directly.
|
|
119
|
+
|
|
120
|
+
| Option | Type | Description |
|
|
121
|
+
|--------|------|-------------|
|
|
122
|
+
| `name` | `string` | Tool name |
|
|
123
|
+
| `description` | `string` | Tool description |
|
|
124
|
+
| `input` | `ZodSchema` | Input schema |
|
|
125
|
+
| `output` | `ZodSchema` | Output schema |
|
|
126
|
+
| `execute` | `(input) => Promise<output>` | Real implementation |
|
|
127
|
+
| `effects` | `(output, world) => Effect[]` | Declare state changes from output |
|
|
128
|
+
| `invariants` | `Invariant[]` | Constraints to enforce |
|
|
129
|
+
|
|
93
130
|
### `wrap(tool, config)`
|
|
94
131
|
|
|
95
|
-
Wrap a LangChain tool for simulation
|
|
132
|
+
Wrap a LangChain tool for simulation. Extracts `name`, `description`, and `schema` automatically.
|
|
96
133
|
|
|
97
134
|
```typescript
|
|
98
135
|
import { wrap } from '@virtualkitchenco/multiverse-sdk';
|
|
@@ -102,9 +139,6 @@ const myTool = wrap(langchainTool, {
|
|
|
102
139
|
effects: (output, world) => [
|
|
103
140
|
{ operation: 'create', collection: 'orders', id: output.id, data: output },
|
|
104
141
|
],
|
|
105
|
-
invariants: [
|
|
106
|
-
{ collection: 'inventory', field: 'quantity', condition: 'gte', value: 0 },
|
|
107
|
-
],
|
|
108
142
|
});
|
|
109
143
|
```
|
|
110
144
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virtualkitchenco/multiverse-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
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.17"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.11.0",
|