@molroo-io/sdk 0.7.3 → 0.8.3
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/expression/index.d.ts +103 -0
- package/dist/cjs/expression/index.d.ts.map +1 -0
- package/dist/cjs/expression/index.js +18 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/llm/schema.d.ts +114 -0
- package/dist/cjs/llm/schema.d.ts.map +1 -1
- package/dist/cjs/llm/schema.js +44 -1
- package/dist/cjs/persona/chat-orchestrator.d.ts +2 -2
- package/dist/cjs/persona/chat-orchestrator.d.ts.map +1 -1
- package/dist/cjs/persona/chat-orchestrator.js +128 -48
- package/dist/cjs/persona.d.ts +26 -5
- package/dist/cjs/persona.d.ts.map +1 -1
- package/dist/cjs/persona.js +34 -14
- package/dist/cjs/types.d.ts +18 -5
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/world/world.d.ts +3 -1
- package/dist/cjs/world/world.d.ts.map +1 -1
- package/dist/esm/expression/index.d.ts +103 -0
- package/dist/esm/expression/index.d.ts.map +1 -0
- package/dist/esm/expression/index.js +17 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/llm/schema.d.ts +114 -0
- package/dist/esm/llm/schema.d.ts.map +1 -1
- package/dist/esm/llm/schema.js +43 -0
- package/dist/esm/persona/chat-orchestrator.d.ts +2 -2
- package/dist/esm/persona/chat-orchestrator.d.ts.map +1 -1
- package/dist/esm/persona/chat-orchestrator.js +128 -48
- package/dist/esm/persona.d.ts +26 -5
- package/dist/esm/persona.d.ts.map +1 -1
- package/dist/esm/persona.js +34 -14
- package/dist/esm/types.d.ts +18 -5
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/world/world.d.ts +3 -1
- package/dist/esm/world/world.d.ts.map +1 -1
- package/package.json +11 -2
package/dist/esm/llm/schema.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
// Ontology constants inlined from @molroo-io/core (private package).
|
|
3
|
+
// These must stay in sync with engine/core/src/modules/ontology/types.ts.
|
|
4
|
+
const INTERACTION_TYPES = ['chat', 'inform', 'humor', 'express', 'goodbye'];
|
|
5
|
+
const EVENT_TYPES = [
|
|
6
|
+
'praise', 'criticism', 'support', 'rejection',
|
|
7
|
+
'apology', 'request', 'betrayal', 'neglect',
|
|
8
|
+
];
|
|
9
|
+
const AGENT_ROLES = ['user', 'self', 'other'];
|
|
10
|
+
const TARGET_ROLES = ['user', 'self', 'other'];
|
|
11
|
+
const RELATIONSHIP_TYPES = ['friend', 'romantic', 'authority', 'stranger'];
|
|
2
12
|
/** Clamp a number to [lo, hi]. */
|
|
3
13
|
const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
4
14
|
/**
|
|
@@ -47,6 +57,17 @@ export const AppraisalVectorSchema = z.object({
|
|
|
47
57
|
.describe('How much time pressure or immediate action is needed? 0: settled/past event/no rush, 0.5: moderate, 1: immediate action required/acute emergency. For past losses: low. For active threats: high. Use 0-1 range.')
|
|
48
58
|
.transform((v) => clamp(v, 0, 1)),
|
|
49
59
|
});
|
|
60
|
+
export const EventAppraisalSchema = z.object({
|
|
61
|
+
interaction_type: z.enum(INTERACTION_TYPES).describe('Conversation mode: chat (small talk), inform (sharing info/news), humor (jokes), express (emotional/relational event), goodbye (farewell).'),
|
|
62
|
+
event_type: z.enum(EVENT_TYPES).optional().describe('Relationship event type. Required when interaction_type is "express". Omit for chat/inform/humor/goodbye. One of: praise, criticism, support, rejection, apology, request, betrayal, neglect.'),
|
|
63
|
+
agent_role: z.enum(AGENT_ROLES).describe('Primary role responsible for the event from the persona perspective: user, self, or other.'),
|
|
64
|
+
target_role: z.enum(TARGET_ROLES).describe('Who is affected by or receives the event: self (persona), user (conversation partner), or other (third party).'),
|
|
65
|
+
relationship: z.enum(RELATIONSHIP_TYPES).describe('Relationship context for this event: friend, romantic, authority, or stranger.'),
|
|
66
|
+
intensity: z
|
|
67
|
+
.number()
|
|
68
|
+
.describe('Impact strength from 0 to 1.5. Use 1.0 for a normal event and >1.0 for unusually strong events.')
|
|
69
|
+
.transform((v) => clamp(v, 0, 1.5)),
|
|
70
|
+
});
|
|
50
71
|
/**
|
|
51
72
|
* Full LLM response schema — response text + appraisal vector.
|
|
52
73
|
*/
|
|
@@ -54,6 +75,15 @@ export const LLMResponseSchema = z.object({
|
|
|
54
75
|
response: z.string().describe('Response message from persona to user'),
|
|
55
76
|
appraisal: AppraisalVectorSchema.describe("Scherer 9-dimensional emotion appraisal of user input from persona's perspective"),
|
|
56
77
|
});
|
|
78
|
+
export const LLMEventResponseSchema = z.object({
|
|
79
|
+
response: z.string().describe('Response message from persona to user'),
|
|
80
|
+
interaction_type: EventAppraisalSchema.shape.interaction_type,
|
|
81
|
+
event_type: EventAppraisalSchema.shape.event_type,
|
|
82
|
+
agent_role: EventAppraisalSchema.shape.agent_role,
|
|
83
|
+
target_role: EventAppraisalSchema.shape.target_role,
|
|
84
|
+
relationship: EventAppraisalSchema.shape.relationship,
|
|
85
|
+
intensity: EventAppraisalSchema.shape.intensity,
|
|
86
|
+
});
|
|
57
87
|
/**
|
|
58
88
|
* Tool-use aware LLM response schema.
|
|
59
89
|
* The LLM can either produce a normal response or request a memory search.
|
|
@@ -67,3 +97,16 @@ export const LLMResponseWithToolsSchema = z.object({
|
|
|
67
97
|
.optional()
|
|
68
98
|
.describe('If you need to recall a specific memory before responding, set this to your search query. Leave empty/omit when you can respond without searching.'),
|
|
69
99
|
});
|
|
100
|
+
export const LLMEventResponseWithToolsSchema = z.object({
|
|
101
|
+
response: z.string().describe('Response message from persona to user. Set to empty string "" if you need to search memory first.'),
|
|
102
|
+
interaction_type: EventAppraisalSchema.shape.interaction_type,
|
|
103
|
+
event_type: EventAppraisalSchema.shape.event_type,
|
|
104
|
+
agent_role: EventAppraisalSchema.shape.agent_role,
|
|
105
|
+
target_role: EventAppraisalSchema.shape.target_role,
|
|
106
|
+
relationship: EventAppraisalSchema.shape.relationship,
|
|
107
|
+
intensity: EventAppraisalSchema.shape.intensity,
|
|
108
|
+
search_memory: z
|
|
109
|
+
.string()
|
|
110
|
+
.optional()
|
|
111
|
+
.describe('If you need to recall a specific memory before responding, set this to your search query. Leave empty/omit when you can respond without searching.'),
|
|
112
|
+
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* All external dependencies are injected via ChatOrchestratorDeps.
|
|
6
6
|
*/
|
|
7
7
|
import type { LLMAdapter, Message } from '../llm/adapter';
|
|
8
|
-
import type { AgentResponse, InterlocutorContext, PerceiveOptions } from '../types';
|
|
8
|
+
import type { AgentResponse, AppraisalMode, InterlocutorContext, PerceiveOptions } from '../types';
|
|
9
9
|
import type { RecallLimits } from '../memory/types';
|
|
10
10
|
import type { MemoryAdapter } from '../memory/types';
|
|
11
11
|
import type { EventAdapter } from '../events/types';
|
|
@@ -21,9 +21,9 @@ export interface ChatOrchestratorDeps {
|
|
|
21
21
|
memoryAdapter: MemoryAdapter | null;
|
|
22
22
|
memoryRecallConfig: RecallLimits | undefined;
|
|
23
23
|
events: EventAdapter | null;
|
|
24
|
+
appraisalMode: AppraisalMode;
|
|
24
25
|
getPromptContext: (consumerSuffix?: string, sourceEntity?: string) => Promise<PromptContextResult>;
|
|
25
26
|
perceive: (message: string, options?: PerceiveOptions) => Promise<AgentResponse>;
|
|
26
|
-
searchMemory: (query: string) => Promise<Array<Record<string, unknown>>>;
|
|
27
27
|
}
|
|
28
28
|
export interface ChatOptions {
|
|
29
29
|
from?: string | InterlocutorContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-orchestrator.d.ts","sourceRoot":"","sources":["../../../src/persona/chat-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO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,IAAI,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAAC;IACpC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAC/F;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,aAAa,CAAC;IACxB,2FAA2F;IAC3F,cAAc,EAAE,OAAO,EAAE,CAAC;CAC3B;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAiKlH"}
|
|
@@ -29,6 +29,49 @@ function buildInterlocutorBlock(ctx) {
|
|
|
29
29
|
}
|
|
30
30
|
return parts.join('\n');
|
|
31
31
|
}
|
|
32
|
+
function buildDirectAppraisalInstruction() {
|
|
33
|
+
return [
|
|
34
|
+
'',
|
|
35
|
+
'## Appraisal Task',
|
|
36
|
+
"Evaluate how RECEIVING the user's message affects this persona emotionally.",
|
|
37
|
+
'The event you are appraising is the message itself arriving, not the described situation.',
|
|
38
|
+
"When the user shares their own experience, appraise through the persona's relational goals.",
|
|
39
|
+
"Rate each dimension from the persona's subjective perspective.",
|
|
40
|
+
'An insult should produce negative goal_congruence and norm_compatibility.',
|
|
41
|
+
'A compliment should produce positive values. Neutral small talk should be near zero.',
|
|
42
|
+
].join('\n');
|
|
43
|
+
}
|
|
44
|
+
function buildEventAppraisalInstruction() {
|
|
45
|
+
return [
|
|
46
|
+
'',
|
|
47
|
+
'## Event Classification Task',
|
|
48
|
+
"Classify the user's message into the ontology event format before emotion is computed.",
|
|
49
|
+
'',
|
|
50
|
+
'### Step 1: interaction_type (required)',
|
|
51
|
+
'Determine the conversation mode: chat (small talk), inform (sharing info/news), humor (jokes/playfulness), express (emotional/relational event), goodbye (farewell/parting).',
|
|
52
|
+
'',
|
|
53
|
+
'### Step 2: event_type (only when interaction_type is "express")',
|
|
54
|
+
'If the message contains a relationship event, classify it: praise, criticism, support, rejection, apology, request, betrayal, or neglect.',
|
|
55
|
+
'Omit event_type for chat, inform, humor, or goodbye — these do not carry relationship events.',
|
|
56
|
+
'',
|
|
57
|
+
'### Step 3: agent_role, target_role, relationship, intensity',
|
|
58
|
+
'agent_role: who performed the action. target_role: who is affected by or receives the action.',
|
|
59
|
+
'Example: "you did great" → interaction=express, event=praise, agent=user, target=self.',
|
|
60
|
+
'Example: "nice weather" → interaction=chat, no event_type, agent=user, target=self.',
|
|
61
|
+
'Example: "my friend betrayed me" → interaction=express, event=betrayal, agent=other, target=user.',
|
|
62
|
+
].join('\n');
|
|
63
|
+
}
|
|
64
|
+
/** Convert an EventAppraisal to the ontologyEvent shape for API. */
|
|
65
|
+
function toOntologyEvent(event) {
|
|
66
|
+
return {
|
|
67
|
+
interaction_type: event.interaction_type,
|
|
68
|
+
...(event.event_type ? { event_type: event.event_type } : {}),
|
|
69
|
+
agent_role: event.agent_role,
|
|
70
|
+
target_role: event.target_role,
|
|
71
|
+
relationship: event.relationship,
|
|
72
|
+
intensity: event.intensity,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
32
75
|
export async function chat(deps, message, options) {
|
|
33
76
|
const fromOption = options?.from ?? 'user';
|
|
34
77
|
const from = typeof fromOption === 'string' ? fromOption : fromOption.name;
|
|
@@ -62,30 +105,33 @@ export async function chat(deps, message, options) {
|
|
|
62
105
|
}
|
|
63
106
|
let responseText;
|
|
64
107
|
let appraisal;
|
|
108
|
+
let ontologyEvent;
|
|
65
109
|
let earlyPerceiveResponse;
|
|
66
110
|
// Split mode: engineLlm handles appraisal, primary llm handles response text
|
|
67
111
|
if (deps.engineLlm && deps.engineLlm !== deps.llm) {
|
|
68
|
-
const { AppraisalVectorSchema } = await import('../llm/schema');
|
|
69
|
-
const appraisalInstruction = [
|
|
70
|
-
'',
|
|
71
|
-
'## Appraisal Task',
|
|
72
|
-
"Evaluate how RECEIVING the user's message affects this persona emotionally.",
|
|
73
|
-
'The event you are appraising is the message itself arriving — not the described situation.',
|
|
74
|
-
"When the user shares their own experience (e.g. loss, success), appraise through the persona's relational goals: caring about the speaker makes their suffering relevant and incongruent.",
|
|
75
|
-
"Rate each dimension from the persona's subjective perspective.",
|
|
76
|
-
'An insult should produce negative goal_congruence and norm_compatibility.',
|
|
77
|
-
'A compliment should produce positive values. Neutral small talk should be near zero.',
|
|
78
|
-
].join('\n');
|
|
79
112
|
const appraisalMessages = messages.length <= 5 ? messages : messages.slice(-5);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
113
|
+
if (deps.appraisalMode === 'event') {
|
|
114
|
+
const { EventAppraisalSchema } = await import('../llm/schema');
|
|
115
|
+
const { object: appraisalResult } = await deps.engineLlm.generateObject({
|
|
116
|
+
system: systemPrompt + buildEventAppraisalInstruction(),
|
|
117
|
+
messages: appraisalMessages,
|
|
118
|
+
schema: EventAppraisalSchema,
|
|
119
|
+
});
|
|
120
|
+
ontologyEvent = toOntologyEvent(appraisalResult);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const { AppraisalVectorSchema } = await import('../llm/schema');
|
|
124
|
+
const { object: appraisalResult } = await deps.engineLlm.generateObject({
|
|
125
|
+
system: systemPrompt + buildDirectAppraisalInstruction(),
|
|
126
|
+
messages: appraisalMessages,
|
|
127
|
+
schema: AppraisalVectorSchema,
|
|
128
|
+
});
|
|
129
|
+
appraisal = clampAppraisal(appraisalResult);
|
|
130
|
+
}
|
|
86
131
|
earlyPerceiveResponse = await deps.perceive(message, {
|
|
87
132
|
from,
|
|
88
|
-
appraisal,
|
|
133
|
+
...(appraisal ? { appraisal } : {}),
|
|
134
|
+
...(ontologyEvent ? { ontologyEvent } : {}),
|
|
89
135
|
priorEpisodes: recalledEpisodes.length > 0 ? recalledEpisodes : undefined,
|
|
90
136
|
skipMemory: true,
|
|
91
137
|
});
|
|
@@ -112,17 +158,30 @@ export async function chat(deps, message, options) {
|
|
|
112
158
|
else if (hasTools) {
|
|
113
159
|
const result = await generateWithToolLoop(deps, systemPrompt, messages, options?.onToolCall);
|
|
114
160
|
responseText = result.text;
|
|
115
|
-
appraisal =
|
|
161
|
+
appraisal = result.appraisal;
|
|
162
|
+
ontologyEvent = result.ontologyEvent;
|
|
116
163
|
}
|
|
117
164
|
else {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
165
|
+
if (deps.appraisalMode === 'event') {
|
|
166
|
+
const { LLMEventResponseSchema } = await import('../llm/schema');
|
|
167
|
+
const { object: llmResult } = await deps.llm.generateObject({
|
|
168
|
+
system: systemPrompt + buildEventAppraisalInstruction(),
|
|
169
|
+
messages,
|
|
170
|
+
schema: LLMEventResponseSchema,
|
|
171
|
+
});
|
|
172
|
+
responseText = llmResult.response;
|
|
173
|
+
ontologyEvent = toOntologyEvent(llmResult);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
const { LLMResponseSchema } = await import('../llm/schema');
|
|
177
|
+
const { object: llmResult } = await deps.llm.generateObject({
|
|
178
|
+
system: systemPrompt,
|
|
179
|
+
messages,
|
|
180
|
+
schema: LLMResponseSchema,
|
|
181
|
+
});
|
|
182
|
+
responseText = llmResult.response;
|
|
183
|
+
appraisal = clampAppraisal(llmResult.appraisal ?? { ...NEUTRAL_APPRAISAL });
|
|
184
|
+
}
|
|
126
185
|
}
|
|
127
186
|
// 4. Send to API for emotion processing (skip if already done in split mode)
|
|
128
187
|
let response;
|
|
@@ -132,7 +191,8 @@ export async function chat(deps, message, options) {
|
|
|
132
191
|
else {
|
|
133
192
|
response = await deps.perceive(responseText, {
|
|
134
193
|
from,
|
|
135
|
-
appraisal:
|
|
194
|
+
...(appraisal ? { appraisal } : {}),
|
|
195
|
+
...(ontologyEvent ? { ontologyEvent } : {}),
|
|
136
196
|
priorEpisodes: recalledEpisodes.length > 0 ? recalledEpisodes : undefined,
|
|
137
197
|
skipMemory: true,
|
|
138
198
|
});
|
|
@@ -158,40 +218,60 @@ export async function chat(deps, message, options) {
|
|
|
158
218
|
}
|
|
159
219
|
async function generateWithToolLoop(deps, system, messages, onToolCall) {
|
|
160
220
|
const MAX_TOOL_ITERATIONS = 3;
|
|
161
|
-
const {
|
|
221
|
+
const { LLMEventResponseSchema, LLMEventResponseWithToolsSchema, LLMResponseSchema, LLMResponseWithToolsSchema, } = await import('../llm/schema');
|
|
162
222
|
let currentSystem = system;
|
|
163
223
|
for (let iteration = 0; iteration < MAX_TOOL_ITERATIONS; iteration++) {
|
|
224
|
+
if (deps.appraisalMode === 'event') {
|
|
225
|
+
const { object: llmResult } = await deps.llm.generateObject({
|
|
226
|
+
system: currentSystem + buildEventAppraisalInstruction(),
|
|
227
|
+
messages,
|
|
228
|
+
schema: LLMEventResponseWithToolsSchema,
|
|
229
|
+
});
|
|
230
|
+
if (!llmResult.search_memory) {
|
|
231
|
+
return {
|
|
232
|
+
text: llmResult.response,
|
|
233
|
+
ontologyEvent: toOntologyEvent(llmResult),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
const query = llmResult.search_memory;
|
|
237
|
+
const episodes = [];
|
|
238
|
+
if (onToolCall) {
|
|
239
|
+
onToolCall({ name: 'search_memory', args: { query }, result: episodes });
|
|
240
|
+
}
|
|
241
|
+
const resultBlock = `\n\n## Memory Search Results (query: "${query}")\nNo matching memories found.`;
|
|
242
|
+
currentSystem = currentSystem + resultBlock;
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
164
245
|
const { object: llmResult } = await deps.llm.generateObject({
|
|
165
246
|
system: currentSystem,
|
|
166
247
|
messages,
|
|
167
248
|
schema: LLMResponseWithToolsSchema,
|
|
168
249
|
});
|
|
169
250
|
if (!llmResult.search_memory) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
251
|
+
return {
|
|
252
|
+
text: llmResult.response,
|
|
253
|
+
appraisal: clampAppraisal(llmResult.appraisal ?? { ...NEUTRAL_APPRAISAL }),
|
|
254
|
+
};
|
|
173
255
|
}
|
|
174
256
|
const query = llmResult.search_memory;
|
|
175
|
-
|
|
176
|
-
try {
|
|
177
|
-
episodes = await deps.searchMemory(query);
|
|
178
|
-
}
|
|
179
|
-
catch {
|
|
180
|
-
// Memory search failed — continue without results
|
|
181
|
-
}
|
|
257
|
+
const episodes = [];
|
|
182
258
|
if (onToolCall) {
|
|
183
259
|
onToolCall({ name: 'search_memory', args: { query }, result: episodes });
|
|
184
260
|
}
|
|
185
|
-
const resultBlock =
|
|
186
|
-
? `\n\n## Memory Search Results (query: "${query}")\n${episodes.map(ep => {
|
|
187
|
-
const ts = ep.timestamp ? new Date(ep.timestamp).toISOString() : 'unknown';
|
|
188
|
-
const source = ep.sourceEntity ?? 'unknown';
|
|
189
|
-
const context = ep.context ?? 'no context';
|
|
190
|
-
return `- [${ts}] ${source}: ${context}`;
|
|
191
|
-
}).join('\n')}`
|
|
192
|
-
: `\n\n## Memory Search Results (query: "${query}")\nNo matching memories found.`;
|
|
261
|
+
const resultBlock = `\n\n## Memory Search Results (query: "${query}")\nNo matching memories found.`;
|
|
193
262
|
currentSystem = currentSystem + resultBlock;
|
|
194
263
|
}
|
|
264
|
+
if (deps.appraisalMode === 'event') {
|
|
265
|
+
const { object: finalResult } = await deps.llm.generateObject({
|
|
266
|
+
system: currentSystem + buildEventAppraisalInstruction(),
|
|
267
|
+
messages,
|
|
268
|
+
schema: LLMEventResponseSchema,
|
|
269
|
+
});
|
|
270
|
+
return {
|
|
271
|
+
text: finalResult.response,
|
|
272
|
+
ontologyEvent: toOntologyEvent(finalResult),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
195
275
|
const { object: finalResult } = await deps.llm.generateObject({
|
|
196
276
|
system: currentSystem,
|
|
197
277
|
messages,
|
|
@@ -199,6 +279,6 @@ async function generateWithToolLoop(deps, system, messages, onToolCall) {
|
|
|
199
279
|
});
|
|
200
280
|
return {
|
|
201
281
|
text: finalResult.response,
|
|
202
|
-
appraisal: finalResult.appraisal ?? { ...NEUTRAL_APPRAISAL },
|
|
282
|
+
appraisal: clampAppraisal(finalResult.appraisal ?? { ...NEUTRAL_APPRAISAL }),
|
|
203
283
|
};
|
|
204
284
|
}
|
package/dist/esm/persona.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { LLMAdapter, Message } from './llm/adapter';
|
|
|
2
2
|
import { type LLMInput } from './llm/resolve';
|
|
3
3
|
import type { MemoryAdapter, RecallLimits } from './memory/types';
|
|
4
4
|
import type { EventAdapter } from './events/types';
|
|
5
|
-
import type { AgentResponse, AppraisalVector, InterlocutorContext, PersonaSnapshot, PersonaConfigData, PerceiveOptions } from './types';
|
|
5
|
+
import type { AgentResponse, AppraisalMode, AppraisalVector, InterlocutorContext, PersonaSnapshot, PersonaConfigData, PerceiveOptions } from './types';
|
|
6
6
|
/** Configuration for connecting to a standalone persona instance. */
|
|
7
7
|
export interface MolrooPersonaConfig {
|
|
8
8
|
/** Base URL of the molroo API. Defaults to 'https://api.molroo.io'. */
|
|
@@ -30,6 +30,8 @@ export interface MolrooPersonaConfig {
|
|
|
30
30
|
* memory_consolidated, reflection_generated, etc.).
|
|
31
31
|
*/
|
|
32
32
|
events?: EventAdapter;
|
|
33
|
+
/** Appraisal generation mode for `chat()`. Defaults to `direct`. */
|
|
34
|
+
appraisalMode?: AppraisalMode;
|
|
33
35
|
}
|
|
34
36
|
/** Summary of a persona instance, returned by list operations. */
|
|
35
37
|
export interface PersonaSummary {
|
|
@@ -95,6 +97,7 @@ export declare class MolrooPersona {
|
|
|
95
97
|
private memoryRecallConfig;
|
|
96
98
|
private events;
|
|
97
99
|
private _personaId;
|
|
100
|
+
private appraisalMode;
|
|
98
101
|
constructor(config: MolrooPersonaConfig & {
|
|
99
102
|
llm?: LLMAdapter;
|
|
100
103
|
engineLlm?: LLMAdapter;
|
|
@@ -121,6 +124,7 @@ export declare class MolrooPersona {
|
|
|
121
124
|
memory?: MemoryAdapter;
|
|
122
125
|
recall?: RecallLimits;
|
|
123
126
|
events?: EventAdapter;
|
|
127
|
+
appraisalMode?: AppraisalMode;
|
|
124
128
|
}, description: string): Promise<MolrooPersona>;
|
|
125
129
|
/**
|
|
126
130
|
* Create a new persona with explicit configuration.
|
|
@@ -141,6 +145,7 @@ export declare class MolrooPersona {
|
|
|
141
145
|
memory?: MemoryAdapter;
|
|
142
146
|
recall?: RecallLimits;
|
|
143
147
|
events?: EventAdapter;
|
|
148
|
+
appraisalMode?: AppraisalMode;
|
|
144
149
|
}, personaConfig: PersonaConfigData): Promise<MolrooPersona>;
|
|
145
150
|
/**
|
|
146
151
|
* Internal implementation for creating persona with resolved config.
|
|
@@ -159,6 +164,7 @@ export declare class MolrooPersona {
|
|
|
159
164
|
memory?: MemoryAdapter;
|
|
160
165
|
recall?: RecallLimits;
|
|
161
166
|
events?: EventAdapter;
|
|
167
|
+
appraisalMode?: AppraisalMode;
|
|
162
168
|
}, description: string): Promise<MolrooPersona>;
|
|
163
169
|
static connect(config: {
|
|
164
170
|
baseUrl?: string;
|
|
@@ -168,6 +174,7 @@ export declare class MolrooPersona {
|
|
|
168
174
|
memory?: MemoryAdapter;
|
|
169
175
|
recall?: RecallLimits;
|
|
170
176
|
events?: EventAdapter;
|
|
177
|
+
appraisalMode?: AppraisalMode;
|
|
171
178
|
}, personaId: string): Promise<MolrooPersona>;
|
|
172
179
|
static listPersonas(config: {
|
|
173
180
|
baseUrl?: string;
|
|
@@ -198,6 +205,24 @@ export declare class MolrooPersona {
|
|
|
198
205
|
A: number;
|
|
199
206
|
D: number;
|
|
200
207
|
}>): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* Set StyleProfile extracted from a text corpus.
|
|
210
|
+
* Once set, expression constraints (promptText) are automatically
|
|
211
|
+
* included in getPromptContext() and modulated by current emotion.
|
|
212
|
+
*/
|
|
213
|
+
setStyleProfile(profile: Record<string, unknown>): Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* Extract a StyleProfile from a text corpus and save it to this persona.
|
|
216
|
+
* Delegates extraction to the API server (keeps expression logic server-side).
|
|
217
|
+
*
|
|
218
|
+
* @param corpus - Array of messages from this persona's author (min 50 recommended)
|
|
219
|
+
* @param options - Optional extraction configuration (timestamps, otherMessages)
|
|
220
|
+
* @returns The extracted StyleProfile
|
|
221
|
+
*/
|
|
222
|
+
extractStyleProfile(corpus: string[], options?: {
|
|
223
|
+
timestamps?: number[];
|
|
224
|
+
otherMessages?: string[];
|
|
225
|
+
}): Promise<Record<string, unknown>>;
|
|
201
226
|
getState(): Promise<PersonaState>;
|
|
202
227
|
getSnapshot(): Promise<PersonaSnapshot>;
|
|
203
228
|
putSnapshot(snapshot: PersonaSnapshot): Promise<void>;
|
|
@@ -211,10 +236,6 @@ export declare class MolrooPersona {
|
|
|
211
236
|
personaPrompt: Record<string, unknown>;
|
|
212
237
|
tools?: Array<Record<string, unknown>>;
|
|
213
238
|
}>;
|
|
214
|
-
searchMemory(query: string, options?: {
|
|
215
|
-
topK?: number;
|
|
216
|
-
minImportance?: number;
|
|
217
|
-
}): Promise<Array<Record<string, unknown>>>;
|
|
218
239
|
private get memoryPipelineDeps();
|
|
219
240
|
private requireLLM;
|
|
220
241
|
}
|
|
@@ -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,gBA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WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;IAOvC,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IASrD,KAAK,CAAC,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,iBAAiB,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAUxB,gBAAgB,CACpB,cAAc,CAAC,EAAE,MAAM,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KAAE,CAAC;IAapH,OAAO,KAAK,kBAAkB,GAQ7B;IAED,OAAO,CAAC,UAAU;CAUnB"}
|
package/dist/esm/persona.js
CHANGED
|
@@ -21,6 +21,7 @@ export class MolrooPersona {
|
|
|
21
21
|
this.events = config.events ?? null;
|
|
22
22
|
this.memoryAdapter = config.memory ?? null;
|
|
23
23
|
this.memoryRecallConfig = config.recall;
|
|
24
|
+
this.appraisalMode = config.appraisalMode ?? 'direct';
|
|
24
25
|
}
|
|
25
26
|
// ── Properties ──
|
|
26
27
|
get id() {
|
|
@@ -107,9 +108,13 @@ export class MolrooPersona {
|
|
|
107
108
|
relationshipContext: options?.relationshipContext,
|
|
108
109
|
}
|
|
109
110
|
: undefined;
|
|
111
|
+
// Pass ontologyEvent alongside event/context — API converts to appraisal internally
|
|
112
|
+
const ontologyEvent = (!options?.appraisal && options?.ontologyEvent)
|
|
113
|
+
? options.ontologyEvent
|
|
114
|
+
: undefined;
|
|
110
115
|
const { data } = await this.client.POST('/personas/{id}/perceive', {
|
|
111
116
|
params: { path: { id: this._personaId } },
|
|
112
|
-
body: { event, context },
|
|
117
|
+
body: { event, context, ...(ontologyEvent ? { ontologyEvent } : {}) },
|
|
113
118
|
});
|
|
114
119
|
const response = unwrap(data);
|
|
115
120
|
if (!options?.skipMemory && response.memoryEpisode && this.memoryAdapter) {
|
|
@@ -132,9 +137,9 @@ export class MolrooPersona {
|
|
|
132
137
|
memoryAdapter: this.memoryAdapter,
|
|
133
138
|
memoryRecallConfig: this.memoryRecallConfig,
|
|
134
139
|
events: this.events,
|
|
140
|
+
appraisalMode: this.appraisalMode,
|
|
135
141
|
getPromptContext: (suffix, source) => this.getPromptContext(suffix, source),
|
|
136
142
|
perceive: (msg, opts) => this.perceive(msg, opts),
|
|
137
|
-
searchMemory: (query) => this.searchMemory(query),
|
|
138
143
|
};
|
|
139
144
|
return chatOrchestrator(deps, message, options);
|
|
140
145
|
}
|
|
@@ -151,6 +156,33 @@ export class MolrooPersona {
|
|
|
151
156
|
body: { vad },
|
|
152
157
|
});
|
|
153
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Set StyleProfile extracted from a text corpus.
|
|
161
|
+
* Once set, expression constraints (promptText) are automatically
|
|
162
|
+
* included in getPromptContext() and modulated by current emotion.
|
|
163
|
+
*/
|
|
164
|
+
async setStyleProfile(profile) {
|
|
165
|
+
await this.client.POST('/personas/{id}/style-profile', {
|
|
166
|
+
params: { path: { id: this._personaId } },
|
|
167
|
+
body: { profile },
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Extract a StyleProfile from a text corpus and save it to this persona.
|
|
172
|
+
* Delegates extraction to the API server (keeps expression logic server-side).
|
|
173
|
+
*
|
|
174
|
+
* @param corpus - Array of messages from this persona's author (min 50 recommended)
|
|
175
|
+
* @param options - Optional extraction configuration (timestamps, otherMessages)
|
|
176
|
+
* @returns The extracted StyleProfile
|
|
177
|
+
*/
|
|
178
|
+
async extractStyleProfile(corpus, options) {
|
|
179
|
+
const { data } = await this.client.POST('/personas/{id}/style-profile/extract', {
|
|
180
|
+
params: { path: { id: this._personaId } },
|
|
181
|
+
body: { corpus, ...(options ? { options } : {}) },
|
|
182
|
+
});
|
|
183
|
+
const result = unwrap(data);
|
|
184
|
+
return result.styleProfile;
|
|
185
|
+
}
|
|
154
186
|
// ── State ──
|
|
155
187
|
async getState() {
|
|
156
188
|
const { data } = await this.client.GET('/personas/{id}/state', {
|
|
@@ -203,18 +235,6 @@ export class MolrooPersona {
|
|
|
203
235
|
});
|
|
204
236
|
return unwrap(data);
|
|
205
237
|
}
|
|
206
|
-
async searchMemory(query, options) {
|
|
207
|
-
const { data } = await this.client.POST('/personas/{id}/memory/search', {
|
|
208
|
-
params: { path: { id: this._personaId } },
|
|
209
|
-
body: {
|
|
210
|
-
query,
|
|
211
|
-
...(options?.topK ? { topK: options.topK } : {}),
|
|
212
|
-
...(options?.minImportance ? { minImportance: options.minImportance } : {}),
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
const result = unwrap(data);
|
|
216
|
-
return result.episodes;
|
|
217
|
-
}
|
|
218
238
|
// ── Private ──
|
|
219
239
|
get memoryPipelineDeps() {
|
|
220
240
|
return {
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -24,12 +24,16 @@ export interface InterlocutorContext {
|
|
|
24
24
|
type PerceiveBody = RequestBody<'/personas/{id}/perceive', 'post'>;
|
|
25
25
|
export type PerceiveEvent = PerceiveBody['event'];
|
|
26
26
|
export type PerceiveContext = NonNullable<PerceiveBody['context']>;
|
|
27
|
+
export type AppraisalMode = 'direct' | 'event';
|
|
27
28
|
/** Options for {@link MolrooPersona.perceive}. */
|
|
28
29
|
export interface PerceiveOptions {
|
|
29
30
|
/** Source entity — a name string or structured {@link InterlocutorContext}. */
|
|
30
31
|
from?: string | InterlocutorContext;
|
|
31
32
|
/** Pre-computed appraisal vector (maps to event.appraisal). */
|
|
32
33
|
appraisal?: AppraisalVector;
|
|
34
|
+
/** Ontology-classified event — API converts to appraisal internally.
|
|
35
|
+
* Mutually exclusive with `appraisal`; if both provided, `appraisal` takes precedence. */
|
|
36
|
+
ontologyEvent?: EventAppraisal;
|
|
33
37
|
/** Event type (default: 'chat_message'). */
|
|
34
38
|
type?: string;
|
|
35
39
|
/** Low-level stimulus overrides (bodyBudgetDelta, vadOverride, etc.). */
|
|
@@ -38,14 +42,22 @@ export interface PerceiveOptions {
|
|
|
38
42
|
payload?: Record<string, unknown>;
|
|
39
43
|
/** Prior episodic memories for context-aware appraisal. */
|
|
40
44
|
priorEpisodes?: Episode[];
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
/** Full relationship state for social update computation.
|
|
46
|
+
* When provided, the engine computes trust/intimacy/proximity deltas
|
|
47
|
+
* and emits socialUpdates in the response.
|
|
48
|
+
* Typically sourced from World-level storage (D1). */
|
|
49
|
+
relationshipContext?: Record<string, unknown>;
|
|
46
50
|
/** Skip saving memoryEpisode to the episode store. Default: false. */
|
|
47
51
|
skipMemory?: boolean;
|
|
48
52
|
}
|
|
53
|
+
export interface EventAppraisal {
|
|
54
|
+
interaction_type: 'chat' | 'inform' | 'humor' | 'express' | 'goodbye';
|
|
55
|
+
event_type?: 'praise' | 'criticism' | 'support' | 'rejection' | 'apology' | 'request' | 'betrayal' | 'neglect';
|
|
56
|
+
agent_role: 'user' | 'self' | 'other';
|
|
57
|
+
target_role: 'user' | 'self' | 'other';
|
|
58
|
+
relationship: 'friend' | 'romantic' | 'authority' | 'stranger';
|
|
59
|
+
intensity: number;
|
|
60
|
+
}
|
|
49
61
|
export type PersonaDynamicState = Record<string, unknown>;
|
|
50
62
|
export type BlendRatio = Record<string, number>;
|
|
51
63
|
export interface AgentResponse {
|
|
@@ -63,6 +75,7 @@ export interface AgentResponse {
|
|
|
63
75
|
stageTransition?: StageTransition;
|
|
64
76
|
maskExposure?: MaskExposure;
|
|
65
77
|
goalChanges?: GoalChanges;
|
|
78
|
+
behaviorModifiers?: Record<string, number>;
|
|
66
79
|
[key: string]: unknown;
|
|
67
80
|
}
|
|
68
81
|
export interface ApiResponse<T> {
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAI7C,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AACpD,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAIjF,MAAM,MAAM,WAAW,CACrB,CAAC,SAAS,MAAM,KAAK,EACrB,CAAC,SAAS,MAAM,GAAG,KAAK,GAAG,OAAO,IAChC,KAAK,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE;YAAE,kBAAkB,EAAE,MAAM,CAAC,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,CAAC,GAC1F,CAAC,GACD,KAAK,CAAC;AAeV;;2EAE2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAID,KAAK,YAAY,GAAG,WAAW,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;AACnE,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;AAClD,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"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,MAAM,WAAW,kBAAkB;IAAG,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;AAC9E,MAAM,WAAW,eAAe;IAAG,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,qBAAqB,EAAE,mBAAmB,EAAE,CAAC;IAAC,eAAe,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAE;AAErK,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,GAAG,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,KAAK,CAAC,GAAG,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,WAAW,EAAE,MAAM,CAAC;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,MAAM,UAAU,CAAC"}
|
|
@@ -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 { PersonaConfigData } from '../types';
|
|
5
|
+
import type { AppraisalMode, 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,6 +18,8 @@ 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;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Unified entry point for the molroo SDK.
|