@molroo-io/sdk 0.5.2 → 0.6.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 +59 -81
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/persona.d.ts +26 -0
- package/dist/cjs/persona.d.ts.map +1 -1
- package/dist/cjs/persona.js +23 -0
- package/dist/cjs/world/client.d.ts +3 -3
- package/dist/cjs/world/client.js +3 -3
- package/dist/cjs/world/index.d.ts +4 -4
- package/dist/cjs/world/index.d.ts.map +1 -1
- package/dist/cjs/world/index.js +4 -4
- package/dist/cjs/world/types.d.ts +4 -4
- package/dist/cjs/world/types.d.ts.map +1 -1
- package/dist/cjs/world/{village.d.ts → world-domain.d.ts} +25 -25
- package/dist/cjs/world/world-domain.d.ts.map +1 -0
- package/dist/cjs/world/{village.js → world-domain.js} +36 -36
- package/dist/cjs/world/world-persona.d.ts +5 -5
- package/dist/cjs/world/world-persona.d.ts.map +1 -1
- package/dist/cjs/world/world-persona.js +14 -14
- package/dist/cjs/world/world.d.ts +61 -17
- package/dist/cjs/world/world.d.ts.map +1 -1
- package/dist/cjs/world/world.js +70 -27
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/persona.d.ts +26 -0
- package/dist/esm/persona.d.ts.map +1 -1
- package/dist/esm/persona.js +23 -0
- package/dist/esm/world/client.d.ts +3 -3
- package/dist/esm/world/client.js +3 -3
- package/dist/esm/world/index.d.ts +4 -4
- package/dist/esm/world/index.d.ts.map +1 -1
- package/dist/esm/world/index.js +2 -2
- package/dist/esm/world/types.d.ts +4 -4
- package/dist/esm/world/types.d.ts.map +1 -1
- package/dist/esm/world/{village.d.ts → world-domain.d.ts} +25 -25
- package/dist/esm/world/world-domain.d.ts.map +1 -0
- package/dist/esm/world/{village.js → world-domain.js} +34 -34
- package/dist/esm/world/world-persona.d.ts +5 -5
- package/dist/esm/world/world-persona.d.ts.map +1 -1
- package/dist/esm/world/world-persona.js +14 -14
- package/dist/esm/world/world.d.ts +61 -17
- package/dist/esm/world/world.d.ts.map +1 -1
- package/dist/esm/world/world.js +68 -25
- package/package.json +1 -1
- package/dist/cjs/world/village.d.ts.map +0 -1
- package/dist/esm/world/village.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
// INFO: @F001 Domain class wrapping
|
|
3
|
+
exports.World = void 0;
|
|
4
|
+
// INFO: @F001 Domain class wrapping World API — see plan step 3
|
|
5
5
|
const client_1 = require("./client");
|
|
6
6
|
const world_persona_1 = require("./world-persona");
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
@@ -34,16 +34,16 @@ function fromApiAppraisal(raw) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
// ---------------------------------------------------------------------------
|
|
37
|
-
//
|
|
37
|
+
// World class (domain)
|
|
38
38
|
// ---------------------------------------------------------------------------
|
|
39
39
|
/**
|
|
40
|
-
* Represents a
|
|
40
|
+
* Represents a world and exposes domain methods for personas, actions,
|
|
41
41
|
* relationships, interactions, and events.
|
|
42
42
|
*
|
|
43
|
-
* Instances are obtained via {@link
|
|
43
|
+
* Instances are obtained via {@link Molroo.createWorld} or {@link Molroo.getWorld}.
|
|
44
44
|
*/
|
|
45
|
-
class
|
|
46
|
-
/** @internal — use
|
|
45
|
+
class World {
|
|
46
|
+
/** @internal — use Molroo.createWorld / Molroo.getWorld instead. */
|
|
47
47
|
constructor(client, data) {
|
|
48
48
|
this._client = client;
|
|
49
49
|
this._data = { ...data };
|
|
@@ -64,16 +64,16 @@ class Village {
|
|
|
64
64
|
get responseRule() {
|
|
65
65
|
return this._data.responseRule;
|
|
66
66
|
}
|
|
67
|
-
/** Returns a readonly snapshot of the
|
|
67
|
+
/** Returns a readonly snapshot of the world data. */
|
|
68
68
|
get data() {
|
|
69
69
|
return this._data;
|
|
70
70
|
}
|
|
71
|
-
// --
|
|
71
|
+
// -- World CRUD ---------------------------------------------------------
|
|
72
72
|
/**
|
|
73
|
-
* Update
|
|
73
|
+
* Update world properties. Applies an optimistic local update on success.
|
|
74
74
|
*/
|
|
75
75
|
async update(options) {
|
|
76
|
-
await this._client.PATCH('/
|
|
76
|
+
await this._client.PATCH('/worlds/{id}', {
|
|
77
77
|
params: { path: { id: this.id } },
|
|
78
78
|
body: {
|
|
79
79
|
name: options.name,
|
|
@@ -92,9 +92,9 @@ class Village {
|
|
|
92
92
|
if (options.responseRule !== undefined)
|
|
93
93
|
this._data.responseRule = options.responseRule;
|
|
94
94
|
}
|
|
95
|
-
/** Soft-delete this
|
|
95
|
+
/** Soft-delete this world. */
|
|
96
96
|
async delete() {
|
|
97
|
-
await this._client.DELETE('/
|
|
97
|
+
await this._client.DELETE('/worlds/{id}', {
|
|
98
98
|
params: { path: { id: this.id } },
|
|
99
99
|
});
|
|
100
100
|
}
|
|
@@ -124,7 +124,7 @@ class Village {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const { data } = await this._client.POST('/
|
|
127
|
+
const { data } = await this._client.POST('/worlds/{id}/personas', {
|
|
128
128
|
params: { path: { id: this.id } },
|
|
129
129
|
body: body,
|
|
130
130
|
});
|
|
@@ -135,9 +135,9 @@ class Village {
|
|
|
135
135
|
createdAt: raw.created_at,
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
-
/** List all personas in this
|
|
138
|
+
/** List all personas in this world. */
|
|
139
139
|
async listPersonas() {
|
|
140
|
-
const { data } = await this._client.GET('/
|
|
140
|
+
const { data } = await this._client.GET('/worlds/{id}/personas', {
|
|
141
141
|
params: { path: { id: this.id } },
|
|
142
142
|
});
|
|
143
143
|
const raw = (0, client_1.unwrap)(data);
|
|
@@ -145,14 +145,14 @@ class Village {
|
|
|
145
145
|
}
|
|
146
146
|
/** Get a single persona by ID. */
|
|
147
147
|
async getPersona(personaId) {
|
|
148
|
-
const { data } = await this._client.GET('/
|
|
148
|
+
const { data } = await this._client.GET('/worlds/{id}/personas/{pid}', {
|
|
149
149
|
params: { path: { id: this.id, pid: personaId } },
|
|
150
150
|
});
|
|
151
151
|
return (0, client_1.unwrap)(data);
|
|
152
152
|
}
|
|
153
|
-
/** Remove a persona from this
|
|
153
|
+
/** Remove a persona from this world. */
|
|
154
154
|
async removePersona(personaId) {
|
|
155
|
-
await this._client.DELETE('/
|
|
155
|
+
await this._client.DELETE('/worlds/{id}/personas/{pid}', {
|
|
156
156
|
params: { path: { id: this.id, pid: personaId } },
|
|
157
157
|
});
|
|
158
158
|
}
|
|
@@ -165,7 +165,7 @@ class Village {
|
|
|
165
165
|
*
|
|
166
166
|
* @example
|
|
167
167
|
* ```typescript
|
|
168
|
-
* const mina =
|
|
168
|
+
* const mina = world.persona('mina', { llm: adapter });
|
|
169
169
|
* const r = await mina.react('flirt', {
|
|
170
170
|
* actor: 'yongjun',
|
|
171
171
|
* prompt: '거실에서 용준이 민아에게 윙크했다.',
|
|
@@ -176,9 +176,9 @@ class Village {
|
|
|
176
176
|
return new world_persona_1.WorldPersona(this._client, this.id, personaId, options);
|
|
177
177
|
}
|
|
178
178
|
// -- Actions --------------------------------------------------------------
|
|
179
|
-
/** Create a custom action in this
|
|
179
|
+
/** Create a custom action in this world. */
|
|
180
180
|
async createAction(options) {
|
|
181
|
-
const { data } = await this._client.POST('/
|
|
181
|
+
const { data } = await this._client.POST('/worlds/{id}/actions', {
|
|
182
182
|
params: { path: { id: this.id } },
|
|
183
183
|
body: {
|
|
184
184
|
name: options.name,
|
|
@@ -189,9 +189,9 @@ class Village {
|
|
|
189
189
|
const raw = (0, client_1.unwrap)(data);
|
|
190
190
|
return { id: raw.id, name: raw.name };
|
|
191
191
|
}
|
|
192
|
-
/** List all actions (defaults + custom) in this
|
|
192
|
+
/** List all actions (defaults + custom) in this world. */
|
|
193
193
|
async listActions() {
|
|
194
|
-
const { data } = await this._client.GET('/
|
|
194
|
+
const { data } = await this._client.GET('/worlds/{id}/actions', {
|
|
195
195
|
params: { path: { id: this.id } },
|
|
196
196
|
});
|
|
197
197
|
const raw = (0, client_1.unwrap)(data);
|
|
@@ -202,16 +202,16 @@ class Village {
|
|
|
202
202
|
isDefault: a.is_default,
|
|
203
203
|
}));
|
|
204
204
|
}
|
|
205
|
-
/** Delete a custom action from this
|
|
205
|
+
/** Delete a custom action from this world. */
|
|
206
206
|
async deleteAction(actionId) {
|
|
207
|
-
await this._client.DELETE('/
|
|
207
|
+
await this._client.DELETE('/worlds/{id}/actions/{aid}', {
|
|
208
208
|
params: { path: { id: this.id, aid: actionId } },
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
// -- Relationships --------------------------------------------------------
|
|
212
|
-
/** Set (upsert) a relationship in this
|
|
212
|
+
/** Set (upsert) a relationship in this world. */
|
|
213
213
|
async setRelationship(options) {
|
|
214
|
-
await this._client.PUT('/
|
|
214
|
+
await this._client.PUT('/worlds/{id}/relationships', {
|
|
215
215
|
params: { path: { id: this.id } },
|
|
216
216
|
body: {
|
|
217
217
|
source_type: options.source.type,
|
|
@@ -225,9 +225,9 @@ class Village {
|
|
|
225
225
|
},
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
|
-
/** List all relationships in this
|
|
228
|
+
/** List all relationships in this world. */
|
|
229
229
|
async listRelationships() {
|
|
230
|
-
const { data } = await this._client.GET('/
|
|
230
|
+
const { data } = await this._client.GET('/worlds/{id}/relationships', {
|
|
231
231
|
params: { path: { id: this.id } },
|
|
232
232
|
});
|
|
233
233
|
const raw = (0, client_1.unwrap)(data);
|
|
@@ -235,14 +235,14 @@ class Village {
|
|
|
235
235
|
}
|
|
236
236
|
/** Delete a relationship by ID. */
|
|
237
237
|
async deleteRelationship(relationshipId) {
|
|
238
|
-
await this._client.DELETE('/
|
|
238
|
+
await this._client.DELETE('/worlds/{id}/relationships/{rid}', {
|
|
239
239
|
params: { path: { id: this.id, rid: relationshipId } },
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
// -- Interaction ----------------------------------------------------------
|
|
243
|
-
/** Execute an interaction in this
|
|
243
|
+
/** Execute an interaction in this world. */
|
|
244
244
|
async interact(options) {
|
|
245
|
-
const { data } = await this._client.POST('/
|
|
245
|
+
const { data } = await this._client.POST('/worlds/{id}/interact', {
|
|
246
246
|
params: { path: { id: this.id } },
|
|
247
247
|
body: {
|
|
248
248
|
target_persona_id: options.target,
|
|
@@ -257,9 +257,9 @@ class Village {
|
|
|
257
257
|
return (0, client_1.unwrap)(data);
|
|
258
258
|
}
|
|
259
259
|
// -- Events ---------------------------------------------------------------
|
|
260
|
-
/** Retrieve the event log for this
|
|
260
|
+
/** Retrieve the event log for this world. */
|
|
261
261
|
async getEvents(options) {
|
|
262
|
-
const { data } = await this._client.GET('/
|
|
262
|
+
const { data } = await this._client.GET('/worlds/{id}/events', {
|
|
263
263
|
params: {
|
|
264
264
|
path: { id: this.id },
|
|
265
265
|
query: {
|
|
@@ -275,4 +275,4 @@ class Village {
|
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
exports.
|
|
278
|
+
exports.World = World;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* WorldPersona — a persona handle within a
|
|
2
|
+
* WorldPersona — a persona handle within a world.
|
|
3
3
|
*
|
|
4
4
|
* "누가 말하는가? 페르소나가 말한다."
|
|
5
5
|
*
|
|
@@ -100,13 +100,13 @@ export interface WorldPersonaOptions {
|
|
|
100
100
|
}
|
|
101
101
|
export declare class WorldPersona {
|
|
102
102
|
private readonly _client;
|
|
103
|
-
private readonly
|
|
103
|
+
private readonly _worldId;
|
|
104
104
|
private readonly _personaId;
|
|
105
105
|
private readonly _llm?;
|
|
106
106
|
/** Cached persona detail (config + state). Invalidated on interact(). */
|
|
107
107
|
private _detailCache;
|
|
108
|
-
/** @internal — use
|
|
109
|
-
constructor(client: ApiClient,
|
|
108
|
+
/** @internal — use World.persona() instead. */
|
|
109
|
+
constructor(client: ApiClient, worldId: string, personaId: string, options?: WorldPersonaOptions);
|
|
110
110
|
get id(): string;
|
|
111
111
|
/** Fetch full persona detail (config + state). Cached per-instance. */
|
|
112
112
|
getDetail(): Promise<PersonaDetail>;
|
|
@@ -155,7 +155,7 @@ export declare class WorldPersona {
|
|
|
155
155
|
*
|
|
156
156
|
* @example
|
|
157
157
|
* ```typescript
|
|
158
|
-
* const mina =
|
|
158
|
+
* const mina = world.persona('mina', { llm: adapter });
|
|
159
159
|
*
|
|
160
160
|
* // Plain text reaction
|
|
161
161
|
* const r1 = await mina.react('flirt', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world-persona.d.ts","sourceRoot":"","sources":["../../../src/world/world-persona.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAwBjD,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC;AAMlC,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,QAAQ,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE,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3
|
exports.WorldPersona = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* WorldPersona — a persona handle within a
|
|
5
|
+
* WorldPersona — a persona handle within a world.
|
|
6
6
|
*
|
|
7
7
|
* "누가 말하는가? 페르소나가 말한다."
|
|
8
8
|
*
|
|
@@ -28,12 +28,12 @@ function toApiAppraisal(v) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
class WorldPersona {
|
|
31
|
-
/** @internal — use
|
|
32
|
-
constructor(client,
|
|
31
|
+
/** @internal — use World.persona() instead. */
|
|
32
|
+
constructor(client, worldId, personaId, options) {
|
|
33
33
|
/** Cached persona detail (config + state). Invalidated on interact(). */
|
|
34
34
|
this._detailCache = null;
|
|
35
35
|
this._client = client;
|
|
36
|
-
this.
|
|
36
|
+
this._worldId = worldId;
|
|
37
37
|
this._personaId = personaId;
|
|
38
38
|
this._llm = options?.llm;
|
|
39
39
|
}
|
|
@@ -45,8 +45,8 @@ class WorldPersona {
|
|
|
45
45
|
async getDetail() {
|
|
46
46
|
if (this._detailCache)
|
|
47
47
|
return this._detailCache;
|
|
48
|
-
const { data } = await this._client.GET('/
|
|
49
|
-
params: { path: { id: this.
|
|
48
|
+
const { data } = await this._client.GET('/worlds/{id}/personas/{pid}', {
|
|
49
|
+
params: { path: { id: this._worldId, pid: this._personaId } },
|
|
50
50
|
});
|
|
51
51
|
const raw = (0, client_1.unwrap)(data);
|
|
52
52
|
const config = typeof raw.config === 'string' ? JSON.parse(raw.config) : raw.config;
|
|
@@ -71,8 +71,8 @@ class WorldPersona {
|
|
|
71
71
|
}
|
|
72
72
|
/** Get LLM system prompt assembled from all persona subsystems + world context. */
|
|
73
73
|
async getPromptContext(sourceEntity) {
|
|
74
|
-
const { data } = await this._client.POST('/
|
|
75
|
-
params: { path: { id: this.
|
|
74
|
+
const { data } = await this._client.POST('/worlds/{id}/personas/{pid}/prompt-context', {
|
|
75
|
+
params: { path: { id: this._worldId, pid: this._personaId } },
|
|
76
76
|
body: sourceEntity ? { sourceEntity } : {},
|
|
77
77
|
});
|
|
78
78
|
return (0, client_1.unwrap)(data);
|
|
@@ -84,8 +84,8 @@ class WorldPersona {
|
|
|
84
84
|
*/
|
|
85
85
|
async interact(action, options) {
|
|
86
86
|
this._detailCache = null; // invalidate
|
|
87
|
-
const { data } = await this._client.POST('/
|
|
88
|
-
params: { path: { id: this.
|
|
87
|
+
const { data } = await this._client.POST('/worlds/{id}/interact', {
|
|
88
|
+
params: { path: { id: this._worldId } },
|
|
89
89
|
body: {
|
|
90
90
|
target_persona_id: this._personaId,
|
|
91
91
|
action_name: action || undefined,
|
|
@@ -110,8 +110,8 @@ class WorldPersona {
|
|
|
110
110
|
*/
|
|
111
111
|
async tick(seconds) {
|
|
112
112
|
this._detailCache = null; // invalidate — state changes after tick
|
|
113
|
-
const { data } = await this._client.POST('/
|
|
114
|
-
params: { path: { id: this.
|
|
113
|
+
const { data } = await this._client.POST('/worlds/{id}/personas/{pid}/tick', {
|
|
114
|
+
params: { path: { id: this._worldId, pid: this._personaId } },
|
|
115
115
|
body: { seconds },
|
|
116
116
|
});
|
|
117
117
|
return (0, client_1.unwrap)(data);
|
|
@@ -125,7 +125,7 @@ class WorldPersona {
|
|
|
125
125
|
*
|
|
126
126
|
* @example
|
|
127
127
|
* ```typescript
|
|
128
|
-
* const mina =
|
|
128
|
+
* const mina = world.persona('mina', { llm: adapter });
|
|
129
129
|
*
|
|
130
130
|
* // Plain text reaction
|
|
131
131
|
* const r1 = await mina.react('flirt', {
|
|
@@ -149,7 +149,7 @@ class WorldPersona {
|
|
|
149
149
|
*/
|
|
150
150
|
async react(action, options) {
|
|
151
151
|
if (!this._llm) {
|
|
152
|
-
throw new Error('WorldPersona.react() requires an LLM adapter. Pass { llm } to
|
|
152
|
+
throw new Error('WorldPersona.react() requires an LLM adapter. Pass { llm } to world.persona().');
|
|
153
153
|
}
|
|
154
154
|
// 1. Interact — emotion engine processes the action
|
|
155
155
|
const interactResult = await this.interact(action, {
|
|
@@ -1,40 +1,84 @@
|
|
|
1
1
|
import { type ApiClient } from './client';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import { World } from './world-domain';
|
|
3
|
+
import { MolrooPersona } from '../persona';
|
|
4
|
+
import type { PersonaSummary } from '../persona';
|
|
5
|
+
import type { PersonaConfigData } from '../types';
|
|
6
|
+
import type { LLMInput } from '../llm/resolve';
|
|
7
|
+
import type { MemoryAdapter, MemoryConfig, RecallLimits } from '../memory/types';
|
|
8
|
+
import type { EventAdapter } from '../events/types';
|
|
9
|
+
import type { WorldData, CreateWorldOptions, PaginationOptions } from './types';
|
|
10
|
+
export interface MolrooOptions {
|
|
5
11
|
apiKey: string;
|
|
6
12
|
baseUrl?: string;
|
|
7
13
|
}
|
|
14
|
+
/** Per-persona options passed when creating/connecting personas via the Molroo client. */
|
|
15
|
+
export interface PersonaOptions {
|
|
16
|
+
llm?: LLMInput;
|
|
17
|
+
engineLlm?: LLMInput;
|
|
18
|
+
memory?: MemoryAdapter | MemoryConfig;
|
|
19
|
+
recall?: RecallLimits;
|
|
20
|
+
events?: EventAdapter;
|
|
21
|
+
}
|
|
8
22
|
/**
|
|
9
|
-
*
|
|
23
|
+
* Unified entry point for the molroo SDK.
|
|
10
24
|
*
|
|
11
25
|
* @example
|
|
12
26
|
* ```typescript
|
|
13
|
-
* import {
|
|
27
|
+
* import { Molroo } from '@molroo-io/sdk/world';
|
|
28
|
+
*
|
|
29
|
+
* const molroo = new Molroo({ apiKey: 'mk_live_...' });
|
|
30
|
+
*
|
|
31
|
+
* // Persona
|
|
32
|
+
* const sera = await molroo.createPersona({ identity: { name: 'Sera' }, ... }, { llm });
|
|
33
|
+
* await sera.chat('Hello!');
|
|
14
34
|
*
|
|
15
|
-
*
|
|
16
|
-
* const
|
|
17
|
-
*
|
|
35
|
+
* // World
|
|
36
|
+
* const world = await molroo.createWorld({ name: 'Cafe' });
|
|
37
|
+
* await world.addPersona({ personaConfigId: sera.id, config: {...} });
|
|
18
38
|
* ```
|
|
19
39
|
*/
|
|
20
|
-
export declare class
|
|
40
|
+
export declare class Molroo {
|
|
21
41
|
/** @internal — exposed for advanced use only. */
|
|
22
42
|
readonly _client: ApiClient;
|
|
23
|
-
|
|
43
|
+
private readonly _baseUrl;
|
|
44
|
+
private readonly _apiKey;
|
|
45
|
+
constructor(options: MolrooOptions);
|
|
46
|
+
/**
|
|
47
|
+
* Create a new persona and return a connected {@link MolrooPersona} instance.
|
|
48
|
+
*/
|
|
49
|
+
createPersona(personaConfig: PersonaConfigData, options?: PersonaOptions): Promise<MolrooPersona>;
|
|
50
|
+
/**
|
|
51
|
+
* Connect to an existing persona by ID.
|
|
52
|
+
*/
|
|
53
|
+
connectPersona(personaId: string, options?: PersonaOptions): Promise<MolrooPersona>;
|
|
54
|
+
/**
|
|
55
|
+
* Generate a persona from a natural-language description, create it on the API,
|
|
56
|
+
* and return a connected {@link MolrooPersona} instance.
|
|
57
|
+
*/
|
|
58
|
+
generatePersona(description: string, options: PersonaOptions & {
|
|
59
|
+
llm: LLMInput;
|
|
60
|
+
}): Promise<MolrooPersona>;
|
|
61
|
+
/**
|
|
62
|
+
* List all personas for the authenticated tenant.
|
|
63
|
+
*/
|
|
64
|
+
listPersonas(): Promise<{
|
|
65
|
+
personas: PersonaSummary[];
|
|
66
|
+
nextCursor?: string;
|
|
67
|
+
}>;
|
|
24
68
|
/**
|
|
25
|
-
* Create a new
|
|
69
|
+
* Create a new world and return a {@link World} instance.
|
|
26
70
|
*/
|
|
27
|
-
|
|
71
|
+
createWorld(options: CreateWorldOptions): Promise<World>;
|
|
28
72
|
/**
|
|
29
|
-
* Fetch an existing
|
|
73
|
+
* Fetch an existing world by ID and return a {@link World} instance.
|
|
30
74
|
*/
|
|
31
|
-
|
|
75
|
+
getWorld(id: string): Promise<World>;
|
|
32
76
|
/**
|
|
33
|
-
* List
|
|
77
|
+
* List worlds. Returns raw data objects (not World instances) for
|
|
34
78
|
* efficiency when only metadata is needed.
|
|
35
79
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
80
|
+
listWorlds(options?: PaginationOptions): Promise<{
|
|
81
|
+
worlds: WorldData[];
|
|
38
82
|
nextCursor: string | null;
|
|
39
83
|
}>;
|
|
40
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../../src/world/world.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../../src/world/world.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAiCjB,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,0FAA0F;AAC1F,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,MAAM,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;IACtC,MAA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esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
// INFO: @F001 Top-level
|
|
3
|
+
exports.Molroo = void 0;
|
|
4
|
+
// INFO: @F001 Top-level SDK entry point — see plan step 4
|
|
5
5
|
const client_1 = require("./client");
|
|
6
|
-
const
|
|
6
|
+
const world_domain_1 = require("./world-domain");
|
|
7
|
+
const persona_1 = require("../persona");
|
|
7
8
|
// ---------------------------------------------------------------------------
|
|
8
9
|
// Internal helper
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
10
|
-
/** Map raw snake_case API
|
|
11
|
-
function
|
|
11
|
+
/** Map raw snake_case API response to camelCase WorldData. */
|
|
12
|
+
function toWorldData(raw) {
|
|
12
13
|
return {
|
|
13
14
|
id: raw.id,
|
|
14
15
|
tenantId: raw.tenant_id,
|
|
@@ -22,32 +23,74 @@ function toVillageData(raw) {
|
|
|
22
23
|
}
|
|
23
24
|
const DEFAULT_BASE_URL = 'https://api.molroo.io';
|
|
24
25
|
// ---------------------------------------------------------------------------
|
|
25
|
-
//
|
|
26
|
+
// Molroo class
|
|
26
27
|
// ---------------------------------------------------------------------------
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
+
* Unified entry point for the molroo SDK.
|
|
29
30
|
*
|
|
30
31
|
* @example
|
|
31
32
|
* ```typescript
|
|
32
|
-
* import {
|
|
33
|
+
* import { Molroo } from '@molroo-io/sdk/world';
|
|
33
34
|
*
|
|
34
|
-
* const
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* const molroo = new Molroo({ apiKey: 'mk_live_...' });
|
|
36
|
+
*
|
|
37
|
+
* // Persona
|
|
38
|
+
* const sera = await molroo.createPersona({ identity: { name: 'Sera' }, ... }, { llm });
|
|
39
|
+
* await sera.chat('Hello!');
|
|
40
|
+
*
|
|
41
|
+
* // World
|
|
42
|
+
* const world = await molroo.createWorld({ name: 'Cafe' });
|
|
43
|
+
* await world.addPersona({ personaConfigId: sera.id, config: {...} });
|
|
37
44
|
* ```
|
|
38
45
|
*/
|
|
39
|
-
class
|
|
46
|
+
class Molroo {
|
|
40
47
|
constructor(options) {
|
|
48
|
+
this._baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
49
|
+
this._apiKey = options.apiKey;
|
|
41
50
|
this._client = (0, client_1.createWorldClient)({
|
|
42
|
-
baseUrl:
|
|
43
|
-
apiKey:
|
|
51
|
+
baseUrl: this._baseUrl,
|
|
52
|
+
apiKey: this._apiKey,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// Persona
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
/**
|
|
59
|
+
* Create a new persona and return a connected {@link MolrooPersona} instance.
|
|
60
|
+
*/
|
|
61
|
+
async createPersona(personaConfig, options) {
|
|
62
|
+
return persona_1.MolrooPersona.create({ baseUrl: this._baseUrl, apiKey: this._apiKey, ...options }, personaConfig);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Connect to an existing persona by ID.
|
|
66
|
+
*/
|
|
67
|
+
async connectPersona(personaId, options) {
|
|
68
|
+
return persona_1.MolrooPersona.connect({ baseUrl: this._baseUrl, apiKey: this._apiKey, ...options }, personaId);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Generate a persona from a natural-language description, create it on the API,
|
|
72
|
+
* and return a connected {@link MolrooPersona} instance.
|
|
73
|
+
*/
|
|
74
|
+
async generatePersona(description, options) {
|
|
75
|
+
return persona_1.MolrooPersona.generate({ baseUrl: this._baseUrl, apiKey: this._apiKey, ...options }, description);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* List all personas for the authenticated tenant.
|
|
79
|
+
*/
|
|
80
|
+
async listPersonas() {
|
|
81
|
+
return persona_1.MolrooPersona.listPersonas({
|
|
82
|
+
baseUrl: this._baseUrl,
|
|
83
|
+
apiKey: this._apiKey,
|
|
44
84
|
});
|
|
45
85
|
}
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
// World
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
46
89
|
/**
|
|
47
|
-
* Create a new
|
|
90
|
+
* Create a new world and return a {@link World} instance.
|
|
48
91
|
*/
|
|
49
|
-
async
|
|
50
|
-
const { data } = await this._client.POST('/
|
|
92
|
+
async createWorld(options) {
|
|
93
|
+
const { data } = await this._client.POST('/worlds', {
|
|
51
94
|
body: {
|
|
52
95
|
name: options.name,
|
|
53
96
|
description: options.description,
|
|
@@ -56,24 +99,24 @@ class World {
|
|
|
56
99
|
},
|
|
57
100
|
});
|
|
58
101
|
const raw = (0, client_1.unwrap)(data);
|
|
59
|
-
return new
|
|
102
|
+
return new world_domain_1.World(this._client, toWorldData(raw));
|
|
60
103
|
}
|
|
61
104
|
/**
|
|
62
|
-
* Fetch an existing
|
|
105
|
+
* Fetch an existing world by ID and return a {@link World} instance.
|
|
63
106
|
*/
|
|
64
|
-
async
|
|
65
|
-
const { data } = await this._client.GET('/
|
|
107
|
+
async getWorld(id) {
|
|
108
|
+
const { data } = await this._client.GET('/worlds/{id}', {
|
|
66
109
|
params: { path: { id } },
|
|
67
110
|
});
|
|
68
111
|
const raw = (0, client_1.unwrap)(data);
|
|
69
|
-
return new
|
|
112
|
+
return new world_domain_1.World(this._client, toWorldData(raw));
|
|
70
113
|
}
|
|
71
114
|
/**
|
|
72
|
-
* List
|
|
115
|
+
* List worlds. Returns raw data objects (not World instances) for
|
|
73
116
|
* efficiency when only metadata is needed.
|
|
74
117
|
*/
|
|
75
|
-
async
|
|
76
|
-
const { data } = await this._client.GET('/
|
|
118
|
+
async listWorlds(options) {
|
|
119
|
+
const { data } = await this._client.GET('/worlds', {
|
|
77
120
|
params: {
|
|
78
121
|
query: {
|
|
79
122
|
limit: options?.limit?.toString(),
|
|
@@ -83,9 +126,9 @@ class World {
|
|
|
83
126
|
});
|
|
84
127
|
const raw = (0, client_1.unwrap)(data);
|
|
85
128
|
return {
|
|
86
|
-
|
|
129
|
+
worlds: (raw.worlds ?? []).map(toWorldData),
|
|
87
130
|
nextCursor: raw.nextCursor ?? null,
|
|
88
131
|
};
|
|
89
132
|
}
|
|
90
133
|
}
|
|
91
|
-
exports.
|
|
134
|
+
exports.Molroo = Molroo;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
* const result = await persona.chat('Hello!');
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
+
export { Molroo } from './world/world';
|
|
34
|
+
export type { MolrooOptions, PersonaOptions } from './world/world';
|
|
33
35
|
export { MolrooPersona } from './persona';
|
|
34
36
|
export { MolrooApiError } from './types';
|
|
35
37
|
export type { LLMAdapter, Message, GenerateTextOptions, GenerateObjectOptions, } from './llm/adapter';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,YAAY,EACV,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACzE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,YAAY,EACV,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,YAAY,EACV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,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