@molroo-io/sdk 0.9.0 → 0.9.1
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/events/types.d.ts +1 -1
- package/dist/cjs/events/types.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/llm/resolve.d.ts.map +1 -1
- package/dist/cjs/llm/resolve.js +2 -1
- package/dist/cjs/llm/schema.d.ts +0 -114
- package/dist/cjs/llm/schema.d.ts.map +1 -1
- package/dist/cjs/llm/schema.js +1 -44
- package/dist/cjs/persona/chat-orchestrator.d.ts +18 -3
- package/dist/cjs/persona/chat-orchestrator.d.ts.map +1 -1
- package/dist/cjs/persona/chat-orchestrator.js +29 -109
- package/dist/cjs/persona/conversation.d.ts +22 -1
- package/dist/cjs/persona/conversation.d.ts.map +1 -1
- package/dist/cjs/persona/conversation.js +2 -0
- package/dist/cjs/persona/memory-pipeline.d.ts.map +1 -1
- package/dist/cjs/persona/memory-pipeline.js +30 -4
- package/dist/cjs/persona.d.ts +270 -36
- package/dist/cjs/persona.d.ts.map +1 -1
- package/dist/cjs/persona.js +238 -19
- package/dist/cjs/shared/errors.d.ts +5 -1
- package/dist/cjs/shared/errors.d.ts.map +1 -1
- package/dist/cjs/shared/errors.js +4 -0
- package/dist/cjs/types.d.ts +18 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/world/world-persona.d.ts +20 -5
- package/dist/cjs/world/world-persona.d.ts.map +1 -1
- package/dist/cjs/world/world-persona.js +21 -5
- package/dist/cjs/world/world.d.ts +23 -3
- package/dist/cjs/world/world.d.ts.map +1 -1
- package/dist/cjs/world/world.js +24 -1
- package/dist/esm/events/types.d.ts +1 -1
- package/dist/esm/events/types.d.ts.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/llm/resolve.d.ts.map +1 -1
- package/dist/esm/llm/resolve.js +2 -1
- package/dist/esm/llm/schema.d.ts +0 -114
- package/dist/esm/llm/schema.d.ts.map +1 -1
- package/dist/esm/llm/schema.js +0 -43
- package/dist/esm/persona/chat-orchestrator.d.ts +18 -3
- package/dist/esm/persona/chat-orchestrator.d.ts.map +1 -1
- package/dist/esm/persona/chat-orchestrator.js +29 -109
- package/dist/esm/persona/conversation.d.ts +22 -1
- package/dist/esm/persona/conversation.d.ts.map +1 -1
- package/dist/esm/persona/conversation.js +2 -0
- package/dist/esm/persona/memory-pipeline.d.ts.map +1 -1
- package/dist/esm/persona/memory-pipeline.js +30 -4
- package/dist/esm/persona.d.ts +270 -36
- package/dist/esm/persona.d.ts.map +1 -1
- package/dist/esm/persona.js +237 -19
- package/dist/esm/shared/errors.d.ts +5 -1
- package/dist/esm/shared/errors.d.ts.map +1 -1
- package/dist/esm/shared/errors.js +4 -0
- package/dist/esm/types.d.ts +18 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/world/world-persona.d.ts +20 -5
- package/dist/esm/world/world-persona.d.ts.map +1 -1
- package/dist/esm/world/world-persona.js +21 -5
- package/dist/esm/world/world.d.ts +23 -3
- package/dist/esm/world/world.d.ts.map +1 -1
- package/dist/esm/world/world.js +24 -1
- package/package.json +1 -1
package/dist/esm/persona.js
CHANGED
|
@@ -22,7 +22,6 @@ export class MolrooPersona {
|
|
|
22
22
|
this.events = config.events ?? null;
|
|
23
23
|
this.memoryAdapter = config.memory ?? null;
|
|
24
24
|
this.memoryRecallConfig = config.recall;
|
|
25
|
-
this.appraisalMode = config.appraisalMode ?? 'direct';
|
|
26
25
|
}
|
|
27
26
|
// ── Properties ──
|
|
28
27
|
/** Unique persona instance ID. */
|
|
@@ -171,15 +170,41 @@ export class MolrooPersona {
|
|
|
171
170
|
return this.perceive(description, { ...options, type });
|
|
172
171
|
}
|
|
173
172
|
/**
|
|
174
|
-
*
|
|
173
|
+
* Register a received message with the emotion engine and update the persona's emotional state.
|
|
175
174
|
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
175
|
+
* This is the **core API** for the `hear() + getState()` pattern. Apps that build their own
|
|
176
|
+
* LLM prompts should call `hear()` after each user message to keep the emotion engine in sync,
|
|
177
|
+
* then call `getState()` to read updated state for prompt assembly.
|
|
179
178
|
*
|
|
180
|
-
* @
|
|
179
|
+
* Use {@link chat} when you want the SDK to handle prompt assembly and LLM orchestration.
|
|
180
|
+
* Use `hear()` + `getState()` when your app owns the LLM call.
|
|
181
|
+
*
|
|
182
|
+
* @param message - The incoming message text (user utterance, narration, etc.).
|
|
183
|
+
* @param from - Who sent the message. A plain string is used as the source entity name.
|
|
184
|
+
* Pass an {@link InterlocutorContext} object for richer context (description, extensions).
|
|
185
|
+
* @returns Emotion engine response with updated VAD, discrete emotion, and any side effects
|
|
186
|
+
* (memory episodes, social updates, stage transitions, etc.).
|
|
187
|
+
*
|
|
188
|
+
* @example Basic hear + getState pattern
|
|
181
189
|
* ```typescript
|
|
182
|
-
*
|
|
190
|
+
* // Step 1: register message with emotion engine
|
|
191
|
+
* await persona.hear('You did a great job today!', 'Alice');
|
|
192
|
+
*
|
|
193
|
+
* // Step 2: read updated psychological state
|
|
194
|
+
* const state = await persona.getState();
|
|
195
|
+
*
|
|
196
|
+
* // Step 3: assemble your own system prompt
|
|
197
|
+
* const systemPrompt = buildPrompt(myPersonaConfig, state);
|
|
198
|
+
* const { text } = await myLLM.generate({ system: systemPrompt, messages });
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @example With structured interlocutor context
|
|
202
|
+
* ```typescript
|
|
203
|
+
* await persona.hear('I need your help', {
|
|
204
|
+
* name: 'Alice',
|
|
205
|
+
* description: 'A regular customer, slightly anxious',
|
|
206
|
+
* extensions: { mood: 'stressed' },
|
|
207
|
+
* });
|
|
183
208
|
* ```
|
|
184
209
|
*/
|
|
185
210
|
async hear(message, from) {
|
|
@@ -254,8 +279,7 @@ export class MolrooPersona {
|
|
|
254
279
|
memoryAdapter: this.memoryAdapter,
|
|
255
280
|
memoryRecallConfig: this.memoryRecallConfig,
|
|
256
281
|
events: this.events,
|
|
257
|
-
|
|
258
|
-
getPromptContext: (suffix, source) => this.getPromptContext(suffix, source),
|
|
282
|
+
getPromptContext: (opts) => this.getPromptContext(opts),
|
|
259
283
|
perceive: (msg, opts) => this.perceive(msg, opts),
|
|
260
284
|
};
|
|
261
285
|
return chatOrchestrator(deps, message, options);
|
|
@@ -342,9 +366,44 @@ export class MolrooPersona {
|
|
|
342
366
|
}
|
|
343
367
|
// ── State ──
|
|
344
368
|
/**
|
|
345
|
-
*
|
|
369
|
+
* Fetch the full psychological state of this persona from the emotion engine.
|
|
370
|
+
*
|
|
371
|
+
* Returns all active subsystems: emotion, soul stage, mask, mood, somatic sensations,
|
|
372
|
+
* narrative self-perception, emotion regulation, self-esteem, TMT state, and relationship.
|
|
373
|
+
*
|
|
374
|
+
* This is the primary data source for apps that build their own LLM prompts. Combine with
|
|
375
|
+
* `hear()` to implement the recommended `hear() + getState()` pattern:
|
|
376
|
+
*
|
|
377
|
+
* ```
|
|
378
|
+
* user message → hear() → emotion engine updates state → getState() → build prompt → LLM
|
|
379
|
+
* ```
|
|
346
380
|
*
|
|
347
|
-
* @returns
|
|
381
|
+
* @returns All psychological subsystems as a {@link PersonaState} object.
|
|
382
|
+
*
|
|
383
|
+
* @example Building a custom system prompt
|
|
384
|
+
* ```typescript
|
|
385
|
+
* const state = await persona.getState();
|
|
386
|
+
*
|
|
387
|
+
* const lines: string[] = [
|
|
388
|
+
* `You are ${name}.`,
|
|
389
|
+
* `Emotion: ${state.emotion.discrete.primary} (${state.emotion.discrete.intensity.toFixed(2)})`,
|
|
390
|
+
* ];
|
|
391
|
+
*
|
|
392
|
+
* if (state.mood) {
|
|
393
|
+
* lines.push(`Mood: valence=${state.mood.V.toFixed(2)} arousal=${state.mood.A.toFixed(2)}`);
|
|
394
|
+
* }
|
|
395
|
+
* if (state.narrative) {
|
|
396
|
+
* lines.push(`Narrative: agency=${state.narrative.agency.toFixed(2)} tone=${state.narrative.tone.toFixed(2)}`);
|
|
397
|
+
* }
|
|
398
|
+
* if (state.selfEsteem) {
|
|
399
|
+
* lines.push(`Self-esteem: ${state.selfEsteem.global.toFixed(2)}`);
|
|
400
|
+
* }
|
|
401
|
+
* if (state.tmt && state.tmt.mortalitySalience > 0.5) {
|
|
402
|
+
* lines.push(`Existential tension is high. Defense mode: ${state.tmt.defenseMode}`);
|
|
403
|
+
* }
|
|
404
|
+
*
|
|
405
|
+
* const systemPrompt = lines.join('\n');
|
|
406
|
+
* ```
|
|
348
407
|
*/
|
|
349
408
|
async getState() {
|
|
350
409
|
const { data } = await this.client.GET('/personas/{id}/state', {
|
|
@@ -352,6 +411,24 @@ export class MolrooPersona {
|
|
|
352
411
|
});
|
|
353
412
|
return unwrap(data);
|
|
354
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Fetch this persona's identity config (identity, personality, goals).
|
|
416
|
+
*
|
|
417
|
+
* Returns a {@link PersonaIdentity} suitable for passing to {@link buildPrompt}
|
|
418
|
+
* when assembling system prompts entirely client-side.
|
|
419
|
+
*/
|
|
420
|
+
async getIdentity() {
|
|
421
|
+
const { data } = await this.client.GET('/personas/{id}', {
|
|
422
|
+
params: { path: { id: this._personaId } },
|
|
423
|
+
});
|
|
424
|
+
const result = unwrap(data);
|
|
425
|
+
const config = result?.persona?.config ?? {};
|
|
426
|
+
return {
|
|
427
|
+
identity: config.identity ?? { name: 'Unknown' },
|
|
428
|
+
personality: config.personality ?? { O: 0.5, C: 0.5, E: 0.5, A: 0.5, N: 0.5, H: 0.5 },
|
|
429
|
+
goals: config.goals,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
355
432
|
/**
|
|
356
433
|
* Get a full snapshot of the persona (config + engine state).
|
|
357
434
|
* Useful for backup, migration, or debugging.
|
|
@@ -409,21 +486,58 @@ export class MolrooPersona {
|
|
|
409
486
|
// ── Prompt / Memory ──
|
|
410
487
|
/**
|
|
411
488
|
* 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
489
|
*
|
|
415
|
-
*
|
|
490
|
+
* The server builds a complete system prompt from the persona's live state. It includes:
|
|
491
|
+
* 1. **Identity** — name, role, core values, speaking style, description
|
|
492
|
+
* 2. **Behavioral instructions** — stay in character, embody state, match language
|
|
493
|
+
* 3. **Psychological state** — emotion, mood, somatic, narrative, goals (from live engine)
|
|
494
|
+
* 4. **Expression constraints** — message length, formality, patterns (only if StyleProfile set)
|
|
495
|
+
* 5. **consumerRules** — behavioral constraints and absolute rules (e.g., "Never break character")
|
|
496
|
+
* 6. **consumerExamples** — few-shot example messages for style/behavior reference
|
|
497
|
+
* 7. **consumerSuffix** — your app-specific context, appended last
|
|
416
498
|
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
499
|
+
* This is a **middle-tier API** — between the low-level `getState()` (raw data) and the
|
|
500
|
+
* high-level `chat()` (full orchestration). Use it when you want to drive the LLM yourself
|
|
501
|
+
* but still benefit from server-side prompt assembly.
|
|
502
|
+
*
|
|
503
|
+
* Called automatically by {@link chat}. Call directly when:
|
|
504
|
+
* - You use a custom LLM framework not supported by the SDK
|
|
505
|
+
* - You need to inspect or transform the system prompt before sending
|
|
506
|
+
* - You need prompt + state in a single round-trip (avoids a separate `getState()` call)
|
|
507
|
+
*
|
|
508
|
+
* **Do NOT** include identity, personality, or emotion in `consumerSuffix` — those are
|
|
509
|
+
* already present. Duplicating them wastes tokens and may confuse the LLM.
|
|
510
|
+
*
|
|
511
|
+
* @param options - Prompt context options.
|
|
512
|
+
* @param options.consumerSuffix - Free-form app-specific context appended to the system prompt as-is.
|
|
513
|
+
* Examples: scene description, available actions, current quest objective.
|
|
514
|
+
* @param options.consumerRules - Behavioral constraints and absolute rules.
|
|
515
|
+
* Examples: "Never break character", "Always respond in Korean", "Do not discuss competitors".
|
|
516
|
+
* @param options.consumerExamples - Few-shot example messages for style/behavior reference.
|
|
517
|
+
* Helps the LLM match a specific tone or response format.
|
|
518
|
+
* @param options.sourceEntity - Name of the conversation partner for interlocutor-aware rendering.
|
|
519
|
+
* @returns `systemPrompt` (ready to pass to LLM), `personaPrompt` (structured breakdown),
|
|
520
|
+
* and optional `tools` (if the persona has tools configured).
|
|
521
|
+
*
|
|
522
|
+
* @example Custom LLM call with server-assembled prompt
|
|
523
|
+
* ```typescript
|
|
524
|
+
* const { systemPrompt } = await persona.getPromptContext({
|
|
525
|
+
* consumerSuffix: 'Available actions: [flee, fight, negotiate]',
|
|
526
|
+
* consumerRules: 'Always respond in English. Never break character.',
|
|
527
|
+
* sourceEntity: 'Alice',
|
|
528
|
+
* });
|
|
529
|
+
* const response = await myLLM.complete({ system: systemPrompt, messages });
|
|
530
|
+
* await persona.hear(userMessage, 'Alice');
|
|
531
|
+
* ```
|
|
421
532
|
*/
|
|
422
|
-
async getPromptContext(
|
|
533
|
+
async getPromptContext(options) {
|
|
534
|
+
const { consumerSuffix, consumerRules, consumerExamples, sourceEntity } = options ?? {};
|
|
423
535
|
const { data } = await this.client.POST('/personas/{id}/prompt-context', {
|
|
424
536
|
params: { path: { id: this._personaId } },
|
|
425
537
|
body: {
|
|
426
538
|
...(consumerSuffix ? { consumerSuffix } : {}),
|
|
539
|
+
...(consumerRules ? { consumerRules } : {}),
|
|
540
|
+
...(consumerExamples ? { consumerExamples } : {}),
|
|
427
541
|
...(sourceEntity ? { sourceEntity } : {}),
|
|
428
542
|
},
|
|
429
543
|
});
|
|
@@ -465,3 +579,107 @@ export class MolrooPersona {
|
|
|
465
579
|
return this.llm;
|
|
466
580
|
}
|
|
467
581
|
}
|
|
582
|
+
// ── Client-side Prompt Assembly ──
|
|
583
|
+
/**
|
|
584
|
+
* Assemble a system prompt entirely client-side from a {@link PersonaIdentity} and
|
|
585
|
+
* {@link PersonaState}.
|
|
586
|
+
*
|
|
587
|
+
* Use this with the `hear() + getState()` pattern when you own the LLM call:
|
|
588
|
+
* ```
|
|
589
|
+
* await persona.hear(userMessage);
|
|
590
|
+
* const [identity, state] = await Promise.all([persona.getIdentity(), persona.getState()]);
|
|
591
|
+
* const systemPrompt = buildPrompt(identity, state, { consumerSuffix: 'Scene: coffee shop.' });
|
|
592
|
+
* ```
|
|
593
|
+
*
|
|
594
|
+
* @param identity - Persona config from {@link MolrooPersona.getIdentity}.
|
|
595
|
+
* @param state - Live emotional state from {@link MolrooPersona.getState}.
|
|
596
|
+
* @param options - Optional consumer-provided context appended to the prompt.
|
|
597
|
+
*/
|
|
598
|
+
export function buildPrompt(identity, state, options) {
|
|
599
|
+
const { identity: id } = identity;
|
|
600
|
+
const lines = [];
|
|
601
|
+
// ── Identity ──
|
|
602
|
+
lines.push(`Name: ${id.name}`);
|
|
603
|
+
if (id.role)
|
|
604
|
+
lines.push(`Role: ${id.role}`);
|
|
605
|
+
if (id.coreValues?.length)
|
|
606
|
+
lines.push(`Core values: ${id.coreValues.join(', ')}`);
|
|
607
|
+
if (id.speakingStyle)
|
|
608
|
+
lines.push(`Speaking style: ${id.speakingStyle}`);
|
|
609
|
+
if (id.description)
|
|
610
|
+
lines.push(id.description);
|
|
611
|
+
if (id.backstory) {
|
|
612
|
+
lines.push('', '## Backstory', id.backstory);
|
|
613
|
+
}
|
|
614
|
+
if (id.relationships && Object.keys(id.relationships).length) {
|
|
615
|
+
lines.push('', '## Key Relationships');
|
|
616
|
+
for (const [k, v] of Object.entries(id.relationships))
|
|
617
|
+
lines.push(`- ${k}: ${v}`);
|
|
618
|
+
}
|
|
619
|
+
if (id.interests?.length) {
|
|
620
|
+
lines.push('', `Interests: ${id.interests.join(', ')}`);
|
|
621
|
+
}
|
|
622
|
+
if (id.speechPatterns?.length) {
|
|
623
|
+
lines.push('', '## Speech Patterns');
|
|
624
|
+
for (const p of id.speechPatterns)
|
|
625
|
+
lines.push(`- ${p}`);
|
|
626
|
+
}
|
|
627
|
+
if (id.emotionalPatterns && Object.keys(id.emotionalPatterns).length) {
|
|
628
|
+
lines.push('', '## Emotional Patterns');
|
|
629
|
+
for (const [k, v] of Object.entries(id.emotionalPatterns))
|
|
630
|
+
lines.push(`- ${k}: ${v}`);
|
|
631
|
+
}
|
|
632
|
+
if (id.quirks?.length) {
|
|
633
|
+
lines.push('', '## Quirks');
|
|
634
|
+
for (const q of id.quirks)
|
|
635
|
+
lines.push(`- ${q}`);
|
|
636
|
+
}
|
|
637
|
+
if (id.extensions && Object.keys(id.extensions).length) {
|
|
638
|
+
for (const [k, v] of Object.entries(id.extensions)) {
|
|
639
|
+
lines.push('', `## ${k}`, v);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
// ── Behavioral Instructions ──
|
|
643
|
+
lines.push('', 'Stay in character.', 'Embody your psychological state naturally in your responses.', 'Respond in the same language as the user.');
|
|
644
|
+
// ── Psychological State ──
|
|
645
|
+
lines.push('', '## Current Psychological State');
|
|
646
|
+
const { primary, secondary, intensity } = state.emotion.discrete;
|
|
647
|
+
const emotionLabel = secondary ? `${primary} / ${secondary}` : primary;
|
|
648
|
+
lines.push(`Emotion: ${emotionLabel} (intensity: ${intensity.toFixed(2)})`);
|
|
649
|
+
const { V, A, D } = state.emotion.vad;
|
|
650
|
+
lines.push(`VAD: V=${V.toFixed(2)} A=${A.toFixed(2)} D=${D.toFixed(2)}`);
|
|
651
|
+
if (state.mood) {
|
|
652
|
+
lines.push(`Mood: V=${state.mood.V.toFixed(2)} A=${state.mood.A.toFixed(2)} D=${state.mood.D.toFixed(2)}`);
|
|
653
|
+
}
|
|
654
|
+
if (state.somatic) {
|
|
655
|
+
const active = Object.entries(state.somatic).filter(([, v]) => v >= 0.1);
|
|
656
|
+
if (active.length) {
|
|
657
|
+
const somaticStr = active.map(([k, v]) => `${k} (${v.toFixed(2)})`).join(', ');
|
|
658
|
+
lines.push(`Somatic: ${somaticStr}. These bodily sensations unconsciously color your responses.`);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (state.narrative) {
|
|
662
|
+
const n = state.narrative;
|
|
663
|
+
lines.push(`Narrative self-perception: tone=${n.tone.toFixed(2)} agency=${n.agency.toFixed(2)} coherence=${n.coherence.toFixed(2)}`);
|
|
664
|
+
}
|
|
665
|
+
lines.push(`Soul stage: ${state.soulStage.name}`);
|
|
666
|
+
if (state.relationship) {
|
|
667
|
+
const r = state.relationship;
|
|
668
|
+
const attachment = r.attachmentStyle ? ` attachment=${r.attachmentStyle}` : '';
|
|
669
|
+
lines.push(`Relationship: trust=${r.trust.toFixed(2)} intimacy=${r.intimacy.toFixed(2)}${attachment}`);
|
|
670
|
+
}
|
|
671
|
+
if (state.mask.state !== 'stable') {
|
|
672
|
+
lines.push(`Mask: ${state.mask.state} (integrity=${state.mask.integrity.toFixed(2)})`);
|
|
673
|
+
}
|
|
674
|
+
// ── Consumer Context ──
|
|
675
|
+
if (options?.consumerRules) {
|
|
676
|
+
lines.push('', '## Rules', options.consumerRules);
|
|
677
|
+
}
|
|
678
|
+
if (options?.consumerExamples) {
|
|
679
|
+
lines.push('', '## Examples', options.consumerExamples);
|
|
680
|
+
}
|
|
681
|
+
if (options?.consumerSuffix) {
|
|
682
|
+
lines.push('', options.consumerSuffix);
|
|
683
|
+
}
|
|
684
|
+
return lines.join('\n');
|
|
685
|
+
}
|
|
@@ -28,7 +28,11 @@ export declare enum MolrooErrorCode {
|
|
|
28
28
|
/** Authentication failed — invalid or missing API key. */
|
|
29
29
|
UNAUTHORIZED = "UNAUTHORIZED",
|
|
30
30
|
/** API returned an unexpected error not covered by other codes. */
|
|
31
|
-
API_ERROR = "API_ERROR"
|
|
31
|
+
API_ERROR = "API_ERROR",
|
|
32
|
+
/** Feature is not yet implemented. */
|
|
33
|
+
NOT_IMPLEMENTED = "NOT_IMPLEMENTED",
|
|
34
|
+
/** Memory pipeline operation failed (fire-and-forget, non-blocking). */
|
|
35
|
+
PIPELINE_ERROR = "PIPELINE_ERROR"
|
|
32
36
|
}
|
|
33
37
|
export declare class MolrooApiError extends Error {
|
|
34
38
|
/** Machine-readable error code. Use {@link MolrooErrorCode} for type-safe matching. */
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IACvB,sCAAsC;IACtC,eAAe,oBAAoB;IACnC,wEAAwE;IACxE,cAAc,mBAAmB;CAClC;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"}
|
|
@@ -30,6 +30,10 @@ export var MolrooErrorCode;
|
|
|
30
30
|
MolrooErrorCode["UNAUTHORIZED"] = "UNAUTHORIZED";
|
|
31
31
|
/** API returned an unexpected error not covered by other codes. */
|
|
32
32
|
MolrooErrorCode["API_ERROR"] = "API_ERROR";
|
|
33
|
+
/** Feature is not yet implemented. */
|
|
34
|
+
MolrooErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
|
|
35
|
+
/** Memory pipeline operation failed (fire-and-forget, non-blocking). */
|
|
36
|
+
MolrooErrorCode["PIPELINE_ERROR"] = "PIPELINE_ERROR";
|
|
33
37
|
})(MolrooErrorCode || (MolrooErrorCode = {}));
|
|
34
38
|
export class MolrooApiError extends Error {
|
|
35
39
|
constructor(message,
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -222,6 +222,18 @@ export interface Identity {
|
|
|
222
222
|
coreValues?: string[];
|
|
223
223
|
culturalIdentity?: string;
|
|
224
224
|
description?: string;
|
|
225
|
+
/** Character backstory or personal history. */
|
|
226
|
+
backstory?: string;
|
|
227
|
+
/** Key relationships and how the persona perceives them. e.g. {"mom": "strict but loving"} */
|
|
228
|
+
relationships?: Record<string, string>;
|
|
229
|
+
/** Interests, hobbies, or topics the persona cares about. */
|
|
230
|
+
interests?: string[];
|
|
231
|
+
/** Characteristic speech patterns or verbal tics. e.g. ["ends sentences with ~잖아", "says 진짜 when surprised"] */
|
|
232
|
+
speechPatterns?: string[];
|
|
233
|
+
/** Emotional reaction patterns. e.g. {"angry": "goes quiet and terse", "happy": "talks fast"} */
|
|
234
|
+
emotionalPatterns?: Record<string, string>;
|
|
235
|
+
/** Distinctive habits or quirks. e.g. ["taps fingers when thinking", "avoids eye contact when lying"] */
|
|
236
|
+
quirks?: string[];
|
|
225
237
|
extensions?: Record<string, string>;
|
|
226
238
|
}
|
|
227
239
|
export interface Goal {
|
|
@@ -237,6 +249,12 @@ export interface PersonaConfigData {
|
|
|
237
249
|
goals?: Goal[];
|
|
238
250
|
[key: string]: unknown;
|
|
239
251
|
}
|
|
252
|
+
/** Persona identity config as returned by {@link MolrooPersona.getIdentity}. */
|
|
253
|
+
export interface PersonaIdentity {
|
|
254
|
+
identity: Identity;
|
|
255
|
+
personality: PersonalityTraits;
|
|
256
|
+
goals?: Goal[];
|
|
257
|
+
}
|
|
240
258
|
export interface MotivationContext {
|
|
241
259
|
goals: Goal[];
|
|
242
260
|
activeGoal?: Goal;
|
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;AAED,mFAAmF;AACnF,MAAM,WAAW,mBAAmB;IAClC,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gC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AAE,MAAM,CAAC;CAC5B;AAID,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { type ApiClient } from './client';
|
|
11
11
|
import type { Appraisal } from './types';
|
|
12
12
|
import type { LLMAdapter } from '../llm/adapter';
|
|
13
|
+
import type { ZodSchema } from 'zod';
|
|
13
14
|
export type LLMMessage = {
|
|
14
15
|
role: 'user' | 'assistant' | 'system';
|
|
15
16
|
content: string;
|
|
@@ -71,7 +72,7 @@ export interface PersonaDetail {
|
|
|
71
72
|
};
|
|
72
73
|
state: WorldPersonaState | null;
|
|
73
74
|
}
|
|
74
|
-
export interface ReactOptions {
|
|
75
|
+
export interface ReactOptions<T = string> {
|
|
75
76
|
/** Who is performing the action (e.g. 'yongjun'). */
|
|
76
77
|
actor?: string;
|
|
77
78
|
actorType?: 'user' | 'persona';
|
|
@@ -80,7 +81,7 @@ export interface ReactOptions {
|
|
|
80
81
|
/** Prior conversation turns for context. */
|
|
81
82
|
history?: LLMMessage[];
|
|
82
83
|
/** Zod schema for structured output. Omit for plain text. */
|
|
83
|
-
schema?:
|
|
84
|
+
schema?: ZodSchema<T>;
|
|
84
85
|
temperature?: number;
|
|
85
86
|
}
|
|
86
87
|
export interface ReactResult<T = string> {
|
|
@@ -117,8 +118,22 @@ export declare class WorldPersona {
|
|
|
117
118
|
getState(): Promise<WorldPersonaState>;
|
|
118
119
|
/** Get speaking style from persona config (identity.speakingStyle). */
|
|
119
120
|
getSpeakingStyle(): Promise<string | undefined>;
|
|
120
|
-
/**
|
|
121
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Get LLM system prompt assembled from all persona subsystems + world context.
|
|
123
|
+
*
|
|
124
|
+
* @param options - Prompt context options.
|
|
125
|
+
* @param options.sourceEntity - Name of the conversation partner for interlocutor-aware rendering.
|
|
126
|
+
* @param options.consumerSuffix - Free-form app-specific context appended to the system prompt as-is.
|
|
127
|
+
* @param options.consumerRules - Behavioral constraints and absolute rules.
|
|
128
|
+
* Examples: "Never break character", "Always respond in Korean".
|
|
129
|
+
* @param options.consumerExamples - Few-shot example messages for style/behavior reference.
|
|
130
|
+
*/
|
|
131
|
+
getPromptContext(options?: {
|
|
132
|
+
sourceEntity?: string;
|
|
133
|
+
consumerSuffix?: string;
|
|
134
|
+
consumerRules?: string;
|
|
135
|
+
consumerExamples?: string;
|
|
136
|
+
}): Promise<PromptContext>;
|
|
122
137
|
/**
|
|
123
138
|
* Send a predefined action to this persona's emotion engine.
|
|
124
139
|
* Invalidates cached state.
|
|
@@ -183,6 +198,6 @@ export declare class WorldPersona {
|
|
|
183
198
|
* console.log(r2.narrative.dialogue); // typed
|
|
184
199
|
* ```
|
|
185
200
|
*/
|
|
186
|
-
react<T = string>(action: string, options: ReactOptions): Promise<ReactResult<T>>;
|
|
201
|
+
react<T = string>(action: string, options: ReactOptions<T>): Promise<ReactResult<T>>;
|
|
187
202
|
}
|
|
188
203
|
//# sourceMappingURL=world-persona.d.ts.map
|
|
@@ -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,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
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,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,KAAK,EAAE,SAAS,EAAE,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AC;QACf,OAAO,EAAE,cAAc,CAAC;QACxB,IAAI,CAAC,EAAE;YAAE,GAAG,EAAE;gBAAE,CAAC,EAAE,MAAM,CAAC;gBAAC,CAAC,EAAE,MAAM,CAAC;gBAAC,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;QACnE,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;IA6BF;;;;;;;OAOG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,aAAa,CAAC,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;IAgBnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,KAAK,CAAC,CAAC,GAAG,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GACvB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAiD3B"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { unwrap } from './client';
|
|
11
11
|
import { toWireAppraisal } from '../shared/appraisal';
|
|
12
|
+
import { MolrooApiError, MolrooErrorCode } from '../shared/errors';
|
|
12
13
|
export class WorldPersona {
|
|
13
14
|
/** @internal — use World.persona() instead. */
|
|
14
15
|
constructor(client, worldId, personaId, options) {
|
|
@@ -54,11 +55,26 @@ export class WorldPersona {
|
|
|
54
55
|
const detail = await this.getDetail();
|
|
55
56
|
return detail.config?.identity?.speakingStyle;
|
|
56
57
|
}
|
|
57
|
-
/**
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Get LLM system prompt assembled from all persona subsystems + world context.
|
|
60
|
+
*
|
|
61
|
+
* @param options - Prompt context options.
|
|
62
|
+
* @param options.sourceEntity - Name of the conversation partner for interlocutor-aware rendering.
|
|
63
|
+
* @param options.consumerSuffix - Free-form app-specific context appended to the system prompt as-is.
|
|
64
|
+
* @param options.consumerRules - Behavioral constraints and absolute rules.
|
|
65
|
+
* Examples: "Never break character", "Always respond in Korean".
|
|
66
|
+
* @param options.consumerExamples - Few-shot example messages for style/behavior reference.
|
|
67
|
+
*/
|
|
68
|
+
async getPromptContext(options) {
|
|
69
|
+
const { sourceEntity, consumerSuffix, consumerRules, consumerExamples } = options ?? {};
|
|
59
70
|
const { data } = await this._client.POST('/worlds/{id}/personas/{pid}/prompt-context', {
|
|
60
71
|
params: { path: { id: this._worldId, pid: this._personaId } },
|
|
61
|
-
body:
|
|
72
|
+
body: {
|
|
73
|
+
...(sourceEntity ? { sourceEntity } : {}),
|
|
74
|
+
...(consumerSuffix ? { consumerSuffix } : {}),
|
|
75
|
+
...(consumerRules ? { consumerRules } : {}),
|
|
76
|
+
...(consumerExamples ? { consumerExamples } : {}),
|
|
77
|
+
},
|
|
62
78
|
});
|
|
63
79
|
return unwrap(data);
|
|
64
80
|
}
|
|
@@ -134,7 +150,7 @@ export class WorldPersona {
|
|
|
134
150
|
*/
|
|
135
151
|
async react(action, options) {
|
|
136
152
|
if (!this._llm) {
|
|
137
|
-
throw new
|
|
153
|
+
throw new MolrooApiError('WorldPersona.react() requires an LLM adapter. Pass { llm } to world.persona().', MolrooErrorCode.LLM_NOT_CONFIGURED, 400);
|
|
138
154
|
}
|
|
139
155
|
// 1. Interact — emotion engine processes the action
|
|
140
156
|
const interactResult = await this.interact(action, {
|
|
@@ -142,7 +158,7 @@ export class WorldPersona {
|
|
|
142
158
|
actorType: options.actorType,
|
|
143
159
|
});
|
|
144
160
|
// 2. Get prompt context — now reflects updated emotion
|
|
145
|
-
const ctx = await this.getPromptContext(options.actor);
|
|
161
|
+
const ctx = await this.getPromptContext({ sourceEntity: options.actor });
|
|
146
162
|
// 3. LLM generates narrative
|
|
147
163
|
const messages = [
|
|
148
164
|
...(options.history ?? []),
|
|
@@ -2,7 +2,7 @@ import { type ApiClient } from './client';
|
|
|
2
2
|
import { World } from './world-domain';
|
|
3
3
|
import { MolrooPersona } from '../persona';
|
|
4
4
|
import type { PersonaSummary } from '../persona';
|
|
5
|
-
import type {
|
|
5
|
+
import type { PersonaConfigData } from '../types';
|
|
6
6
|
import type { LLMInput } from '../llm/resolve';
|
|
7
7
|
import type { MemoryAdapter, RecallLimits } from '../memory/types';
|
|
8
8
|
import type { EventAdapter } from '../events/types';
|
|
@@ -18,8 +18,6 @@ export interface PersonaOptions {
|
|
|
18
18
|
memory?: MemoryAdapter;
|
|
19
19
|
recall?: RecallLimits;
|
|
20
20
|
events?: EventAdapter;
|
|
21
|
-
/** Appraisal generation mode for `chat()`. `'direct'` (default) generates raw appraisal vectors; `'event'` classifies into ontology events and converts server-side. */
|
|
22
|
-
appraisalMode?: AppraisalMode;
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
25
23
|
* Unified entry point for the molroo SDK.
|
|
@@ -74,6 +72,28 @@ export declare class Molroo {
|
|
|
74
72
|
createPersona(personaConfig: PersonaConfigData, options?: PersonaOptions): Promise<MolrooPersona>;
|
|
75
73
|
/**
|
|
76
74
|
* Connect to an existing persona by ID.
|
|
75
|
+
*
|
|
76
|
+
* LLM adapter is optional. Without it, {@link MolrooPersona.chat | chat()} will throw,
|
|
77
|
+
* but emotion/state APIs ({@link MolrooPersona.hear | hear()},
|
|
78
|
+
* {@link MolrooPersona.getState | getState()},
|
|
79
|
+
* {@link MolrooPersona.getEngineState | getEngineState()},
|
|
80
|
+
* {@link MolrooPersona.perceive | perceive()},
|
|
81
|
+
* {@link MolrooPersona.tick | tick()}) work without LLM.
|
|
82
|
+
*
|
|
83
|
+
* This is the recommended pattern for hybrid apps that build their own prompts
|
|
84
|
+
* and only need SDK for emotion/psychological state computation.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* // Hybrid: emotion engine only (no LLM needed)
|
|
89
|
+
* const persona = await molroo.connectPersona('persona_abc123');
|
|
90
|
+
* const state = await persona.getEngineState(elapsed);
|
|
91
|
+
* const emotion = await persona.hear(userMessage, 'Alice');
|
|
92
|
+
*
|
|
93
|
+
* // Full: SDK handles everything (LLM required)
|
|
94
|
+
* const persona = await molroo.connectPersona('persona_abc123', { llm });
|
|
95
|
+
* const result = await persona.chat('Hello!');
|
|
96
|
+
* ```
|
|
77
97
|
*/
|
|
78
98
|
connectPersona(personaId: string, options?: PersonaOptions): Promise<MolrooPersona>;
|
|
79
99
|
/**
|
|
@@ -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;
|
|
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;AAE3C,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,MAAM,iBAAiB,CAAC;AACnE,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,c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