@molroo-io/sdk 0.9.1 → 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.
- package/dist/cjs/defaults/index.d.ts.map +1 -1
- package/dist/cjs/defaults/index.js +10 -5
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/persona.d.ts +60 -0
- package/dist/cjs/persona.d.ts.map +1 -1
- package/dist/cjs/persona.js +64 -0
- package/dist/esm/api-client.js +2 -2
- package/dist/esm/defaults/index.d.ts.map +1 -1
- package/dist/esm/defaults/index.js +10 -2
- package/dist/esm/errors.js +1 -1
- package/dist/esm/generate/persona.js +2 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -6
- package/dist/esm/llm/resolve.js +2 -2
- package/dist/esm/llm/vercel-ai/index.js +2 -2
- package/dist/esm/package.json +1 -0
- package/dist/esm/persona/chat-orchestrator.js +6 -6
- package/dist/esm/persona/memory-pipeline.js +1 -1
- package/dist/esm/persona.d.ts +60 -0
- package/dist/esm/persona.d.ts.map +1 -1
- package/dist/esm/persona.js +71 -7
- package/dist/esm/types.js +1 -1
- package/dist/esm/world/client.js +2 -2
- package/dist/esm/world/errors.js +1 -1
- package/dist/esm/world/index.js +5 -5
- package/dist/esm/world/world-domain.js +3 -3
- package/dist/esm/world/world-persona.js +3 -3
- package/dist/esm/world/world.js +4 -4
- package/package.json +3 -3
- package/dist/cjs/defaults/persona.json +0 -17
- package/dist/esm/defaults/persona.json +0 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/defaults/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/defaults/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,eAAe,EAAE,iBAS7B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAenF"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.DEFAULT_PERSONA = void 0;
|
|
7
4
|
exports.withDefaults = withDefaults;
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
exports.DEFAULT_PERSONA = {
|
|
6
|
+
personality: { O: 0.5, C: 0.5, E: 0.5, A: 0.5, N: 0.5, H: 0.5 },
|
|
7
|
+
identity: {
|
|
8
|
+
name: 'Persona',
|
|
9
|
+
role: 'A person with a neutral, balanced personality.',
|
|
10
|
+
speakingStyle: 'Natural, conversational tone.',
|
|
11
|
+
coreValues: ['honesty', 'kindness'],
|
|
12
|
+
},
|
|
13
|
+
goals: [],
|
|
14
|
+
};
|
|
10
15
|
/**
|
|
11
16
|
* Merge user-provided persona config with defaults.
|
|
12
17
|
* User values take precedence; defaults fill missing fields.
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type { Appraisal } from './shared/appraisal';
|
|
|
36
36
|
export type { LLMAdapter, Message, GenerateTextOptions, GenerateObjectOptions, } from './llm/adapter';
|
|
37
37
|
export type { LLMInput } from './llm/resolve';
|
|
38
38
|
export type { MemoryAdapter, RecallQuery, SemanticRecallOptions, RecallLimits, Reflection, } from './memory/types';
|
|
39
|
-
export type { PersonaSummary, PersonaState, PersonaChatResult, } from './persona';
|
|
39
|
+
export type { PersonaSummary, PersonaState, PersonaChatResult, ReactInput, PersonaUpdate, } from './persona';
|
|
40
40
|
export { Conversation } from './persona/conversation';
|
|
41
41
|
export type { ConversationOptions } from './persona/conversation';
|
|
42
42
|
export type { AppraisalMode, InterlocutorContext, RelationshipContext, PerceiveOptions, PerceiveEvent, PerceiveContext, } from './types';
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGjF,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,YAAY,EACV,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,YAAY,EACV,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,cAAc,EACd,YAAY,EACZ,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGjF,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAi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EAAE,MAAM,WAAW,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/cjs/persona.d.ts
CHANGED
|
@@ -5,6 +5,49 @@ import type { EventAdapter } from './events/types';
|
|
|
5
5
|
import type { AgentResponse, AppraisalVector, InterlocutorContext, RelationshipContext, PersonaSnapshot, PersonaConfigData, PerceiveOptions, PersonaIdentity } from './types';
|
|
6
6
|
import type { StyleProfile } from './expression';
|
|
7
7
|
import { Conversation, type ConversationOptions } from './persona/conversation';
|
|
8
|
+
/**
|
|
9
|
+
* Discriminated input for {@link MolrooPersona.react}. Each kind corresponds
|
|
10
|
+
* to one of the legacy input methods (perceive/hear/experience/event/socialize).
|
|
11
|
+
*/
|
|
12
|
+
export type ReactInput = {
|
|
13
|
+
kind: 'perceive';
|
|
14
|
+
message: string;
|
|
15
|
+
options?: PerceiveOptions;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'hear';
|
|
18
|
+
message: string;
|
|
19
|
+
from?: string | InterlocutorContext;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'experience';
|
|
22
|
+
description: string;
|
|
23
|
+
appraisal: AppraisalVector;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'event';
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
appraisal: AppraisalVector;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'socialize';
|
|
31
|
+
message: string;
|
|
32
|
+
from: string | InterlocutorContext;
|
|
33
|
+
relationship: RelationshipContext;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Patch shape for {@link MolrooPersona.update}. Any subset of fields may be
|
|
37
|
+
* provided; they are applied in declaration order.
|
|
38
|
+
*/
|
|
39
|
+
export interface PersonaUpdate {
|
|
40
|
+
emotion?: Partial<{
|
|
41
|
+
V: number;
|
|
42
|
+
A: number;
|
|
43
|
+
D: number;
|
|
44
|
+
}>;
|
|
45
|
+
annotation?: string;
|
|
46
|
+
nextResponse?: string;
|
|
47
|
+
styleProfile?: StyleProfile;
|
|
48
|
+
config?: PersonaConfigData;
|
|
49
|
+
snapshot?: PersonaSnapshot;
|
|
50
|
+
}
|
|
8
51
|
/** Configuration for connecting to a standalone persona instance. */
|
|
9
52
|
export interface MolrooPersonaConfig {
|
|
10
53
|
/** Base URL of the molroo API. Defaults to 'https://api.molroo.io'. */
|
|
@@ -646,6 +689,23 @@ export declare class MolrooPersona {
|
|
|
646
689
|
*/
|
|
647
690
|
conversation(options?: ConversationOptions): Conversation;
|
|
648
691
|
private get memoryPipelineDeps();
|
|
692
|
+
/**
|
|
693
|
+
* Unified input method. Replaces perceive/event/hear/experience/socialize.
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* ```ts
|
|
697
|
+
* await persona.react({ kind: 'hear', message: 'hi', from: 'Alice' });
|
|
698
|
+
* await persona.react({ kind: 'experience', description: 'sun set', appraisal });
|
|
699
|
+
* await persona.react({ kind: 'event', type: 'gift', description: 'got flowers', appraisal });
|
|
700
|
+
* ```
|
|
701
|
+
*/
|
|
702
|
+
react(input: ReactInput, options?: PerceiveOptions): Promise<AgentResponse>;
|
|
703
|
+
/**
|
|
704
|
+
* Unified admin/patch method. Replaces setEmotion, annotate, setNextResponse,
|
|
705
|
+
* setStyleProfile, patch, putSnapshot. Multiple fields can be applied in one
|
|
706
|
+
* call; they run sequentially in declaration order.
|
|
707
|
+
*/
|
|
708
|
+
update(patch: PersonaUpdate): Promise<void>;
|
|
649
709
|
private requireLLM;
|
|
650
710
|
}
|
|
651
711
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persona.d.ts","sourceRoot":"","sources":["../../src/persona.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EA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,aAAa,CAAC;IAgCjF;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IASjD,OAAO,CAAC,UAAU;CAUnB;AAID;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE;IACR,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GACA,MAAM,CAiGR"}
|
package/dist/cjs/persona.js
CHANGED
|
@@ -609,6 +609,70 @@ class MolrooPersona {
|
|
|
609
609
|
engineLlm: this.engineLlm,
|
|
610
610
|
};
|
|
611
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
|
+
}
|
|
612
676
|
requireLLM() {
|
|
613
677
|
if (!this.llm) {
|
|
614
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);
|
package/dist/esm/api-client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MolrooApiError } from './errors';
|
|
2
|
-
import { createTypedClient, unwrap } from './shared/client-factory';
|
|
1
|
+
import { MolrooApiError } from './errors.js';
|
|
2
|
+
import { createTypedClient, unwrap } from './shared/client-factory.js';
|
|
3
3
|
/**
|
|
4
4
|
* Create a typed openapi-fetch client for the molroo API.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/defaults/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/defaults/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,eAAe,EAAE,iBAS7B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAenF"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export const DEFAULT_PERSONA = {
|
|
2
|
+
personality: { O: 0.5, C: 0.5, E: 0.5, A: 0.5, N: 0.5, H: 0.5 },
|
|
3
|
+
identity: {
|
|
4
|
+
name: 'Persona',
|
|
5
|
+
role: 'A person with a neutral, balanced personality.',
|
|
6
|
+
speakingStyle: 'Natural, conversational tone.',
|
|
7
|
+
coreValues: ['honesty', 'kindness'],
|
|
8
|
+
},
|
|
9
|
+
goals: [],
|
|
10
|
+
};
|
|
3
11
|
/**
|
|
4
12
|
* Merge user-provided persona config with defaults.
|
|
5
13
|
* User values take precedence; defaults fill missing fields.
|
package/dist/esm/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MolrooApiError, MolrooErrorCode } from './shared/errors';
|
|
1
|
+
export { MolrooApiError, MolrooErrorCode } from './shared/errors.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GeneratePersonaSchema } from './schema';
|
|
2
|
-
import { buildSystemPrompt } from './prompt';
|
|
1
|
+
import { GeneratePersonaSchema } from './schema.js';
|
|
2
|
+
import { buildSystemPrompt } from './prompt.js';
|
|
3
3
|
/**
|
|
4
4
|
* Generate a structured persona from a natural language character description.
|
|
5
5
|
*
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type { Appraisal } from './shared/appraisal';
|
|
|
36
36
|
export type { LLMAdapter, Message, GenerateTextOptions, GenerateObjectOptions, } from './llm/adapter';
|
|
37
37
|
export type { LLMInput } from './llm/resolve';
|
|
38
38
|
export type { MemoryAdapter, RecallQuery, SemanticRecallOptions, RecallLimits, Reflection, } from './memory/types';
|
|
39
|
-
export type { PersonaSummary, PersonaState, PersonaChatResult, } from './persona';
|
|
39
|
+
export type { PersonaSummary, PersonaState, PersonaChatResult, ReactInput, PersonaUpdate, } from './persona';
|
|
40
40
|
export { Conversation } from './persona/conversation';
|
|
41
41
|
export type { ConversationOptions } from './persona/conversation';
|
|
42
42
|
export type { AppraisalMode, InterlocutorContext, RelationshipContext, PerceiveOptions, PerceiveEvent, PerceiveContext, } from './types';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGjF,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,YAAY,EACV,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,eAAe,CAAC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e,EACf,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,EACT,OAAO,EACP,YAAY,EACZ,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,IAAI,EACJ,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,SAAS,EACT,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
// ── Main exports ──
|
|
32
|
-
export { Molroo } from './world/world';
|
|
33
|
-
export { MolrooApiError, WorldApiError, MolrooErrorCode } from './shared/errors';
|
|
32
|
+
export { Molroo } from './world/world.js';
|
|
33
|
+
export { MolrooApiError, WorldApiError, MolrooErrorCode } from './shared/errors.js';
|
|
34
34
|
// ── Shared utilities ──
|
|
35
|
-
export { NEUTRAL_APPRAISAL, toWireAppraisal, fromWireAppraisal } from './shared/appraisal';
|
|
35
|
+
export { NEUTRAL_APPRAISAL, toWireAppraisal, fromWireAppraisal } from './shared/appraisal.js';
|
|
36
36
|
// ── Conversation ──
|
|
37
|
-
export { Conversation } from './persona/conversation';
|
|
37
|
+
export { Conversation } from './persona/conversation.js';
|
|
38
38
|
// ── Emotion labels (synced with engine/core) ──
|
|
39
|
-
export { EMOTION_LABELS } from './emotion';
|
|
39
|
+
export { EMOTION_LABELS } from './emotion.js';
|
|
40
40
|
// ── Defaults ──
|
|
41
|
-
export { DEFAULT_PERSONA, withDefaults } from './defaults';
|
|
41
|
+
export { DEFAULT_PERSONA, withDefaults } from './defaults/index.js';
|
package/dist/esm/llm/resolve.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { VercelAIAdapter } from './vercel-ai';
|
|
2
|
-
import { MolrooApiError, MolrooErrorCode } from '../shared/errors';
|
|
1
|
+
import { VercelAIAdapter } from './vercel-ai/index.js';
|
|
2
|
+
import { MolrooApiError, MolrooErrorCode } from '../shared/errors.js';
|
|
3
3
|
/**
|
|
4
4
|
* Check if input is a Vercel AI SDK provider instance.
|
|
5
5
|
* Provider instances have a `doGenerate` method.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { recallMemories, buildMemoryBlock } from '../memory/recall';
|
|
2
|
-
import { NEUTRAL_APPRAISAL } from '../shared/appraisal';
|
|
3
|
-
import { postChat } from './memory-pipeline';
|
|
1
|
+
import { recallMemories, buildMemoryBlock } from '../memory/recall.js';
|
|
2
|
+
import { NEUTRAL_APPRAISAL } from '../shared/appraisal.js';
|
|
3
|
+
import { postChat } from './memory-pipeline.js';
|
|
4
4
|
/** Clamp appraisal values to engine-valid ranges after LLM generation. */
|
|
5
5
|
function clampAppraisal(a) {
|
|
6
6
|
const c = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
@@ -83,7 +83,7 @@ export async function chat(deps, message, options) {
|
|
|
83
83
|
// Split mode: engineLlm handles appraisal, primary llm handles response text
|
|
84
84
|
if (deps.engineLlm && deps.engineLlm !== deps.llm) {
|
|
85
85
|
const appraisalMessages = messages.length <= 5 ? messages : messages.slice(-5);
|
|
86
|
-
const { AppraisalVectorSchema } = await import('../llm/schema');
|
|
86
|
+
const { AppraisalVectorSchema } = await import('../llm/schema.js');
|
|
87
87
|
const { object: appraisalResult } = await deps.engineLlm.generateObject({
|
|
88
88
|
system: systemPrompt + buildDirectAppraisalInstruction(),
|
|
89
89
|
messages: appraisalMessages,
|
|
@@ -127,7 +127,7 @@ export async function chat(deps, message, options) {
|
|
|
127
127
|
appraisal = result.appraisal;
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
130
|
-
const { LLMResponseSchema } = await import('../llm/schema');
|
|
130
|
+
const { LLMResponseSchema } = await import('../llm/schema.js');
|
|
131
131
|
const { object: llmResult } = await deps.llm.generateObject({
|
|
132
132
|
system: systemPrompt,
|
|
133
133
|
messages,
|
|
@@ -170,7 +170,7 @@ export async function chat(deps, message, options) {
|
|
|
170
170
|
}
|
|
171
171
|
async function generateWithToolLoop(deps, system, messages, onToolCall) {
|
|
172
172
|
const MAX_TOOL_ITERATIONS = 3;
|
|
173
|
-
const { LLMResponseSchema, LLMResponseWithToolsSchema, } = await import('../llm/schema');
|
|
173
|
+
const { LLMResponseSchema, LLMResponseWithToolsSchema, } = await import('../llm/schema.js');
|
|
174
174
|
let currentSystem = system;
|
|
175
175
|
for (let iteration = 0; iteration < MAX_TOOL_ITERATIONS; iteration++) {
|
|
176
176
|
const { object: llmResult } = await deps.llm.generateObject({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { emitResponseEvents } from './event-emitter';
|
|
1
|
+
import { emitResponseEvents } from './event-emitter.js';
|
|
2
2
|
/** Emit pipeline error or log warning if no EventAdapter. */
|
|
3
3
|
function handlePipelineError(deps, stage, error) {
|
|
4
4
|
const message = error instanceof Error ? error.message : String(error);
|
package/dist/esm/persona.d.ts
CHANGED
|
@@ -5,6 +5,49 @@ import type { EventAdapter } from './events/types';
|
|
|
5
5
|
import type { AgentResponse, AppraisalVector, InterlocutorContext, RelationshipContext, PersonaSnapshot, PersonaConfigData, PerceiveOptions, PersonaIdentity } from './types';
|
|
6
6
|
import type { StyleProfile } from './expression';
|
|
7
7
|
import { Conversation, type ConversationOptions } from './persona/conversation';
|
|
8
|
+
/**
|
|
9
|
+
* Discriminated input for {@link MolrooPersona.react}. Each kind corresponds
|
|
10
|
+
* to one of the legacy input methods (perceive/hear/experience/event/socialize).
|
|
11
|
+
*/
|
|
12
|
+
export type ReactInput = {
|
|
13
|
+
kind: 'perceive';
|
|
14
|
+
message: string;
|
|
15
|
+
options?: PerceiveOptions;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'hear';
|
|
18
|
+
message: string;
|
|
19
|
+
from?: string | InterlocutorContext;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'experience';
|
|
22
|
+
description: string;
|
|
23
|
+
appraisal: AppraisalVector;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'event';
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
appraisal: AppraisalVector;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'socialize';
|
|
31
|
+
message: string;
|
|
32
|
+
from: string | InterlocutorContext;
|
|
33
|
+
relationship: RelationshipContext;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Patch shape for {@link MolrooPersona.update}. Any subset of fields may be
|
|
37
|
+
* provided; they are applied in declaration order.
|
|
38
|
+
*/
|
|
39
|
+
export interface PersonaUpdate {
|
|
40
|
+
emotion?: Partial<{
|
|
41
|
+
V: number;
|
|
42
|
+
A: number;
|
|
43
|
+
D: number;
|
|
44
|
+
}>;
|
|
45
|
+
annotation?: string;
|
|
46
|
+
nextResponse?: string;
|
|
47
|
+
styleProfile?: StyleProfile;
|
|
48
|
+
config?: PersonaConfigData;
|
|
49
|
+
snapshot?: PersonaSnapshot;
|
|
50
|
+
}
|
|
8
51
|
/** Configuration for connecting to a standalone persona instance. */
|
|
9
52
|
export interface MolrooPersonaConfig {
|
|
10
53
|
/** Base URL of the molroo API. Defaults to 'https://api.molroo.io'. */
|
|
@@ -646,6 +689,23 @@ export declare class MolrooPersona {
|
|
|
646
689
|
*/
|
|
647
690
|
conversation(options?: ConversationOptions): Conversation;
|
|
648
691
|
private get memoryPipelineDeps();
|
|
692
|
+
/**
|
|
693
|
+
* Unified input method. Replaces perceive/event/hear/experience/socialize.
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* ```ts
|
|
697
|
+
* await persona.react({ kind: 'hear', message: 'hi', from: 'Alice' });
|
|
698
|
+
* await persona.react({ kind: 'experience', description: 'sun set', appraisal });
|
|
699
|
+
* await persona.react({ kind: 'event', type: 'gift', description: 'got flowers', appraisal });
|
|
700
|
+
* ```
|
|
701
|
+
*/
|
|
702
|
+
react(input: ReactInput, options?: PerceiveOptions): Promise<AgentResponse>;
|
|
703
|
+
/**
|
|
704
|
+
* Unified admin/patch method. Replaces setEmotion, annotate, setNextResponse,
|
|
705
|
+
* setStyleProfile, patch, putSnapshot. Multiple fields can be applied in one
|
|
706
|
+
* call; they run sequentially in declaration order.
|
|
707
|
+
*/
|
|
708
|
+
update(patch: PersonaUpdate): Promise<void>;
|
|
649
709
|
private requireLLM;
|
|
650
710
|
}
|
|
651
711
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persona.d.ts","sourceRoot":"","sources":["../../src/persona.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,eAAe,EAEf,eAAe,EAIhB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAMjD,OAAO,EAAE,YAAY,EAAE,KAAK,mBAA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c,CAAC,EAAE,MAAM,CAAC;CACzB,GACA,MAAM,CAiGR"}
|
package/dist/esm/persona.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { resolveLLM } from './llm/resolve';
|
|
2
|
-
import { MolrooApiError, MolrooErrorCode } from './errors';
|
|
3
|
-
import { createApiClient, unwrap } from './api-client';
|
|
4
|
-
import { postPerceive } from './persona/memory-pipeline';
|
|
5
|
-
import { chat as chatOrchestrator } from './persona/chat-orchestrator';
|
|
6
|
-
import { Conversation } from './persona/conversation';
|
|
1
|
+
import { resolveLLM } from './llm/resolve.js';
|
|
2
|
+
import { MolrooApiError, MolrooErrorCode } from './errors.js';
|
|
3
|
+
import { createApiClient, unwrap } from './api-client.js';
|
|
4
|
+
import { postPerceive } from './persona/memory-pipeline.js';
|
|
5
|
+
import { chat as chatOrchestrator } from './persona/chat-orchestrator.js';
|
|
6
|
+
import { Conversation } from './persona/conversation.js';
|
|
7
7
|
// ── SDK Persona Types ──
|
|
8
8
|
const DEFAULT_BASE_URL = 'https://api.molroo.io';
|
|
9
9
|
// ── MolrooPersona ──
|
|
@@ -39,7 +39,7 @@ export class MolrooPersona {
|
|
|
39
39
|
throw new MolrooApiError('LLM adapter is required when using description string. ' +
|
|
40
40
|
'Provide llm option or use explicit PersonaConfigData.', MolrooErrorCode.LLM_REQUIRED, 400);
|
|
41
41
|
}
|
|
42
|
-
const { generatePersona } = await import('./generate/persona');
|
|
42
|
+
const { generatePersona } = await import('./generate/persona.js');
|
|
43
43
|
const llm = await resolveLLM(config.llm);
|
|
44
44
|
const personaConfig = await generatePersona(llm, input);
|
|
45
45
|
return MolrooPersona.createWithConfig(config, personaConfig);
|
|
@@ -572,6 +572,70 @@ export class MolrooPersona {
|
|
|
572
572
|
engineLlm: this.engineLlm,
|
|
573
573
|
};
|
|
574
574
|
}
|
|
575
|
+
// ── v1.0 unified API (additive — old methods still work) ─────────────
|
|
576
|
+
// `react()` collapses perceive/event/hear/experience/socialize into one
|
|
577
|
+
// discriminated input. `update()` collapses the 6 admin setters into one
|
|
578
|
+
// patch shape. Both delegate to the existing implementations.
|
|
579
|
+
/**
|
|
580
|
+
* Unified input method. Replaces perceive/event/hear/experience/socialize.
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* ```ts
|
|
584
|
+
* await persona.react({ kind: 'hear', message: 'hi', from: 'Alice' });
|
|
585
|
+
* await persona.react({ kind: 'experience', description: 'sun set', appraisal });
|
|
586
|
+
* await persona.react({ kind: 'event', type: 'gift', description: 'got flowers', appraisal });
|
|
587
|
+
* ```
|
|
588
|
+
*/
|
|
589
|
+
async react(input, options) {
|
|
590
|
+
switch (input.kind) {
|
|
591
|
+
case 'perceive':
|
|
592
|
+
return this.perceive(input.message, { ...options, ...input.options });
|
|
593
|
+
case 'hear':
|
|
594
|
+
return this.perceive(input.message, {
|
|
595
|
+
...options,
|
|
596
|
+
from: input.from,
|
|
597
|
+
type: 'chat_message',
|
|
598
|
+
});
|
|
599
|
+
case 'experience':
|
|
600
|
+
return this.perceive(input.description, {
|
|
601
|
+
...options,
|
|
602
|
+
appraisal: input.appraisal,
|
|
603
|
+
type: 'environment',
|
|
604
|
+
});
|
|
605
|
+
case 'event':
|
|
606
|
+
return this.perceive(input.description, {
|
|
607
|
+
...options,
|
|
608
|
+
appraisal: input.appraisal,
|
|
609
|
+
type: input.type,
|
|
610
|
+
});
|
|
611
|
+
case 'socialize':
|
|
612
|
+
return this.perceive(input.message, {
|
|
613
|
+
...options,
|
|
614
|
+
from: input.from,
|
|
615
|
+
relationshipContext: input.relationship,
|
|
616
|
+
type: 'chat_message',
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Unified admin/patch method. Replaces setEmotion, annotate, setNextResponse,
|
|
622
|
+
* setStyleProfile, patch, putSnapshot. Multiple fields can be applied in one
|
|
623
|
+
* call; they run sequentially in declaration order.
|
|
624
|
+
*/
|
|
625
|
+
async update(patch) {
|
|
626
|
+
if (patch.emotion)
|
|
627
|
+
await this.setEmotion(patch.emotion);
|
|
628
|
+
if (patch.annotation !== undefined)
|
|
629
|
+
await this.annotate(patch.annotation);
|
|
630
|
+
if (patch.nextResponse !== undefined)
|
|
631
|
+
await this.setNextResponse(patch.nextResponse);
|
|
632
|
+
if (patch.styleProfile)
|
|
633
|
+
await this.setStyleProfile(patch.styleProfile);
|
|
634
|
+
if (patch.config)
|
|
635
|
+
await this.patch({ config: patch.config });
|
|
636
|
+
if (patch.snapshot)
|
|
637
|
+
await this.putSnapshot(patch.snapshot);
|
|
638
|
+
}
|
|
575
639
|
requireLLM() {
|
|
576
640
|
if (!this.llm) {
|
|
577
641
|
throw new MolrooApiError('LLM adapter is required for chat(). Provide llm option, or use perceive() directly.', MolrooErrorCode.LLM_NOT_CONFIGURED, 400);
|
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, MolrooErrorCode } from './errors';
|
|
11
|
+
export { MolrooApiError, MolrooErrorCode } from './errors.js';
|
package/dist/esm/world/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WorldApiError } from './errors';
|
|
2
|
-
import { createTypedClient, unwrap } from '../shared/client-factory';
|
|
1
|
+
import { WorldApiError } from './errors.js';
|
|
2
|
+
import { createTypedClient, unwrap } from '../shared/client-factory.js';
|
|
3
3
|
/**
|
|
4
4
|
* Create a typed API client for the molroo World API.
|
|
5
5
|
*
|
package/dist/esm/world/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { WorldApiError } from '../shared/errors';
|
|
1
|
+
export { WorldApiError } from '../shared/errors.js';
|
package/dist/esm/world/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Primary
|
|
2
|
-
export { Molroo } from './world';
|
|
3
|
-
export { World } from './world-domain';
|
|
4
|
-
export { WorldPersona } from './world-persona';
|
|
2
|
+
export { Molroo } from './world.js';
|
|
3
|
+
export { World } from './world-domain.js';
|
|
4
|
+
export { WorldPersona } from './world-persona.js';
|
|
5
5
|
// Error
|
|
6
|
-
export { WorldApiError } from './errors';
|
|
6
|
+
export { WorldApiError } from './errors.js';
|
|
7
7
|
// Advanced
|
|
8
|
-
export { createWorldClient } from './client';
|
|
8
|
+
export { createWorldClient } from './client.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// INFO: @F001 Domain class wrapping World API — see plan step 3
|
|
2
|
-
import { unwrap } from './client';
|
|
3
|
-
import { WorldPersona } from './world-persona';
|
|
4
|
-
import { toWireAppraisal, fromWireAppraisal } from '../shared/appraisal';
|
|
2
|
+
import { unwrap } from './client.js';
|
|
3
|
+
import { WorldPersona } from './world-persona.js';
|
|
4
|
+
import { toWireAppraisal, fromWireAppraisal } from '../shared/appraisal.js';
|
|
5
5
|
// ---------------------------------------------------------------------------
|
|
6
6
|
// World class (domain)
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* WorldPersona는 Persona SDK와 동일한 DX(getState, getPromptContext, react)를
|
|
8
8
|
* 제공하되, 내부적으로 World API 엔드포인트를 사용한다.
|
|
9
9
|
*/
|
|
10
|
-
import { unwrap } from './client';
|
|
11
|
-
import { toWireAppraisal } from '../shared/appraisal';
|
|
12
|
-
import { MolrooApiError, MolrooErrorCode } from '../shared/errors';
|
|
10
|
+
import { unwrap } from './client.js';
|
|
11
|
+
import { toWireAppraisal } from '../shared/appraisal.js';
|
|
12
|
+
import { MolrooApiError, MolrooErrorCode } from '../shared/errors.js';
|
|
13
13
|
export class WorldPersona {
|
|
14
14
|
/** @internal — use World.persona() instead. */
|
|
15
15
|
constructor(client, worldId, personaId, options) {
|
package/dist/esm/world/world.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// INFO: @F001 Top-level SDK entry point — see plan step 4
|
|
2
|
-
import { createWorldClient, unwrap } from './client';
|
|
3
|
-
import { World } from './world-domain';
|
|
4
|
-
import { MolrooPersona } from '../persona';
|
|
5
|
-
import { MolrooApiError, MolrooErrorCode } from '../shared/errors';
|
|
2
|
+
import { createWorldClient, unwrap } from './client.js';
|
|
3
|
+
import { World } from './world-domain.js';
|
|
4
|
+
import { MolrooPersona } from '../persona.js';
|
|
5
|
+
import { MolrooApiError, MolrooErrorCode } from '../shared/errors.js';
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
// Internal helper
|
|
8
8
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molroo-io/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Unified SDK for molroo emotion engine — persona, world, LLM integration",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"scripts": {
|
|
44
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json && tsc -p tsconfig.esm.json",
|
|
44
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && tsc -p tsconfig.esm.json && node scripts/fix-esm-extensions.mjs",
|
|
45
45
|
"test": "vitest run",
|
|
46
46
|
"test:watch": "vitest",
|
|
47
47
|
"test:coverage": "vitest run --coverage",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"format:check": "prettier --check 'src/**/*.ts'",
|
|
52
52
|
"clean": "rm -rf dist",
|
|
53
53
|
"docs": "typedoc",
|
|
54
|
-
"gen:types": "node
|
|
54
|
+
"gen:types": "node ../api/scripts/dump-spec.mjs ../api/dist/openapi.json && openapi-typescript ../api/dist/openapi.json -o src/generated/api.d.ts"
|
|
55
55
|
},
|
|
56
56
|
"keywords": [
|
|
57
57
|
"emotion",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"personality": {
|
|
3
|
-
"O": 0.5,
|
|
4
|
-
"C": 0.5,
|
|
5
|
-
"E": 0.5,
|
|
6
|
-
"A": 0.5,
|
|
7
|
-
"N": 0.5,
|
|
8
|
-
"H": 0.5
|
|
9
|
-
},
|
|
10
|
-
"identity": {
|
|
11
|
-
"name": "Persona",
|
|
12
|
-
"role": "A person with a neutral, balanced personality.",
|
|
13
|
-
"speakingStyle": "Natural, conversational tone.",
|
|
14
|
-
"coreValues": ["honesty", "kindness"]
|
|
15
|
-
},
|
|
16
|
-
"goals": []
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"personality": {
|
|
3
|
-
"O": 0.5,
|
|
4
|
-
"C": 0.5,
|
|
5
|
-
"E": 0.5,
|
|
6
|
-
"A": 0.5,
|
|
7
|
-
"N": 0.5,
|
|
8
|
-
"H": 0.5
|
|
9
|
-
},
|
|
10
|
-
"identity": {
|
|
11
|
-
"name": "Persona",
|
|
12
|
-
"role": "A person with a neutral, balanced personality.",
|
|
13
|
-
"speakingStyle": "Natural, conversational tone.",
|
|
14
|
-
"coreValues": ["honesty", "kindness"]
|
|
15
|
-
},
|
|
16
|
-
"goals": []
|
|
17
|
-
}
|