@molroo-io/sdk 0.8.3 → 0.9.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.
- package/dist/cjs/errors.d.ts +1 -1
- package/dist/cjs/errors.d.ts.map +1 -1
- package/dist/cjs/errors.js +2 -1
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/persona/conversation.d.ts +63 -0
- package/dist/cjs/persona/conversation.d.ts.map +1 -0
- package/dist/cjs/persona/conversation.js +70 -0
- package/dist/cjs/persona.d.ts +197 -2
- package/dist/cjs/persona.d.ts.map +1 -1
- package/dist/cjs/persona.js +215 -2
- package/dist/cjs/shared/errors.d.ts +28 -2
- package/dist/cjs/shared/errors.d.ts.map +1 -1
- package/dist/cjs/shared/errors.js +29 -2
- package/dist/cjs/types.d.ts +52 -5
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js +2 -1
- package/dist/cjs/world/world.d.ts +5 -2
- package/dist/cjs/world/world.d.ts.map +1 -1
- package/dist/cjs/world/world.js +5 -2
- package/dist/esm/errors.d.ts +1 -1
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/errors.js +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/persona/conversation.d.ts +63 -0
- package/dist/esm/persona/conversation.d.ts.map +1 -0
- package/dist/esm/persona/conversation.js +66 -0
- package/dist/esm/persona.d.ts +197 -2
- package/dist/esm/persona.d.ts.map +1 -1
- package/dist/esm/persona.js +216 -3
- package/dist/esm/shared/errors.d.ts +28 -2
- package/dist/esm/shared/errors.d.ts.map +1 -1
- package/dist/esm/shared/errors.js +28 -1
- package/dist/esm/types.d.ts +52 -5
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +1 -1
- package/dist/esm/world/world.d.ts +5 -2
- package/dist/esm/world/world.d.ts.map +1 -1
- package/dist/esm/world/world.js +5 -2
- package/package.json +1 -1
package/dist/esm/persona.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { resolveLLM } from './llm/resolve';
|
|
2
|
-
import { MolrooApiError } from './errors';
|
|
2
|
+
import { MolrooApiError, MolrooErrorCode } from './errors';
|
|
3
3
|
import { createApiClient, unwrap } from './api-client';
|
|
4
4
|
import { postPerceive } from './persona/memory-pipeline';
|
|
5
5
|
import { chat as chatOrchestrator } from './persona/chat-orchestrator';
|
|
6
|
+
import { Conversation } from './persona/conversation';
|
|
6
7
|
// ── SDK Persona Types ──
|
|
7
8
|
const DEFAULT_BASE_URL = 'https://api.molroo.io';
|
|
8
9
|
// ── MolrooPersona ──
|
|
@@ -24,9 +25,11 @@ export class MolrooPersona {
|
|
|
24
25
|
this.appraisalMode = config.appraisalMode ?? 'direct';
|
|
25
26
|
}
|
|
26
27
|
// ── Properties ──
|
|
28
|
+
/** Unique persona instance ID. */
|
|
27
29
|
get id() {
|
|
28
30
|
return this._personaId;
|
|
29
31
|
}
|
|
32
|
+
/** @deprecated Use {@link id} instead. */
|
|
30
33
|
get personaId() {
|
|
31
34
|
return this._personaId;
|
|
32
35
|
}
|
|
@@ -35,7 +38,7 @@ export class MolrooPersona {
|
|
|
35
38
|
if (typeof input === 'string') {
|
|
36
39
|
if (!config.llm) {
|
|
37
40
|
throw new MolrooApiError('LLM adapter is required when using description string. ' +
|
|
38
|
-
'Provide llm option or use explicit PersonaConfigData.',
|
|
41
|
+
'Provide llm option or use explicit PersonaConfigData.', MolrooErrorCode.LLM_REQUIRED, 400);
|
|
39
42
|
}
|
|
40
43
|
const { generatePersona } = await import('./generate/persona');
|
|
41
44
|
const llm = await resolveLLM(config.llm);
|
|
@@ -70,6 +73,23 @@ export class MolrooPersona {
|
|
|
70
73
|
static async generate(config, description) {
|
|
71
74
|
return MolrooPersona.create(config, description);
|
|
72
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Connect to an existing persona by ID.
|
|
78
|
+
*
|
|
79
|
+
* @param config - Connection configuration (apiKey required).
|
|
80
|
+
* @param personaId - The persona instance ID to connect to.
|
|
81
|
+
* @returns A connected MolrooPersona instance.
|
|
82
|
+
*
|
|
83
|
+
* @deprecated Use {@link Molroo.connectPersona} instead.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const sera = await MolrooPersona.connect(
|
|
88
|
+
* { apiKey: 'mk_...', llm: openaiAdapter },
|
|
89
|
+
* 'persona_abc123'
|
|
90
|
+
* );
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
73
93
|
static async connect(config, personaId) {
|
|
74
94
|
const [llm, engineLlm] = await Promise.all([
|
|
75
95
|
config.llm ? resolveLLM(config.llm) : undefined,
|
|
@@ -82,6 +102,12 @@ export class MolrooPersona {
|
|
|
82
102
|
});
|
|
83
103
|
return persona;
|
|
84
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* List all personas for the authenticated tenant.
|
|
107
|
+
*
|
|
108
|
+
* @param config - API connection config.
|
|
109
|
+
* @returns Paginated list of persona summaries.
|
|
110
|
+
*/
|
|
85
111
|
static async listPersonas(config) {
|
|
86
112
|
const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
87
113
|
const client = createApiClient(baseUrl, config.apiKey);
|
|
@@ -89,6 +115,14 @@ export class MolrooPersona {
|
|
|
89
115
|
return unwrap(data);
|
|
90
116
|
}
|
|
91
117
|
// ── Runtime ──
|
|
118
|
+
/**
|
|
119
|
+
* Send a stimulus to the persona's emotion engine and get the updated emotional response.
|
|
120
|
+
* This is the low-level API — for common cases, prefer {@link hear}, {@link experience}, or {@link chat}.
|
|
121
|
+
*
|
|
122
|
+
* @param message - The stimulus text (user message, event description, etc.).
|
|
123
|
+
* @param options - Appraisal, source, relationship context, and other options.
|
|
124
|
+
* @returns Emotion engine response with VAD, discrete emotion, and side effects.
|
|
125
|
+
*/
|
|
92
126
|
async perceive(message, options) {
|
|
93
127
|
const eventType = options?.type ?? 'chat_message';
|
|
94
128
|
const sourceName = typeof options?.from === 'string'
|
|
@@ -125,9 +159,92 @@ export class MolrooPersona {
|
|
|
125
159
|
}
|
|
126
160
|
return response;
|
|
127
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Send a custom event with a required appraisal vector.
|
|
164
|
+
*
|
|
165
|
+
* @param type - Custom event type (e.g., 'gift_received', 'argument').
|
|
166
|
+
* @param description - Human-readable event description.
|
|
167
|
+
* @param options - Must include a pre-computed appraisal vector.
|
|
168
|
+
* @returns Emotion engine response.
|
|
169
|
+
*/
|
|
128
170
|
async event(type, description, options) {
|
|
129
171
|
return this.perceive(description, { ...options, type });
|
|
130
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Perceive a chat message from another entity. Simplest wrapper over {@link perceive}.
|
|
175
|
+
*
|
|
176
|
+
* @param message - The incoming message text.
|
|
177
|
+
* @param from - Who sent the message (name string or structured context).
|
|
178
|
+
* @returns Emotion engine response.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const response = await persona.hear('How are you?', 'Alice');
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
async hear(message, from) {
|
|
186
|
+
return this.perceive(message, { from, type: 'chat_message' });
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Perceive an environmental or narrative event with a pre-computed appraisal.
|
|
190
|
+
*
|
|
191
|
+
* @param description - What happened (e.g., 'The sun set over the ocean').
|
|
192
|
+
* @param appraisal - 9-dimensional Scherer CPM appraisal vector.
|
|
193
|
+
* @returns Emotion engine response.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const response = await persona.experience('Received a surprise gift', {
|
|
198
|
+
* goal_relevance: 0.8, goal_congruence: 0.9, expectedness: 0.2,
|
|
199
|
+
* controllability: 0.5, agency: 0.3, norm_compatibility: 0.8,
|
|
200
|
+
* internal_standards: 0.7, adjustment_potential: 0.6, urgency: 0.3,
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
async experience(description, appraisal) {
|
|
205
|
+
return this.perceive(description, { appraisal, type: 'environment' });
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Perceive a social interaction with relationship context for trust/intimacy computation.
|
|
209
|
+
*
|
|
210
|
+
* @param message - The interaction message.
|
|
211
|
+
* @param from - Who the interaction is from.
|
|
212
|
+
* @param relationship - Current relationship state (closeness, trust, familiarity).
|
|
213
|
+
* @returns Emotion engine response including socialUpdates.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* const response = await persona.socialize('I missed you!', 'Bob', {
|
|
218
|
+
* closeness: 0.7, trust: 0.8, familiarity: 0.9, type: 'friend',
|
|
219
|
+
* });
|
|
220
|
+
* console.log(response.socialUpdates); // trust/intimacy deltas
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
async socialize(message, from, relationship) {
|
|
224
|
+
return this.perceive(message, { from, relationshipContext: relationship, type: 'chat_message' });
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Send a message and get an LLM-generated response with emotion processing.
|
|
228
|
+
* This is the primary method for conversational interactions.
|
|
229
|
+
*
|
|
230
|
+
* The system prompt is assembled server-side via {@link getPromptContext} and includes:
|
|
231
|
+
* identity, behavioral instructions, current psychological state, expression style,
|
|
232
|
+
* and consumerSuffix. Do NOT duplicate these in consumerSuffix.
|
|
233
|
+
*
|
|
234
|
+
* @param message - User message to respond to.
|
|
235
|
+
* @param options - Conversation history, source entity, and app-specific suffix.
|
|
236
|
+
* @returns LLM response text, emotion data, and updated conversation history.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* const result = await persona.chat('Tell me about yourself', {
|
|
241
|
+
* from: 'Alice',
|
|
242
|
+
* history: previousMessages,
|
|
243
|
+
* });
|
|
244
|
+
* console.log(result.text); // LLM response
|
|
245
|
+
* console.log(result.response.emotion); // updated VAD
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
131
248
|
async chat(message, options) {
|
|
132
249
|
const llm = this.requireLLM();
|
|
133
250
|
const deps = {
|
|
@@ -143,6 +260,13 @@ export class MolrooPersona {
|
|
|
143
260
|
};
|
|
144
261
|
return chatOrchestrator(deps, message, options);
|
|
145
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Advance persona simulation time. Triggers idle decay, body budget recovery,
|
|
265
|
+
* need regression, and timeline advancement.
|
|
266
|
+
*
|
|
267
|
+
* @param seconds - Number of seconds to advance (must be >= 1).
|
|
268
|
+
* @returns Any pending internal events generated by threshold checks.
|
|
269
|
+
*/
|
|
146
270
|
async tick(seconds) {
|
|
147
271
|
const { data } = await this.client.POST('/personas/{id}/tick', {
|
|
148
272
|
params: { path: { id: this._personaId } },
|
|
@@ -150,17 +274,50 @@ export class MolrooPersona {
|
|
|
150
274
|
});
|
|
151
275
|
return unwrap(data);
|
|
152
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Override the persona's current emotion to a specific VAD point.
|
|
279
|
+
* Useful for testing or narrative-driven emotion control.
|
|
280
|
+
*
|
|
281
|
+
* @param vad - Partial VAD values to set (V: valence, A: arousal, D: dominance).
|
|
282
|
+
*/
|
|
153
283
|
async setEmotion(vad) {
|
|
154
284
|
await this.client.POST('/personas/{id}/emotion', {
|
|
155
285
|
params: { path: { id: this._personaId } },
|
|
156
286
|
body: { vad },
|
|
157
287
|
});
|
|
158
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Append text to the next system prompt. One-shot: cleared after the next
|
|
291
|
+
* `getPromptContext()` / `chat()` call.
|
|
292
|
+
*/
|
|
293
|
+
async annotate(text) {
|
|
294
|
+
await this.client.POST('/personas/{id}/annotate', {
|
|
295
|
+
params: { path: { id: this._personaId } },
|
|
296
|
+
body: { text },
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Force the next response text. The persona will use this exact text
|
|
301
|
+
* instead of generating via LLM on the next `chat()` call.
|
|
302
|
+
*/
|
|
303
|
+
async setNextResponse(text) {
|
|
304
|
+
await this.client.POST('/personas/{id}/next-response', {
|
|
305
|
+
params: { path: { id: this._personaId } },
|
|
306
|
+
body: { text },
|
|
307
|
+
});
|
|
308
|
+
}
|
|
159
309
|
/**
|
|
160
310
|
* Set StyleProfile extracted from a text corpus.
|
|
161
311
|
* Once set, expression constraints (promptText) are automatically
|
|
162
312
|
* included in getPromptContext() and modulated by current emotion.
|
|
163
313
|
*/
|
|
314
|
+
/**
|
|
315
|
+
* Set a StyleProfile for expression-aware prompt generation.
|
|
316
|
+
* Once set, expression constraints are automatically included in
|
|
317
|
+
* {@link getPromptContext} and modulated by current emotion.
|
|
318
|
+
*
|
|
319
|
+
* @param profile - StyleProfile object (lexical, structural, register features, etc.).
|
|
320
|
+
*/
|
|
164
321
|
async setStyleProfile(profile) {
|
|
165
322
|
await this.client.POST('/personas/{id}/style-profile', {
|
|
166
323
|
params: { path: { id: this._personaId } },
|
|
@@ -184,18 +341,34 @@ export class MolrooPersona {
|
|
|
184
341
|
return result.styleProfile;
|
|
185
342
|
}
|
|
186
343
|
// ── State ──
|
|
344
|
+
/**
|
|
345
|
+
* Get the persona's current emotional and psychological state.
|
|
346
|
+
*
|
|
347
|
+
* @returns Current emotion (VAD + discrete), mood, somatic sensations, and narrative.
|
|
348
|
+
*/
|
|
187
349
|
async getState() {
|
|
188
350
|
const { data } = await this.client.GET('/personas/{id}/state', {
|
|
189
351
|
params: { path: { id: this._personaId } },
|
|
190
352
|
});
|
|
191
353
|
return unwrap(data);
|
|
192
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Get a full snapshot of the persona (config + engine state).
|
|
357
|
+
* Useful for backup, migration, or debugging.
|
|
358
|
+
*
|
|
359
|
+
* @returns Full persona snapshot including config and internal state.
|
|
360
|
+
*/
|
|
193
361
|
async getSnapshot() {
|
|
194
362
|
const { data } = await this.client.GET('/personas/{id}/snapshot', {
|
|
195
363
|
params: { path: { id: this._personaId } },
|
|
196
364
|
});
|
|
197
365
|
return unwrap(data);
|
|
198
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Restore a persona from a snapshot. Overwrites current state entirely.
|
|
369
|
+
*
|
|
370
|
+
* @param snapshot - Full persona snapshot to restore.
|
|
371
|
+
*/
|
|
199
372
|
async putSnapshot(snapshot) {
|
|
200
373
|
await this.client.PUT('/personas/{id}/snapshot', {
|
|
201
374
|
params: { path: { id: this._personaId } },
|
|
@@ -203,6 +376,11 @@ export class MolrooPersona {
|
|
|
203
376
|
});
|
|
204
377
|
}
|
|
205
378
|
// ── Config ──
|
|
379
|
+
/**
|
|
380
|
+
* Partially update persona configuration (identity, personality, goals, etc.).
|
|
381
|
+
*
|
|
382
|
+
* @param updates - Fields to update. Only provided fields are changed.
|
|
383
|
+
*/
|
|
206
384
|
async patch(updates) {
|
|
207
385
|
await this.client.PATCH('/personas/{id}', {
|
|
208
386
|
params: { path: { id: this._personaId } },
|
|
@@ -210,6 +388,9 @@ export class MolrooPersona {
|
|
|
210
388
|
});
|
|
211
389
|
}
|
|
212
390
|
// ── Lifecycle ──
|
|
391
|
+
/**
|
|
392
|
+
* Soft-delete this persona. Can be restored within retention period via {@link restore}.
|
|
393
|
+
*/
|
|
213
394
|
async destroy() {
|
|
214
395
|
if (this._personaId) {
|
|
215
396
|
await this.client.DELETE('/personas/{id}', {
|
|
@@ -217,6 +398,7 @@ export class MolrooPersona {
|
|
|
217
398
|
});
|
|
218
399
|
}
|
|
219
400
|
}
|
|
401
|
+
/** Restore a soft-deleted persona. */
|
|
220
402
|
async restore() {
|
|
221
403
|
if (this._personaId) {
|
|
222
404
|
await this.client.POST('/personas/{id}/restore', {
|
|
@@ -225,6 +407,18 @@ export class MolrooPersona {
|
|
|
225
407
|
}
|
|
226
408
|
}
|
|
227
409
|
// ── Prompt / Memory ──
|
|
410
|
+
/**
|
|
411
|
+
* Fetch the server-assembled system prompt for this persona.
|
|
412
|
+
* Includes identity, behavioral instructions, psychological state,
|
|
413
|
+
* expression style (if StyleProfile set), and consumerSuffix.
|
|
414
|
+
*
|
|
415
|
+
* Called internally by {@link chat}. Use directly when building custom LLM pipelines.
|
|
416
|
+
*
|
|
417
|
+
* @param consumerSuffix - App-specific context appended to the system prompt.
|
|
418
|
+
* Do NOT include identity, personality, or emotion — these are already in the prompt.
|
|
419
|
+
* @param sourceEntity - Name of the conversation partner (for interlocutor-aware prompts).
|
|
420
|
+
* @returns System prompt string and structured persona prompt data.
|
|
421
|
+
*/
|
|
228
422
|
async getPromptContext(consumerSuffix, sourceEntity) {
|
|
229
423
|
const { data } = await this.client.POST('/personas/{id}/prompt-context', {
|
|
230
424
|
params: { path: { id: this._personaId } },
|
|
@@ -235,6 +429,25 @@ export class MolrooPersona {
|
|
|
235
429
|
});
|
|
236
430
|
return unwrap(data);
|
|
237
431
|
}
|
|
432
|
+
// ── Conversation ──
|
|
433
|
+
/**
|
|
434
|
+
* Create a conversation session that auto-manages message history.
|
|
435
|
+
* Each `.send()` call automatically appends to the history.
|
|
436
|
+
*
|
|
437
|
+
* @param options - Max messages or custom chat options.
|
|
438
|
+
* @returns A new Conversation instance bound to this persona.
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```typescript
|
|
442
|
+
* const conv = persona.conversation({ maxMessages: 20 });
|
|
443
|
+
* const r1 = await conv.send('Hello!');
|
|
444
|
+
* const r2 = await conv.send('Tell me more'); // history auto-managed
|
|
445
|
+
* console.log(conv.messages); // full conversation
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
conversation(options) {
|
|
449
|
+
return new Conversation(this, options);
|
|
450
|
+
}
|
|
238
451
|
// ── Private ──
|
|
239
452
|
get memoryPipelineDeps() {
|
|
240
453
|
return {
|
|
@@ -247,7 +460,7 @@ export class MolrooPersona {
|
|
|
247
460
|
}
|
|
248
461
|
requireLLM() {
|
|
249
462
|
if (!this.llm) {
|
|
250
|
-
throw new MolrooApiError('LLM adapter is required for chat(). Provide llm option, or use perceive() directly.',
|
|
463
|
+
throw new MolrooApiError('LLM adapter is required for chat(). Provide llm option, or use perceive() directly.', MolrooErrorCode.LLM_NOT_CONFIGURED, 400);
|
|
251
464
|
}
|
|
252
465
|
return this.llm;
|
|
253
466
|
}
|
|
@@ -3,14 +3,40 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `instanceof MolrooApiError` catches ALL API errors (persona + world).
|
|
5
5
|
* `instanceof WorldApiError` catches world-only errors.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { MolrooApiError, MolrooErrorCode } from '@molroo-io/sdk';
|
|
10
|
+
*
|
|
11
|
+
* try {
|
|
12
|
+
* await persona.chat('hello');
|
|
13
|
+
* } catch (e) {
|
|
14
|
+
* if (e instanceof MolrooApiError && e.code === MolrooErrorCode.LLM_NOT_CONFIGURED) {
|
|
15
|
+
* console.log('Please provide an LLM adapter');
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
6
19
|
*/
|
|
20
|
+
/** Machine-readable error codes for programmatic error handling. */
|
|
21
|
+
export declare enum MolrooErrorCode {
|
|
22
|
+
/** LLM adapter is required for this operation (e.g., description-based create). */
|
|
23
|
+
LLM_REQUIRED = "LLM_REQUIRED",
|
|
24
|
+
/** LLM adapter was not configured at initialization (e.g., calling chat() without llm). */
|
|
25
|
+
LLM_NOT_CONFIGURED = "LLM_NOT_CONFIGURED",
|
|
26
|
+
/** Requested entity (persona, world, etc.) was not found. */
|
|
27
|
+
ENTITY_NOT_FOUND = "ENTITY_NOT_FOUND",
|
|
28
|
+
/** Authentication failed — invalid or missing API key. */
|
|
29
|
+
UNAUTHORIZED = "UNAUTHORIZED",
|
|
30
|
+
/** API returned an unexpected error not covered by other codes. */
|
|
31
|
+
API_ERROR = "API_ERROR"
|
|
32
|
+
}
|
|
7
33
|
export declare class MolrooApiError extends Error {
|
|
8
|
-
/** Machine-readable error code
|
|
34
|
+
/** Machine-readable error code. Use {@link MolrooErrorCode} for type-safe matching. */
|
|
9
35
|
readonly code: string;
|
|
10
36
|
/** HTTP status code. */
|
|
11
37
|
readonly status: number;
|
|
12
38
|
constructor(message: string,
|
|
13
|
-
/** Machine-readable error code
|
|
39
|
+
/** Machine-readable error code. Use {@link MolrooErrorCode} for type-safe matching. */
|
|
14
40
|
code: string,
|
|
15
41
|
/** HTTP status code. */
|
|
16
42
|
status: number);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/shared/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/shared/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,oEAAoE;AACpE,oBAAY,eAAe;IACzB,mFAAmF;IACnF,YAAY,iBAAiB;IAC7B,2FAA2F;IAC3F,kBAAkB,uBAAuB;IACzC,6DAA6D;IAC7D,gBAAgB,qBAAqB;IACrC,0DAA0D;IAC1D,YAAY,iBAAiB;IAC7B,mEAAmE;IACnE,SAAS,cAAc;CACxB;AAED,qBAAa,cAAe,SAAQ,KAAK;IAGrC,uFAAuF;aACvE,IAAI,EAAE,MAAM;IAC5B,wBAAwB;aACR,MAAM,EAAE,MAAM;gBAJ9B,OAAO,EAAE,MAAM;IACf,uFAAuF;IACvE,IAAI,EAAE,MAAM;IAC5B,wBAAwB;IACR,MAAM,EAAE,MAAM;CAKjC;AAED,qBAAa,aAAc,SAAQ,cAAc;gBACnC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI1D"}
|
|
@@ -3,10 +3,37 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `instanceof MolrooApiError` catches ALL API errors (persona + world).
|
|
5
5
|
* `instanceof WorldApiError` catches world-only errors.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { MolrooApiError, MolrooErrorCode } from '@molroo-io/sdk';
|
|
10
|
+
*
|
|
11
|
+
* try {
|
|
12
|
+
* await persona.chat('hello');
|
|
13
|
+
* } catch (e) {
|
|
14
|
+
* if (e instanceof MolrooApiError && e.code === MolrooErrorCode.LLM_NOT_CONFIGURED) {
|
|
15
|
+
* console.log('Please provide an LLM adapter');
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
6
19
|
*/
|
|
20
|
+
/** Machine-readable error codes for programmatic error handling. */
|
|
21
|
+
export var MolrooErrorCode;
|
|
22
|
+
(function (MolrooErrorCode) {
|
|
23
|
+
/** LLM adapter is required for this operation (e.g., description-based create). */
|
|
24
|
+
MolrooErrorCode["LLM_REQUIRED"] = "LLM_REQUIRED";
|
|
25
|
+
/** LLM adapter was not configured at initialization (e.g., calling chat() without llm). */
|
|
26
|
+
MolrooErrorCode["LLM_NOT_CONFIGURED"] = "LLM_NOT_CONFIGURED";
|
|
27
|
+
/** Requested entity (persona, world, etc.) was not found. */
|
|
28
|
+
MolrooErrorCode["ENTITY_NOT_FOUND"] = "ENTITY_NOT_FOUND";
|
|
29
|
+
/** Authentication failed — invalid or missing API key. */
|
|
30
|
+
MolrooErrorCode["UNAUTHORIZED"] = "UNAUTHORIZED";
|
|
31
|
+
/** API returned an unexpected error not covered by other codes. */
|
|
32
|
+
MolrooErrorCode["API_ERROR"] = "API_ERROR";
|
|
33
|
+
})(MolrooErrorCode || (MolrooErrorCode = {}));
|
|
7
34
|
export class MolrooApiError extends Error {
|
|
8
35
|
constructor(message,
|
|
9
|
-
/** Machine-readable error code
|
|
36
|
+
/** Machine-readable error code. Use {@link MolrooErrorCode} for type-safe matching. */
|
|
10
37
|
code,
|
|
11
38
|
/** HTTP status code. */
|
|
12
39
|
status) {
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -21,6 +21,19 @@ export interface InterlocutorContext {
|
|
|
21
21
|
/** Arbitrary key-value extensions rendered as subsections. */
|
|
22
22
|
extensions?: Record<string, string>;
|
|
23
23
|
}
|
|
24
|
+
/** Relationship state between two entities, used for social update computation. */
|
|
25
|
+
export interface RelationshipContext {
|
|
26
|
+
/** Overall closeness/intimacy (0–1). */
|
|
27
|
+
closeness?: number;
|
|
28
|
+
/** Mutual trust level (0–1). */
|
|
29
|
+
trust?: number;
|
|
30
|
+
/** How well they know each other (0–1). */
|
|
31
|
+
familiarity?: number;
|
|
32
|
+
/** Relationship type label. */
|
|
33
|
+
type?: 'friend' | 'romantic' | 'authority' | 'stranger' | string;
|
|
34
|
+
/** Additional relationship-specific fields. */
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
24
37
|
type PerceiveBody = RequestBody<'/personas/{id}/perceive', 'post'>;
|
|
25
38
|
export type PerceiveEvent = PerceiveBody['event'];
|
|
26
39
|
export type PerceiveContext = NonNullable<PerceiveBody['context']>;
|
|
@@ -38,7 +51,7 @@ export interface PerceiveOptions {
|
|
|
38
51
|
type?: string;
|
|
39
52
|
/** Low-level stimulus overrides (bodyBudgetDelta, vadOverride, etc.). */
|
|
40
53
|
stimulus?: PerceiveEvent['stimulus'];
|
|
41
|
-
/** Extra payload fields merged into event.payload alongside message. */
|
|
54
|
+
/** Extra payload fields merged into event.payload alongside message (app-specific data). */
|
|
42
55
|
payload?: Record<string, unknown>;
|
|
43
56
|
/** Prior episodic memories for context-aware appraisal. */
|
|
44
57
|
priorEpisodes?: Episode[];
|
|
@@ -46,7 +59,7 @@ export interface PerceiveOptions {
|
|
|
46
59
|
* When provided, the engine computes trust/intimacy/proximity deltas
|
|
47
60
|
* and emits socialUpdates in the response.
|
|
48
61
|
* Typically sourced from World-level storage (D1). */
|
|
49
|
-
relationshipContext?:
|
|
62
|
+
relationshipContext?: RelationshipContext;
|
|
50
63
|
/** Skip saving memoryEpisode to the episode store. Default: false. */
|
|
51
64
|
skipMemory?: boolean;
|
|
52
65
|
}
|
|
@@ -58,7 +71,34 @@ export interface EventAppraisal {
|
|
|
58
71
|
relationship: 'friend' | 'romantic' | 'authority' | 'stranger';
|
|
59
72
|
intensity: number;
|
|
60
73
|
}
|
|
61
|
-
|
|
74
|
+
/** Full dynamic state returned by the persona state endpoint. */
|
|
75
|
+
export interface PersonaDynamicState {
|
|
76
|
+
emotion: {
|
|
77
|
+
vad: VAD;
|
|
78
|
+
discrete?: {
|
|
79
|
+
primary: string;
|
|
80
|
+
secondary?: string;
|
|
81
|
+
intensity: number;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
mood?: {
|
|
85
|
+
vad: VAD;
|
|
86
|
+
};
|
|
87
|
+
somatic?: string[];
|
|
88
|
+
narrative?: {
|
|
89
|
+
tone: number;
|
|
90
|
+
agency: number;
|
|
91
|
+
coherence: number;
|
|
92
|
+
};
|
|
93
|
+
goals?: Goal[];
|
|
94
|
+
bodyBudget?: number;
|
|
95
|
+
soulStage?: {
|
|
96
|
+
id: number;
|
|
97
|
+
name: string;
|
|
98
|
+
};
|
|
99
|
+
/** Additional engine-specific fields. */
|
|
100
|
+
[key: string]: unknown;
|
|
101
|
+
}
|
|
62
102
|
export type BlendRatio = Record<string, number>;
|
|
63
103
|
export interface AgentResponse {
|
|
64
104
|
text?: string;
|
|
@@ -143,7 +183,14 @@ export interface SocialUpdate {
|
|
|
143
183
|
dimension: string;
|
|
144
184
|
delta: number;
|
|
145
185
|
}
|
|
146
|
-
|
|
186
|
+
/** Full persona snapshot including engine state, config, and metadata. */
|
|
187
|
+
export interface PersonaSnapshot {
|
|
188
|
+
config?: PersonaConfigData;
|
|
189
|
+
state?: State;
|
|
190
|
+
engineVersion?: string;
|
|
191
|
+
/** Additional engine-specific fields. */
|
|
192
|
+
[key: string]: unknown;
|
|
193
|
+
}
|
|
147
194
|
/**
|
|
148
195
|
* HEXACO-PI-R personality domain traits (Ashton & Lee, 2007).
|
|
149
196
|
* Each value ranges from 0 (low) to 1 (high).
|
|
@@ -272,5 +319,5 @@ export interface State {
|
|
|
272
319
|
regulation: RegulationState;
|
|
273
320
|
prevMaskIntegrity?: number;
|
|
274
321
|
}
|
|
275
|
-
export { MolrooApiError } from './errors';
|
|
322
|
+
export { MolrooApiError, MolrooErrorCode } from './errors';
|
|
276
323
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAI7C,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AACpD,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAIjF,MAAM,MAAM,WAAW,CACrB,CAAC,SAAS,MAAM,KAAK,EACrB,CAAC,SAAS,MAAM,GAAG,KAAK,GAAG,OAAO,IAChC,KAAK,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE;YAAE,kBAAkB,EAAE,MAAM,CAAC,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,CAAC,GAC1F,CAAC,GACD,KAAK,CAAC;AAeV;;2EAE2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAID,KAAK,YAAY,GAAG,WAAW,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;AACnE,MAAM,MAAM,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AAkB,CAAC;IAClC,UAAU,EAAE,eAAe,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAID,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/esm/types.js
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
// Pipeline: Engine Zod schemas → @hono/zod-openapi → OpenAPI JSON → openapi-typescript → api.d.ts
|
|
9
9
|
// ============================================================================
|
|
10
10
|
// ── Error (re-exported from errors.ts) ──
|
|
11
|
-
export { MolrooApiError } from './errors';
|
|
11
|
+
export { MolrooApiError, MolrooErrorCode } from './errors';
|
|
@@ -99,8 +99,11 @@ export declare class Molroo {
|
|
|
99
99
|
*/
|
|
100
100
|
getWorld(id: string): Promise<World>;
|
|
101
101
|
/**
|
|
102
|
-
* List worlds
|
|
103
|
-
* efficiency when only metadata is needed.
|
|
102
|
+
* List worlds for the authenticated tenant.
|
|
103
|
+
* Returns raw data objects (not World instances) for efficiency when only metadata is needed.
|
|
104
|
+
*
|
|
105
|
+
* @param options - Pagination options (limit, cursor).
|
|
106
|
+
* @returns Paginated list of world data and next cursor.
|
|
104
107
|
*/
|
|
105
108
|
listWorlds(options?: PaginationOptions): Promise<{
|
|
106
109
|
worlds: WorldData[];
|
|
@@ -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,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,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CA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AAC;IAmB1C;;;;;;OAMG;IACG,UAAU,CACd,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC;QAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CA6B/D"}
|
package/dist/esm/world/world.js
CHANGED
|
@@ -111,8 +111,11 @@ export class Molroo {
|
|
|
111
111
|
return new World(this._client, toWorldData(raw));
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
* List worlds
|
|
115
|
-
* efficiency when only metadata is needed.
|
|
114
|
+
* List worlds for the authenticated tenant.
|
|
115
|
+
* Returns raw data objects (not World instances) for efficiency when only metadata is needed.
|
|
116
|
+
*
|
|
117
|
+
* @param options - Pagination options (limit, cursor).
|
|
118
|
+
* @returns Paginated list of world data and next cursor.
|
|
116
119
|
*/
|
|
117
120
|
async listWorlds(options) {
|
|
118
121
|
const { data } = await this._client.GET('/worlds', {
|