@molroo-io/sdk 0.9.0 → 0.10.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.
Files changed (80) hide show
  1. package/dist/cjs/defaults/index.d.ts.map +1 -1
  2. package/dist/cjs/defaults/index.js +10 -5
  3. package/dist/cjs/events/types.d.ts +1 -1
  4. package/dist/cjs/events/types.d.ts.map +1 -1
  5. package/dist/cjs/index.d.ts +2 -2
  6. package/dist/cjs/index.d.ts.map +1 -1
  7. package/dist/cjs/llm/resolve.d.ts.map +1 -1
  8. package/dist/cjs/llm/resolve.js +2 -1
  9. package/dist/cjs/llm/schema.d.ts +0 -114
  10. package/dist/cjs/llm/schema.d.ts.map +1 -1
  11. package/dist/cjs/llm/schema.js +1 -44
  12. package/dist/cjs/persona/chat-orchestrator.d.ts +18 -3
  13. package/dist/cjs/persona/chat-orchestrator.d.ts.map +1 -1
  14. package/dist/cjs/persona/chat-orchestrator.js +29 -109
  15. package/dist/cjs/persona/conversation.d.ts +22 -1
  16. package/dist/cjs/persona/conversation.d.ts.map +1 -1
  17. package/dist/cjs/persona/conversation.js +2 -0
  18. package/dist/cjs/persona/memory-pipeline.d.ts.map +1 -1
  19. package/dist/cjs/persona/memory-pipeline.js +30 -4
  20. package/dist/cjs/persona.d.ts +330 -36
  21. package/dist/cjs/persona.d.ts.map +1 -1
  22. package/dist/cjs/persona.js +302 -19
  23. package/dist/cjs/shared/errors.d.ts +5 -1
  24. package/dist/cjs/shared/errors.d.ts.map +1 -1
  25. package/dist/cjs/shared/errors.js +4 -0
  26. package/dist/cjs/types.d.ts +18 -0
  27. package/dist/cjs/types.d.ts.map +1 -1
  28. package/dist/cjs/world/world-persona.d.ts +20 -5
  29. package/dist/cjs/world/world-persona.d.ts.map +1 -1
  30. package/dist/cjs/world/world-persona.js +21 -5
  31. package/dist/cjs/world/world.d.ts +23 -3
  32. package/dist/cjs/world/world.d.ts.map +1 -1
  33. package/dist/cjs/world/world.js +24 -1
  34. package/dist/esm/api-client.js +2 -2
  35. package/dist/esm/defaults/index.d.ts.map +1 -1
  36. package/dist/esm/defaults/index.js +10 -2
  37. package/dist/esm/errors.js +1 -1
  38. package/dist/esm/events/types.d.ts +1 -1
  39. package/dist/esm/events/types.d.ts.map +1 -1
  40. package/dist/esm/generate/persona.js +2 -2
  41. package/dist/esm/index.d.ts +2 -2
  42. package/dist/esm/index.d.ts.map +1 -1
  43. package/dist/esm/index.js +6 -6
  44. package/dist/esm/llm/resolve.d.ts.map +1 -1
  45. package/dist/esm/llm/resolve.js +3 -2
  46. package/dist/esm/llm/schema.d.ts +0 -114
  47. package/dist/esm/llm/schema.d.ts.map +1 -1
  48. package/dist/esm/llm/schema.js +0 -43
  49. package/dist/esm/llm/vercel-ai/index.js +2 -2
  50. package/dist/esm/package.json +1 -0
  51. package/dist/esm/persona/chat-orchestrator.d.ts +18 -3
  52. package/dist/esm/persona/chat-orchestrator.d.ts.map +1 -1
  53. package/dist/esm/persona/chat-orchestrator.js +32 -112
  54. package/dist/esm/persona/conversation.d.ts +22 -1
  55. package/dist/esm/persona/conversation.d.ts.map +1 -1
  56. package/dist/esm/persona/conversation.js +2 -0
  57. package/dist/esm/persona/memory-pipeline.d.ts.map +1 -1
  58. package/dist/esm/persona/memory-pipeline.js +31 -5
  59. package/dist/esm/persona.d.ts +330 -36
  60. package/dist/esm/persona.d.ts.map +1 -1
  61. package/dist/esm/persona.js +308 -26
  62. package/dist/esm/shared/errors.d.ts +5 -1
  63. package/dist/esm/shared/errors.d.ts.map +1 -1
  64. package/dist/esm/shared/errors.js +4 -0
  65. package/dist/esm/types.d.ts +18 -0
  66. package/dist/esm/types.d.ts.map +1 -1
  67. package/dist/esm/types.js +1 -1
  68. package/dist/esm/world/client.js +2 -2
  69. package/dist/esm/world/errors.js +1 -1
  70. package/dist/esm/world/index.js +5 -5
  71. package/dist/esm/world/world-domain.js +3 -3
  72. package/dist/esm/world/world-persona.d.ts +20 -5
  73. package/dist/esm/world/world-persona.d.ts.map +1 -1
  74. package/dist/esm/world/world-persona.js +23 -7
  75. package/dist/esm/world/world.d.ts +23 -3
  76. package/dist/esm/world/world.d.ts.map +1 -1
  77. package/dist/esm/world/world.js +27 -4
  78. package/package.json +3 -3
  79. package/dist/cjs/defaults/persona.json +0 -17
  80. package/dist/esm/defaults/persona.json +0 -17
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.MolrooPersona = void 0;
37
+ exports.buildPrompt = buildPrompt;
37
38
  const resolve_1 = require("./llm/resolve");
38
39
  const errors_1 = require("./errors");
39
40
  const api_client_1 = require("./api-client");
@@ -58,7 +59,6 @@ class MolrooPersona {
58
59
  this.events = config.events ?? null;
59
60
  this.memoryAdapter = config.memory ?? null;
60
61
  this.memoryRecallConfig = config.recall;
61
- this.appraisalMode = config.appraisalMode ?? 'direct';
62
62
  }
63
63
  // ── Properties ──
64
64
  /** Unique persona instance ID. */
@@ -207,15 +207,41 @@ class MolrooPersona {
207
207
  return this.perceive(description, { ...options, type });
208
208
  }
209
209
  /**
210
- * Perceive a chat message from another entity. Simplest wrapper over {@link perceive}.
210
+ * Register a received message with the emotion engine and update the persona's emotional state.
211
211
  *
212
- * @param message - The incoming message text.
213
- * @param from - Who sent the message (name string or structured context).
214
- * @returns Emotion engine response.
212
+ * This is the **core API** for the `hear() + getState()` pattern. Apps that build their own
213
+ * LLM prompts should call `hear()` after each user message to keep the emotion engine in sync,
214
+ * then call `getState()` to read updated state for prompt assembly.
215
215
  *
216
- * @example
216
+ * Use {@link chat} when you want the SDK to handle prompt assembly and LLM orchestration.
217
+ * Use `hear()` + `getState()` when your app owns the LLM call.
218
+ *
219
+ * @param message - The incoming message text (user utterance, narration, etc.).
220
+ * @param from - Who sent the message. A plain string is used as the source entity name.
221
+ * Pass an {@link InterlocutorContext} object for richer context (description, extensions).
222
+ * @returns Emotion engine response with updated VAD, discrete emotion, and any side effects
223
+ * (memory episodes, social updates, stage transitions, etc.).
224
+ *
225
+ * @example Basic hear + getState pattern
226
+ * ```typescript
227
+ * // Step 1: register message with emotion engine
228
+ * await persona.hear('You did a great job today!', 'Alice');
229
+ *
230
+ * // Step 2: read updated psychological state
231
+ * const state = await persona.getState();
232
+ *
233
+ * // Step 3: assemble your own system prompt
234
+ * const systemPrompt = buildPrompt(myPersonaConfig, state);
235
+ * const { text } = await myLLM.generate({ system: systemPrompt, messages });
236
+ * ```
237
+ *
238
+ * @example With structured interlocutor context
217
239
  * ```typescript
218
- * const response = await persona.hear('How are you?', 'Alice');
240
+ * await persona.hear('I need your help', {
241
+ * name: 'Alice',
242
+ * description: 'A regular customer, slightly anxious',
243
+ * extensions: { mood: 'stressed' },
244
+ * });
219
245
  * ```
220
246
  */
221
247
  async hear(message, from) {
@@ -290,8 +316,7 @@ class MolrooPersona {
290
316
  memoryAdapter: this.memoryAdapter,
291
317
  memoryRecallConfig: this.memoryRecallConfig,
292
318
  events: this.events,
293
- appraisalMode: this.appraisalMode,
294
- getPromptContext: (suffix, source) => this.getPromptContext(suffix, source),
319
+ getPromptContext: (opts) => this.getPromptContext(opts),
295
320
  perceive: (msg, opts) => this.perceive(msg, opts),
296
321
  };
297
322
  return (0, chat_orchestrator_1.chat)(deps, message, options);
@@ -378,9 +403,44 @@ class MolrooPersona {
378
403
  }
379
404
  // ── State ──
380
405
  /**
381
- * Get the persona's current emotional and psychological state.
406
+ * Fetch the full psychological state of this persona from the emotion engine.
407
+ *
408
+ * Returns all active subsystems: emotion, soul stage, mask, mood, somatic sensations,
409
+ * narrative self-perception, emotion regulation, self-esteem, TMT state, and relationship.
410
+ *
411
+ * This is the primary data source for apps that build their own LLM prompts. Combine with
412
+ * `hear()` to implement the recommended `hear() + getState()` pattern:
413
+ *
414
+ * ```
415
+ * user message → hear() → emotion engine updates state → getState() → build prompt → LLM
416
+ * ```
417
+ *
418
+ * @returns All psychological subsystems as a {@link PersonaState} object.
419
+ *
420
+ * @example Building a custom system prompt
421
+ * ```typescript
422
+ * const state = await persona.getState();
382
423
  *
383
- * @returns Current emotion (VAD + discrete), mood, somatic sensations, and narrative.
424
+ * const lines: string[] = [
425
+ * `You are ${name}.`,
426
+ * `Emotion: ${state.emotion.discrete.primary} (${state.emotion.discrete.intensity.toFixed(2)})`,
427
+ * ];
428
+ *
429
+ * if (state.mood) {
430
+ * lines.push(`Mood: valence=${state.mood.V.toFixed(2)} arousal=${state.mood.A.toFixed(2)}`);
431
+ * }
432
+ * if (state.narrative) {
433
+ * lines.push(`Narrative: agency=${state.narrative.agency.toFixed(2)} tone=${state.narrative.tone.toFixed(2)}`);
434
+ * }
435
+ * if (state.selfEsteem) {
436
+ * lines.push(`Self-esteem: ${state.selfEsteem.global.toFixed(2)}`);
437
+ * }
438
+ * if (state.tmt && state.tmt.mortalitySalience > 0.5) {
439
+ * lines.push(`Existential tension is high. Defense mode: ${state.tmt.defenseMode}`);
440
+ * }
441
+ *
442
+ * const systemPrompt = lines.join('\n');
443
+ * ```
384
444
  */
385
445
  async getState() {
386
446
  const { data } = await this.client.GET('/personas/{id}/state', {
@@ -388,6 +448,24 @@ class MolrooPersona {
388
448
  });
389
449
  return (0, api_client_1.unwrap)(data);
390
450
  }
451
+ /**
452
+ * Fetch this persona's identity config (identity, personality, goals).
453
+ *
454
+ * Returns a {@link PersonaIdentity} suitable for passing to {@link buildPrompt}
455
+ * when assembling system prompts entirely client-side.
456
+ */
457
+ async getIdentity() {
458
+ const { data } = await this.client.GET('/personas/{id}', {
459
+ params: { path: { id: this._personaId } },
460
+ });
461
+ const result = (0, api_client_1.unwrap)(data);
462
+ const config = result?.persona?.config ?? {};
463
+ return {
464
+ identity: config.identity ?? { name: 'Unknown' },
465
+ personality: config.personality ?? { O: 0.5, C: 0.5, E: 0.5, A: 0.5, N: 0.5, H: 0.5 },
466
+ goals: config.goals,
467
+ };
468
+ }
391
469
  /**
392
470
  * Get a full snapshot of the persona (config + engine state).
393
471
  * Useful for backup, migration, or debugging.
@@ -445,21 +523,58 @@ class MolrooPersona {
445
523
  // ── Prompt / Memory ──
446
524
  /**
447
525
  * Fetch the server-assembled system prompt for this persona.
448
- * Includes identity, behavioral instructions, psychological state,
449
- * expression style (if StyleProfile set), and consumerSuffix.
450
526
  *
451
- * Called internally by {@link chat}. Use directly when building custom LLM pipelines.
527
+ * The server builds a complete system prompt from the persona's live state. It includes:
528
+ * 1. **Identity** — name, role, core values, speaking style, description
529
+ * 2. **Behavioral instructions** — stay in character, embody state, match language
530
+ * 3. **Psychological state** — emotion, mood, somatic, narrative, goals (from live engine)
531
+ * 4. **Expression constraints** — message length, formality, patterns (only if StyleProfile set)
532
+ * 5. **consumerRules** — behavioral constraints and absolute rules (e.g., "Never break character")
533
+ * 6. **consumerExamples** — few-shot example messages for style/behavior reference
534
+ * 7. **consumerSuffix** — your app-specific context, appended last
535
+ *
536
+ * This is a **middle-tier API** — between the low-level `getState()` (raw data) and the
537
+ * high-level `chat()` (full orchestration). Use it when you want to drive the LLM yourself
538
+ * but still benefit from server-side prompt assembly.
452
539
  *
453
- * @param consumerSuffix - App-specific context appended to the system prompt.
454
- * Do NOT include identity, personality, or emotion these are already in the prompt.
455
- * @param sourceEntity - Name of the conversation partner (for interlocutor-aware prompts).
456
- * @returns System prompt string and structured persona prompt data.
540
+ * Called automatically by {@link chat}. Call directly when:
541
+ * - You use a custom LLM framework not supported by the SDK
542
+ * - You need to inspect or transform the system prompt before sending
543
+ * - You need prompt + state in a single round-trip (avoids a separate `getState()` call)
544
+ *
545
+ * **Do NOT** include identity, personality, or emotion in `consumerSuffix` — those are
546
+ * already present. Duplicating them wastes tokens and may confuse the LLM.
547
+ *
548
+ * @param options - Prompt context options.
549
+ * @param options.consumerSuffix - Free-form app-specific context appended to the system prompt as-is.
550
+ * Examples: scene description, available actions, current quest objective.
551
+ * @param options.consumerRules - Behavioral constraints and absolute rules.
552
+ * Examples: "Never break character", "Always respond in Korean", "Do not discuss competitors".
553
+ * @param options.consumerExamples - Few-shot example messages for style/behavior reference.
554
+ * Helps the LLM match a specific tone or response format.
555
+ * @param options.sourceEntity - Name of the conversation partner for interlocutor-aware rendering.
556
+ * @returns `systemPrompt` (ready to pass to LLM), `personaPrompt` (structured breakdown),
557
+ * and optional `tools` (if the persona has tools configured).
558
+ *
559
+ * @example Custom LLM call with server-assembled prompt
560
+ * ```typescript
561
+ * const { systemPrompt } = await persona.getPromptContext({
562
+ * consumerSuffix: 'Available actions: [flee, fight, negotiate]',
563
+ * consumerRules: 'Always respond in English. Never break character.',
564
+ * sourceEntity: 'Alice',
565
+ * });
566
+ * const response = await myLLM.complete({ system: systemPrompt, messages });
567
+ * await persona.hear(userMessage, 'Alice');
568
+ * ```
457
569
  */
458
- async getPromptContext(consumerSuffix, sourceEntity) {
570
+ async getPromptContext(options) {
571
+ const { consumerSuffix, consumerRules, consumerExamples, sourceEntity } = options ?? {};
459
572
  const { data } = await this.client.POST('/personas/{id}/prompt-context', {
460
573
  params: { path: { id: this._personaId } },
461
574
  body: {
462
575
  ...(consumerSuffix ? { consumerSuffix } : {}),
576
+ ...(consumerRules ? { consumerRules } : {}),
577
+ ...(consumerExamples ? { consumerExamples } : {}),
463
578
  ...(sourceEntity ? { sourceEntity } : {}),
464
579
  },
465
580
  });
@@ -494,6 +609,70 @@ class MolrooPersona {
494
609
  engineLlm: this.engineLlm,
495
610
  };
496
611
  }
612
+ // ── v1.0 unified API (additive — old methods still work) ─────────────
613
+ // `react()` collapses perceive/event/hear/experience/socialize into one
614
+ // discriminated input. `update()` collapses the 6 admin setters into one
615
+ // patch shape. Both delegate to the existing implementations.
616
+ /**
617
+ * Unified input method. Replaces perceive/event/hear/experience/socialize.
618
+ *
619
+ * @example
620
+ * ```ts
621
+ * await persona.react({ kind: 'hear', message: 'hi', from: 'Alice' });
622
+ * await persona.react({ kind: 'experience', description: 'sun set', appraisal });
623
+ * await persona.react({ kind: 'event', type: 'gift', description: 'got flowers', appraisal });
624
+ * ```
625
+ */
626
+ async react(input, options) {
627
+ switch (input.kind) {
628
+ case 'perceive':
629
+ return this.perceive(input.message, { ...options, ...input.options });
630
+ case 'hear':
631
+ return this.perceive(input.message, {
632
+ ...options,
633
+ from: input.from,
634
+ type: 'chat_message',
635
+ });
636
+ case 'experience':
637
+ return this.perceive(input.description, {
638
+ ...options,
639
+ appraisal: input.appraisal,
640
+ type: 'environment',
641
+ });
642
+ case 'event':
643
+ return this.perceive(input.description, {
644
+ ...options,
645
+ appraisal: input.appraisal,
646
+ type: input.type,
647
+ });
648
+ case 'socialize':
649
+ return this.perceive(input.message, {
650
+ ...options,
651
+ from: input.from,
652
+ relationshipContext: input.relationship,
653
+ type: 'chat_message',
654
+ });
655
+ }
656
+ }
657
+ /**
658
+ * Unified admin/patch method. Replaces setEmotion, annotate, setNextResponse,
659
+ * setStyleProfile, patch, putSnapshot. Multiple fields can be applied in one
660
+ * call; they run sequentially in declaration order.
661
+ */
662
+ async update(patch) {
663
+ if (patch.emotion)
664
+ await this.setEmotion(patch.emotion);
665
+ if (patch.annotation !== undefined)
666
+ await this.annotate(patch.annotation);
667
+ if (patch.nextResponse !== undefined)
668
+ await this.setNextResponse(patch.nextResponse);
669
+ if (patch.styleProfile)
670
+ await this.setStyleProfile(patch.styleProfile);
671
+ if (patch.config)
672
+ await this.patch({ config: patch.config });
673
+ if (patch.snapshot)
674
+ await this.putSnapshot(patch.snapshot);
675
+ }
497
676
  requireLLM() {
498
677
  if (!this.llm) {
499
678
  throw new errors_1.MolrooApiError('LLM adapter is required for chat(). Provide llm option, or use perceive() directly.', errors_1.MolrooErrorCode.LLM_NOT_CONFIGURED, 400);
@@ -502,3 +681,107 @@ class MolrooPersona {
502
681
  }
503
682
  }
504
683
  exports.MolrooPersona = MolrooPersona;
684
+ // ── Client-side Prompt Assembly ──
685
+ /**
686
+ * Assemble a system prompt entirely client-side from a {@link PersonaIdentity} and
687
+ * {@link PersonaState}.
688
+ *
689
+ * Use this with the `hear() + getState()` pattern when you own the LLM call:
690
+ * ```
691
+ * await persona.hear(userMessage);
692
+ * const [identity, state] = await Promise.all([persona.getIdentity(), persona.getState()]);
693
+ * const systemPrompt = buildPrompt(identity, state, { consumerSuffix: 'Scene: coffee shop.' });
694
+ * ```
695
+ *
696
+ * @param identity - Persona config from {@link MolrooPersona.getIdentity}.
697
+ * @param state - Live emotional state from {@link MolrooPersona.getState}.
698
+ * @param options - Optional consumer-provided context appended to the prompt.
699
+ */
700
+ function buildPrompt(identity, state, options) {
701
+ const { identity: id } = identity;
702
+ const lines = [];
703
+ // ── Identity ──
704
+ lines.push(`Name: ${id.name}`);
705
+ if (id.role)
706
+ lines.push(`Role: ${id.role}`);
707
+ if (id.coreValues?.length)
708
+ lines.push(`Core values: ${id.coreValues.join(', ')}`);
709
+ if (id.speakingStyle)
710
+ lines.push(`Speaking style: ${id.speakingStyle}`);
711
+ if (id.description)
712
+ lines.push(id.description);
713
+ if (id.backstory) {
714
+ lines.push('', '## Backstory', id.backstory);
715
+ }
716
+ if (id.relationships && Object.keys(id.relationships).length) {
717
+ lines.push('', '## Key Relationships');
718
+ for (const [k, v] of Object.entries(id.relationships))
719
+ lines.push(`- ${k}: ${v}`);
720
+ }
721
+ if (id.interests?.length) {
722
+ lines.push('', `Interests: ${id.interests.join(', ')}`);
723
+ }
724
+ if (id.speechPatterns?.length) {
725
+ lines.push('', '## Speech Patterns');
726
+ for (const p of id.speechPatterns)
727
+ lines.push(`- ${p}`);
728
+ }
729
+ if (id.emotionalPatterns && Object.keys(id.emotionalPatterns).length) {
730
+ lines.push('', '## Emotional Patterns');
731
+ for (const [k, v] of Object.entries(id.emotionalPatterns))
732
+ lines.push(`- ${k}: ${v}`);
733
+ }
734
+ if (id.quirks?.length) {
735
+ lines.push('', '## Quirks');
736
+ for (const q of id.quirks)
737
+ lines.push(`- ${q}`);
738
+ }
739
+ if (id.extensions && Object.keys(id.extensions).length) {
740
+ for (const [k, v] of Object.entries(id.extensions)) {
741
+ lines.push('', `## ${k}`, v);
742
+ }
743
+ }
744
+ // ── Behavioral Instructions ──
745
+ lines.push('', 'Stay in character.', 'Embody your psychological state naturally in your responses.', 'Respond in the same language as the user.');
746
+ // ── Psychological State ──
747
+ lines.push('', '## Current Psychological State');
748
+ const { primary, secondary, intensity } = state.emotion.discrete;
749
+ const emotionLabel = secondary ? `${primary} / ${secondary}` : primary;
750
+ lines.push(`Emotion: ${emotionLabel} (intensity: ${intensity.toFixed(2)})`);
751
+ const { V, A, D } = state.emotion.vad;
752
+ lines.push(`VAD: V=${V.toFixed(2)} A=${A.toFixed(2)} D=${D.toFixed(2)}`);
753
+ if (state.mood) {
754
+ lines.push(`Mood: V=${state.mood.V.toFixed(2)} A=${state.mood.A.toFixed(2)} D=${state.mood.D.toFixed(2)}`);
755
+ }
756
+ if (state.somatic) {
757
+ const active = Object.entries(state.somatic).filter(([, v]) => v >= 0.1);
758
+ if (active.length) {
759
+ const somaticStr = active.map(([k, v]) => `${k} (${v.toFixed(2)})`).join(', ');
760
+ lines.push(`Somatic: ${somaticStr}. These bodily sensations unconsciously color your responses.`);
761
+ }
762
+ }
763
+ if (state.narrative) {
764
+ const n = state.narrative;
765
+ lines.push(`Narrative self-perception: tone=${n.tone.toFixed(2)} agency=${n.agency.toFixed(2)} coherence=${n.coherence.toFixed(2)}`);
766
+ }
767
+ lines.push(`Soul stage: ${state.soulStage.name}`);
768
+ if (state.relationship) {
769
+ const r = state.relationship;
770
+ const attachment = r.attachmentStyle ? ` attachment=${r.attachmentStyle}` : '';
771
+ lines.push(`Relationship: trust=${r.trust.toFixed(2)} intimacy=${r.intimacy.toFixed(2)}${attachment}`);
772
+ }
773
+ if (state.mask.state !== 'stable') {
774
+ lines.push(`Mask: ${state.mask.state} (integrity=${state.mask.integrity.toFixed(2)})`);
775
+ }
776
+ // ── Consumer Context ──
777
+ if (options?.consumerRules) {
778
+ lines.push('', '## Rules', options.consumerRules);
779
+ }
780
+ if (options?.consumerExamples) {
781
+ lines.push('', '## Examples', options.consumerExamples);
782
+ }
783
+ if (options?.consumerSuffix) {
784
+ lines.push('', options.consumerSuffix);
785
+ }
786
+ return lines.join('\n');
787
+ }
@@ -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;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"}
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"}
@@ -33,6 +33,10 @@ var MolrooErrorCode;
33
33
  MolrooErrorCode["UNAUTHORIZED"] = "UNAUTHORIZED";
34
34
  /** API returned an unexpected error not covered by other codes. */
35
35
  MolrooErrorCode["API_ERROR"] = "API_ERROR";
36
+ /** Feature is not yet implemented. */
37
+ MolrooErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
38
+ /** Memory pipeline operation failed (fire-and-forget, non-blocking). */
39
+ MolrooErrorCode["PIPELINE_ERROR"] = "PIPELINE_ERROR";
36
40
  })(MolrooErrorCode || (exports.MolrooErrorCode = MolrooErrorCode = {}));
37
41
  class MolrooApiError extends Error {
38
42
  constructor(message,
@@ -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;
@@ -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;CAA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IACpB,UAAU,EAAE,SAAS,CAAC;IACtB,gBAAgB,EAAE,eAAe,CAAC;IAClC,kBAAkB,CAAC,EAAE,GAAG,CAAC;IACzB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,OAAO,EAAE,YAAY,CAAC;IACtB,eAAe,EAAE,mBAAmB,CAAC;IACrC,aAAa,EAAE,kBAAkB,CAAC;IAClC,UAAU,EAAE,eAAe,CAAC;IAC5B,iBAAiB,CAAC,EAAE,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?: unknown;
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
- /** Get LLM system prompt assembled from all persona subsystems + world context. */
121
- getPromptContext(sourceEntity?: string): Promise<PromptContext>;
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;AAOjD,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,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE;QAAE,CAAC,E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gB,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,aAAa,CAAC;IAoB1B;;;OAGG;IACG,QAAQ,CACZ,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GACA,OAAO,CAAC;QACT,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;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"}
@@ -12,6 +12,7 @@ exports.WorldPersona = void 0;
12
12
  */
13
13
  const client_1 = require("./client");
14
14
  const appraisal_1 = require("../shared/appraisal");
15
+ const errors_1 = require("../shared/errors");
15
16
  class WorldPersona {
16
17
  /** @internal — use World.persona() instead. */
17
18
  constructor(client, worldId, personaId, options) {
@@ -57,11 +58,26 @@ class WorldPersona {
57
58
  const detail = await this.getDetail();
58
59
  return detail.config?.identity?.speakingStyle;
59
60
  }
60
- /** Get LLM system prompt assembled from all persona subsystems + world context. */
61
- async getPromptContext(sourceEntity) {
61
+ /**
62
+ * Get LLM system prompt assembled from all persona subsystems + world context.
63
+ *
64
+ * @param options - Prompt context options.
65
+ * @param options.sourceEntity - Name of the conversation partner for interlocutor-aware rendering.
66
+ * @param options.consumerSuffix - Free-form app-specific context appended to the system prompt as-is.
67
+ * @param options.consumerRules - Behavioral constraints and absolute rules.
68
+ * Examples: "Never break character", "Always respond in Korean".
69
+ * @param options.consumerExamples - Few-shot example messages for style/behavior reference.
70
+ */
71
+ async getPromptContext(options) {
72
+ const { sourceEntity, consumerSuffix, consumerRules, consumerExamples } = options ?? {};
62
73
  const { data } = await this._client.POST('/worlds/{id}/personas/{pid}/prompt-context', {
63
74
  params: { path: { id: this._worldId, pid: this._personaId } },
64
- body: sourceEntity ? { sourceEntity } : {},
75
+ body: {
76
+ ...(sourceEntity ? { sourceEntity } : {}),
77
+ ...(consumerSuffix ? { consumerSuffix } : {}),
78
+ ...(consumerRules ? { consumerRules } : {}),
79
+ ...(consumerExamples ? { consumerExamples } : {}),
80
+ },
65
81
  });
66
82
  return (0, client_1.unwrap)(data);
67
83
  }
@@ -137,7 +153,7 @@ class WorldPersona {
137
153
  */
138
154
  async react(action, options) {
139
155
  if (!this._llm) {
140
- throw new Error('WorldPersona.react() requires an LLM adapter. Pass { llm } to world.persona().');
156
+ throw new errors_1.MolrooApiError('WorldPersona.react() requires an LLM adapter. Pass { llm } to world.persona().', errors_1.MolrooErrorCode.LLM_NOT_CONFIGURED, 400);
141
157
  }
142
158
  // 1. Interact — emotion engine processes the action
143
159
  const interactResult = await this.interact(action, {
@@ -145,7 +161,7 @@ class WorldPersona {
145
161
  actorType: options.actorType,
146
162
  });
147
163
  // 2. Get prompt context — now reflects updated emotion
148
- const ctx = await this.getPromptContext(options.actor);
164
+ const ctx = await this.getPromptContext({ sourceEntity: options.actor });
149
165
  // 3. LLM generates narrative
150
166
  const messages = [
151
167
  ...(options.history ?? []),