@siduri-x/core 2.0.3 → 2.0.5
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/chat-contract.d.ts +4 -0
- package/dist/chat-contract.js +17 -2
- package/dist/context-retriever.d.ts +3 -0
- package/dist/context-retriever.js +23 -2
- package/dist/conversational-teach.test.d.ts +1 -0
- package/dist/conversational-teach.test.js +513 -0
- package/dist/index.d.ts +11 -3
- package/dist/memory-settler.d.ts +22 -1
- package/dist/memory-settler.js +70 -9
- package/dist/mouth-types.d.ts +7 -2
- package/dist/perception-pipeline.d.ts +1 -0
- package/dist/perception-pipeline.js +20 -2
- package/dist/prompt-compiler.d.ts +4 -0
- package/dist/prompt-compiler.js +8 -1
- package/dist/proposals.d.ts +2 -1
- package/dist/response-envelope.d.ts +4 -0
- package/dist/response-envelope.js +14 -3
- package/dist/runtime.d.ts +47 -1
- package/dist/runtime.js +209 -2
- package/dist/siduri-db.d.ts +14 -2
- package/dist/siduri-db.js +217 -127
- package/dist/siduri-db.test.js +19 -18
- package/dist/teaching.js +201 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ import { EvidenceRecord } from './evidence';
|
|
|
31
31
|
import { ActionIntent } from './action';
|
|
32
32
|
import { RequestContext } from './context';
|
|
33
33
|
import { EarIngestOptions } from './ear-types';
|
|
34
|
-
import { ClaimType, ClaimAuthority, ClaimStatus, SourceEvent, MemoryProposal, BehaviorProposal } from './proposals';
|
|
34
|
+
import { ClaimType, ClaimAuthority, ClaimStatus, DirectiveStatus, SourceEvent, MemoryProposal, BehaviorProposal } from './proposals';
|
|
35
35
|
export interface OrganConfig {
|
|
36
36
|
provider: string;
|
|
37
37
|
[key: string]: unknown;
|
|
@@ -61,6 +61,8 @@ export interface BrainContext {
|
|
|
61
61
|
export interface ResponsePlan {
|
|
62
62
|
speech: string;
|
|
63
63
|
language: string;
|
|
64
|
+
subtitle?: string;
|
|
65
|
+
subtitles?: Record<string, string>;
|
|
64
66
|
memoryProposals?: MemoryProposal[];
|
|
65
67
|
behaviorProposals?: BehaviorProposal[];
|
|
66
68
|
actionIntents?: ActionIntent[];
|
|
@@ -98,7 +100,7 @@ export interface BehaviorDirective {
|
|
|
98
100
|
companionId: string;
|
|
99
101
|
directive: string;
|
|
100
102
|
priority: number;
|
|
101
|
-
status:
|
|
103
|
+
status: DirectiveStatus;
|
|
102
104
|
supersedesId?: string;
|
|
103
105
|
memoryClass?: 'identity' | 'relationship' | 'behavioral';
|
|
104
106
|
subject?: string;
|
|
@@ -259,7 +261,9 @@ import type { SelfIdentity, PersonalityTraits, SelfDirective, SelfRelationship,
|
|
|
259
261
|
export type { SelfIdentity, PersonalityTraits, SelfDirective, SelfRelationship, SelfDialogueExample, LifeInventoryItem, LifeScheduleItem, LifePreference, MemoryClaim, EpisodicEvent, };
|
|
260
262
|
export interface SelfRepository {
|
|
261
263
|
getIdentity(companionId: string): Promise<SelfIdentity | undefined>;
|
|
264
|
+
setIdentity(identity: SelfIdentity): Promise<void>;
|
|
262
265
|
getPersonality?(companionId: string): Promise<PersonalityTraits>;
|
|
266
|
+
setPersonality?(companionId: string, traits: PersonalityTraits): Promise<void>;
|
|
263
267
|
getActiveDirectives(companionId: string): Promise<SelfDirective[]>;
|
|
264
268
|
getRelationship(companionId: string, entityId: string): Promise<SelfRelationship | null>;
|
|
265
269
|
getRelationships?(companionId: string): Promise<SelfRelationship[]>;
|
|
@@ -267,7 +271,11 @@ export interface SelfRepository {
|
|
|
267
271
|
setExemplars?(companionId: string, exemplars: SelfDialogueExample[]): Promise<void>;
|
|
268
272
|
commitDirectives(companionId: string, directives: SelfDirective[]): Promise<void>;
|
|
269
273
|
updateRelationship(companionId: string, rel: SelfRelationship): Promise<void>;
|
|
270
|
-
disableDirective?(id: string): Promise<void>;
|
|
274
|
+
disableDirective?(id: string, companionId?: string): Promise<void>;
|
|
275
|
+
approveDirective?(id: string, companionId?: string): Promise<void>;
|
|
276
|
+
rejectDirective?(id: string, companionId?: string): Promise<void>;
|
|
277
|
+
revokeDirective?(id: string, companionId?: string): Promise<void>;
|
|
278
|
+
expireDirective?(id: string, companionId?: string): Promise<void>;
|
|
271
279
|
getActiveSelf?(companionId: string): Promise<{
|
|
272
280
|
identity?: SelfIdentity;
|
|
273
281
|
personality?: PersonalityTraits;
|
package/dist/memory-settler.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MemoryOrgan, Claim, ResponsePlan, RequestContext, InteractionMode } from './index';
|
|
1
|
+
import { MemoryOrgan, SelfRepository, Claim, BehaviorDirective, ResponsePlan, RequestContext, InteractionMode } from './index';
|
|
2
2
|
import { extractDeterministicTeaching } from './teaching';
|
|
3
3
|
export interface MemorySettlementParams {
|
|
4
4
|
companionId: string;
|
|
@@ -6,6 +6,7 @@ export interface MemorySettlementParams {
|
|
|
6
6
|
role: 'OWNER' | 'VIEWER' | 'OPERATOR';
|
|
7
7
|
requestContext: RequestContext;
|
|
8
8
|
memory?: MemoryOrgan;
|
|
9
|
+
self?: SelfRepository;
|
|
9
10
|
explicitTeaching: ReturnType<typeof extractDeterministicTeaching>;
|
|
10
11
|
plan: ResponsePlan;
|
|
11
12
|
effectiveMode?: InteractionMode;
|
|
@@ -16,10 +17,30 @@ export interface MemoryProposalReceipt {
|
|
|
16
17
|
predicate: string;
|
|
17
18
|
value: string;
|
|
18
19
|
status: string;
|
|
20
|
+
claim_type?: string;
|
|
21
|
+
content?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface BehavioralProposalReceipt {
|
|
24
|
+
directive_id: string;
|
|
25
|
+
domain?: string;
|
|
26
|
+
knowledge_domain?: string;
|
|
27
|
+
memory_class?: string;
|
|
28
|
+
runtime_effect?: string;
|
|
29
|
+
subject?: string;
|
|
30
|
+
predicate?: string;
|
|
31
|
+
value?: string;
|
|
32
|
+
status: string;
|
|
33
|
+
behavior?: {
|
|
34
|
+
instruction: string;
|
|
35
|
+
frequency?: string;
|
|
36
|
+
preferred_positions?: string[];
|
|
37
|
+
};
|
|
19
38
|
}
|
|
20
39
|
export interface MemorySettlementResult {
|
|
21
40
|
createdMemoryProposals: Claim[];
|
|
22
41
|
memoryProposalReceipts: MemoryProposalReceipt[];
|
|
42
|
+
createdBehavioralProposals?: BehaviorDirective[];
|
|
43
|
+
behavioralProposalReceipts?: BehavioralProposalReceipt[];
|
|
23
44
|
}
|
|
24
45
|
/**
|
|
25
46
|
* Persists source events, deterministic teaching claims, LLM memory proposals,
|
package/dist/memory-settler.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.settleMemoryProposals = settleMemoryProposals;
|
|
|
6
6
|
* and LLM behavior proposals to the MemoryOrgan.
|
|
7
7
|
*/
|
|
8
8
|
async function settleMemoryProposals(params) {
|
|
9
|
-
const { companionId, perceivedText, role, requestContext, memory, explicitTeaching, plan, effectiveMode, } = params;
|
|
9
|
+
const { companionId, perceivedText, role, requestContext, memory, self, explicitTeaching, plan, effectiveMode, } = params;
|
|
10
10
|
// Zero Memory Drift: Casual mode completely suppresses all proposal generation
|
|
11
11
|
const mode = effectiveMode || requestContext.mode || 'hybrid';
|
|
12
12
|
if (mode === 'casual') {
|
|
@@ -43,6 +43,7 @@ async function settleMemoryProposals(params) {
|
|
|
43
43
|
if (memory && typeof memory.proposeClaim === 'function') {
|
|
44
44
|
for (const claim of explicitTeaching.claims) {
|
|
45
45
|
const proposal = await memory.proposeClaim({
|
|
46
|
+
companionId,
|
|
46
47
|
subject: claim.subject,
|
|
47
48
|
predicate: claim.predicate,
|
|
48
49
|
value: claim.value,
|
|
@@ -61,6 +62,7 @@ async function settleMemoryProposals(params) {
|
|
|
61
62
|
if (plan.memoryProposals && plan.memoryProposals.length > 0) {
|
|
62
63
|
for (const p of plan.memoryProposals) {
|
|
63
64
|
const proposal = await memory.proposeClaim({
|
|
65
|
+
companionId,
|
|
64
66
|
subject: p.subject || `actor:${requestContext.actor.actorId}`,
|
|
65
67
|
predicate: p.predicate,
|
|
66
68
|
value: p.value,
|
|
@@ -74,27 +76,86 @@ async function settleMemoryProposals(params) {
|
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
const createdBehavioralProposals = [];
|
|
80
|
+
const behavioralProposalReceipts = [];
|
|
81
|
+
const allBehaviorProposals = [
|
|
82
|
+
...explicitTeaching.behaviorProposals,
|
|
83
|
+
...(plan.behaviorProposals || []),
|
|
84
|
+
];
|
|
85
|
+
for (const bp of allBehaviorProposals) {
|
|
86
|
+
let directive;
|
|
87
|
+
if (memory && typeof memory.proposeDirective === 'function') {
|
|
88
|
+
directive = await memory.proposeDirective({
|
|
89
|
+
companionId,
|
|
83
90
|
directive: bp.directive,
|
|
84
91
|
priority: bp.priority || 50,
|
|
85
|
-
|
|
92
|
+
category: bp.category || 'behavioral',
|
|
93
|
+
supersedesId: bp.supersedesId,
|
|
94
|
+
scopeActor: bp.scopeActor || (bp.subject?.startsWith('actor:') ? bp.subject.slice(6) : undefined),
|
|
95
|
+
memoryClass: bp.memoryClass,
|
|
96
|
+
subject: bp.subject,
|
|
97
|
+
predicate: bp.predicate,
|
|
98
|
+
value: bp.value,
|
|
99
|
+
sourceEventId: sourceEventId || bp.sourceEventId,
|
|
86
100
|
});
|
|
87
101
|
}
|
|
102
|
+
if (!directive || !directive.id) {
|
|
103
|
+
directive = {
|
|
104
|
+
id: directive?.id || `dir-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
|
|
105
|
+
companionId,
|
|
106
|
+
directive: bp.directive,
|
|
107
|
+
priority: bp.priority || 50,
|
|
108
|
+
status: 'pending',
|
|
109
|
+
category: (bp.category || 'behavioral'),
|
|
110
|
+
scopeActor: bp.scopeActor,
|
|
111
|
+
supersedesId: bp.supersedesId,
|
|
112
|
+
createdAt: new Date().toISOString(),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
createdBehavioralProposals.push(directive);
|
|
116
|
+
if (self && typeof self.commitDirectives === 'function') {
|
|
117
|
+
await self.commitDirectives(companionId, [{
|
|
118
|
+
id: directive.id,
|
|
119
|
+
companionId,
|
|
120
|
+
directive: bp.directive,
|
|
121
|
+
priority: bp.priority || 50,
|
|
122
|
+
status: 'pending',
|
|
123
|
+
category: (bp.category || 'behavioral'),
|
|
124
|
+
scopeActor: bp.scopeActor,
|
|
125
|
+
supersedesId: bp.supersedesId,
|
|
126
|
+
createdAt: new Date().toISOString(),
|
|
127
|
+
}]);
|
|
128
|
+
}
|
|
129
|
+
behavioralProposalReceipts.push({
|
|
130
|
+
directive_id: directive.id,
|
|
131
|
+
domain: 'behavioral',
|
|
132
|
+
knowledge_domain: 'behavioral',
|
|
133
|
+
memory_class: bp.memoryClass || 'behavioral',
|
|
134
|
+
runtime_effect: bp.memoryClass || 'behavioral',
|
|
135
|
+
subject: bp.subject || `companion:${companionId}`,
|
|
136
|
+
predicate: bp.predicate || 'rule',
|
|
137
|
+
value: bp.value || bp.directive,
|
|
138
|
+
status: 'pending',
|
|
139
|
+
behavior: {
|
|
140
|
+
instruction: bp.directive,
|
|
141
|
+
frequency: 'continuous',
|
|
142
|
+
preferred_positions: [],
|
|
143
|
+
},
|
|
144
|
+
});
|
|
88
145
|
}
|
|
89
146
|
const memoryProposalReceipts = createdMemoryProposals.map((p) => ({
|
|
90
147
|
proposal_id: p.id,
|
|
91
148
|
subject: p.subject,
|
|
92
149
|
predicate: p.predicate,
|
|
93
150
|
value: p.value,
|
|
94
|
-
status: p.status,
|
|
151
|
+
status: (p.status || 'pending').toLowerCase().replace(/_/g, '-'),
|
|
152
|
+
claim_type: p.claimType,
|
|
153
|
+
content: p.content,
|
|
95
154
|
}));
|
|
96
155
|
return {
|
|
97
156
|
createdMemoryProposals,
|
|
98
157
|
memoryProposalReceipts,
|
|
158
|
+
createdBehavioralProposals,
|
|
159
|
+
behavioralProposalReceipts,
|
|
99
160
|
};
|
|
100
161
|
}
|
package/dist/mouth-types.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ export interface MouthUtterance {
|
|
|
17
17
|
subtitleJa?: string;
|
|
18
18
|
subtitleEn?: string;
|
|
19
19
|
spokenJa?: string;
|
|
20
|
+
subtitle?: string;
|
|
21
|
+
subtitleLanguage?: string;
|
|
22
|
+
subtitles?: Record<string, string>;
|
|
20
23
|
expression?: string;
|
|
21
24
|
action?: string;
|
|
22
25
|
medium?: MouthMedium;
|
|
@@ -35,10 +38,12 @@ export interface FormattedMouthOutput {
|
|
|
35
38
|
ssml?: string;
|
|
36
39
|
visemes?: MouthVisemeCue[];
|
|
37
40
|
subtitles?: {
|
|
38
|
-
ja
|
|
39
|
-
en
|
|
41
|
+
ja?: string;
|
|
42
|
+
en?: string;
|
|
40
43
|
spoken?: string;
|
|
44
|
+
[lang: string]: string | undefined;
|
|
41
45
|
};
|
|
46
|
+
subtitle?: string;
|
|
42
47
|
audioUrl?: string;
|
|
43
48
|
audioBuffer?: Uint8Array;
|
|
44
49
|
expression?: string;
|
|
@@ -88,11 +88,15 @@ const promptCompilationStage = async (context) => {
|
|
|
88
88
|
requestContext: context.input.requestContext,
|
|
89
89
|
behavior: context.organs.behavior,
|
|
90
90
|
activeDirectives: context.contextRetrieval.activeDirectives,
|
|
91
|
+
selfIdentity: context.contextRetrieval.selfIdentity,
|
|
92
|
+
selfRelationship: context.contextRetrieval.selfRelationship,
|
|
93
|
+
personality: context.contextRetrieval.personality,
|
|
91
94
|
subsystemDiagnostics: context.contextRetrieval.subsystemDiagnostics,
|
|
92
95
|
knowledgeData: context.contextRetrieval.knowledgeData,
|
|
93
96
|
memoryData: context.contextRetrieval.memoryData,
|
|
94
97
|
lifeContext: context.contextRetrieval.lifeContext,
|
|
95
98
|
effectiveMode: context.intent?.effectiveMode,
|
|
99
|
+
subtitleLanguage: context.perception.subtitleLanguage,
|
|
96
100
|
});
|
|
97
101
|
context.prompts = prompts;
|
|
98
102
|
};
|
|
@@ -120,8 +124,14 @@ const responseGatingStage = async (context) => {
|
|
|
120
124
|
candidateSpeech: context.plan.speech,
|
|
121
125
|
candidateLanguage: context.plan.language || 'ja',
|
|
122
126
|
internalMonologue: context.plan.internalMonologue,
|
|
123
|
-
memoryProposals:
|
|
124
|
-
|
|
127
|
+
memoryProposals: [
|
|
128
|
+
...(context.intent?.explicitTeaching?.claims || []),
|
|
129
|
+
...(context.plan.memoryProposals || []),
|
|
130
|
+
],
|
|
131
|
+
behaviorProposals: [
|
|
132
|
+
...(context.intent?.explicitTeaching?.behaviorProposals || []),
|
|
133
|
+
...(context.plan.behaviorProposals || []),
|
|
134
|
+
],
|
|
125
135
|
evidenceRecords: context.contextRetrieval.collectedEvidence,
|
|
126
136
|
citations: context.contextRetrieval.citations,
|
|
127
137
|
});
|
|
@@ -145,6 +155,7 @@ const memorySettlementStage = async (context) => {
|
|
|
145
155
|
role: context.input.role,
|
|
146
156
|
requestContext: context.input.requestContext,
|
|
147
157
|
memory: context.organs.memory,
|
|
158
|
+
self: context.organs.self,
|
|
148
159
|
explicitTeaching: context.intent.explicitTeaching,
|
|
149
160
|
plan: context.plan,
|
|
150
161
|
effectiveMode: context.intent.effectiveMode,
|
|
@@ -198,6 +209,9 @@ const mouthDeliveryStage = async (context) => {
|
|
|
198
209
|
subtitleJa: context.plan.speech,
|
|
199
210
|
subtitleEn: context.plan.speech,
|
|
200
211
|
spokenJa: context.plan.speech,
|
|
212
|
+
subtitle: context.plan.subtitle,
|
|
213
|
+
subtitles: context.plan.subtitles,
|
|
214
|
+
subtitleLanguage: context.perception.subtitleLanguage,
|
|
201
215
|
expression: avatarEvent?.expression,
|
|
202
216
|
medium: context.perception.medium,
|
|
203
217
|
signal: context.perception.signal,
|
|
@@ -226,9 +240,13 @@ const envelopeAssemblyStage = async (context) => {
|
|
|
226
240
|
stagedPlan: context.stagedPlan,
|
|
227
241
|
speech: context.plan.speech,
|
|
228
242
|
language: context.plan.language,
|
|
243
|
+
subtitle: context.plan.subtitle,
|
|
244
|
+
subtitles: context.plan.subtitles,
|
|
245
|
+
subtitleLanguage: context.perception.subtitleLanguage,
|
|
229
246
|
speechId: context.experienceEmission?.speechId,
|
|
230
247
|
createdMemoryProposals: context.memorySettlement.createdMemoryProposals,
|
|
231
248
|
memoryProposalReceipts: context.memorySettlement.memoryProposalReceipts,
|
|
249
|
+
behavioralProposalReceipts: context.memorySettlement.behavioralProposalReceipts,
|
|
232
250
|
actionResults: context.actionResults || [],
|
|
233
251
|
filteredEvidenceIds: context.gateEval.filteredEvidenceIds,
|
|
234
252
|
filteredCitations: context.gateEval.filteredCitations,
|
|
@@ -6,11 +6,15 @@ export interface PromptCompilationParams {
|
|
|
6
6
|
requestContext: RequestContext;
|
|
7
7
|
behavior?: BehaviorOrgan;
|
|
8
8
|
activeDirectives: BehaviorDirective[];
|
|
9
|
+
selfIdentity?: any;
|
|
10
|
+
selfRelationship?: any;
|
|
11
|
+
personality?: any;
|
|
9
12
|
subsystemDiagnostics: Record<string, string>;
|
|
10
13
|
knowledgeData: KnowledgeItem[];
|
|
11
14
|
memoryData: Claim[];
|
|
12
15
|
lifeContext?: string[];
|
|
13
16
|
effectiveMode?: InteractionMode;
|
|
17
|
+
subtitleLanguage?: string;
|
|
14
18
|
}
|
|
15
19
|
export interface CompiledPrompts {
|
|
16
20
|
systemPrompt: string;
|
package/dist/prompt-compiler.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.compilePrompts = compilePrompts;
|
|
|
5
5
|
* Compiles neutral system prompt and formatted context prompt from structured data.
|
|
6
6
|
*/
|
|
7
7
|
async function compilePrompts(params) {
|
|
8
|
-
const { companionName, companionId, role, requestContext, behavior, activeDirectives, subsystemDiagnostics, knowledgeData, memoryData, lifeContext, effectiveMode, } = params;
|
|
8
|
+
const { companionName, companionId, role, requestContext, behavior, activeDirectives, selfIdentity, selfRelationship, personality, subsystemDiagnostics, knowledgeData, memoryData, lifeContext, effectiveMode, subtitleLanguage, } = params;
|
|
9
9
|
let contextPrompt = '';
|
|
10
10
|
if (Object.keys(subsystemDiagnostics).length > 0) {
|
|
11
11
|
contextPrompt +=
|
|
@@ -40,6 +40,9 @@ async function compilePrompts(params) {
|
|
|
40
40
|
? await behavior.compile({
|
|
41
41
|
directives: activeDirectives,
|
|
42
42
|
companionId,
|
|
43
|
+
identity: selfIdentity,
|
|
44
|
+
relationship: selfRelationship,
|
|
45
|
+
personality,
|
|
43
46
|
actorId: requestContext.actor.actorId,
|
|
44
47
|
})
|
|
45
48
|
: '';
|
|
@@ -48,9 +51,13 @@ async function compilePrompts(params) {
|
|
|
48
51
|
: effectiveMode === 'teach'
|
|
49
52
|
? 'Operating Mode: Teach Mode (Active learning session - accurately capture user preferences and proposed boundaries for operator review).'
|
|
50
53
|
: undefined;
|
|
54
|
+
const subtitleInstruction = subtitleLanguage && subtitleLanguage !== 'off'
|
|
55
|
+
? `Requested Subtitle Language: "${subtitleLanguage}". Along with your primary speech, provide a natural subtitle translation in "${subtitleLanguage}" in the subtitle field.`
|
|
56
|
+
: undefined;
|
|
51
57
|
const systemPrompt = [
|
|
52
58
|
`You are ${companionName}.`,
|
|
53
59
|
modeInstruction,
|
|
60
|
+
subtitleInstruction,
|
|
54
61
|
'This is a neutral conversation context.',
|
|
55
62
|
'Use only approved, permitted memory as factual personal context.',
|
|
56
63
|
'Do not claim prior personal knowledge when no approved memory supports it.',
|
package/dist/proposals.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type ClaimType = 'semantic' | 'preference' | 'episodic' | 'relationship';
|
|
2
2
|
export type ClaimAuthority = 'user_explicit' | 'user_correction' | 'import' | 'repeated_dialogue' | 'inference' | 'observation';
|
|
3
|
-
export type ClaimStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'SESSION_ONLY' | 'EXPIRED' | 'SUPERSEDED' | 'REVOKED';
|
|
3
|
+
export type ClaimStatus = 'pending' | 'approved' | 'rejected' | 'session-only' | 'expired' | 'superseded' | 'revoked' | 'PENDING' | 'APPROVED' | 'REJECTED' | 'SESSION_ONLY' | 'EXPIRED' | 'SUPERSEDED' | 'REVOKED';
|
|
4
|
+
export type DirectiveStatus = 'pending' | 'active' | 'disabled' | 'superseded' | 'rejected' | 'revoked' | 'expired' | 'confirmed' | 'PENDING' | 'ACTIVE' | 'DISABLED' | 'SUPERSEDED' | 'REJECTED' | 'REVOKED' | 'EXPIRED';
|
|
4
5
|
export interface SourceEvent {
|
|
5
6
|
id: string;
|
|
6
7
|
sourceType: string;
|
|
@@ -5,9 +5,13 @@ export interface AssembleResponseEnvelopeParams {
|
|
|
5
5
|
stagedPlan: StagedResponsePlan;
|
|
6
6
|
speech: string;
|
|
7
7
|
language?: string;
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
subtitles?: Record<string, string>;
|
|
10
|
+
subtitleLanguage?: string;
|
|
8
11
|
speechId?: string;
|
|
9
12
|
createdMemoryProposals: Claim[];
|
|
10
13
|
memoryProposalReceipts: MemoryProposalReceipt[];
|
|
14
|
+
behavioralProposalReceipts?: any[];
|
|
11
15
|
actionResults: ActionExecutionResult[];
|
|
12
16
|
filteredEvidenceIds?: string[];
|
|
13
17
|
filteredCitations?: ResponseCitation[];
|
|
@@ -29,7 +29,14 @@ function createGateRejectionEnvelope(stagedPlan, gateEval) {
|
|
|
29
29
|
* Assembles the standardized response structure for approved companion responses.
|
|
30
30
|
*/
|
|
31
31
|
function assembleResponseEnvelope(params) {
|
|
32
|
-
const { stagedPlan, speech, language, speechId, createdMemoryProposals, memoryProposalReceipts, actionResults, filteredEvidenceIds, filteredCitations, subsystemDiagnostics, experienceEvents, mouthDelivery, effectiveMode, } = params;
|
|
32
|
+
const { stagedPlan, speech, language, subtitle, subtitles, subtitleLanguage, speechId, createdMemoryProposals, memoryProposalReceipts, behavioralProposalReceipts, actionResults, filteredEvidenceIds, filteredCitations, subsystemDiagnostics, experienceEvents, mouthDelivery, effectiveMode, } = params;
|
|
33
|
+
const resolvedSubtitles = {
|
|
34
|
+
...(mouthDelivery?.subtitles || {}),
|
|
35
|
+
...(subtitles || {}),
|
|
36
|
+
};
|
|
37
|
+
if (subtitle && subtitleLanguage) {
|
|
38
|
+
resolvedSubtitles[subtitleLanguage] = subtitle;
|
|
39
|
+
}
|
|
33
40
|
return {
|
|
34
41
|
status: 'APPROVED',
|
|
35
42
|
response_id: stagedPlan.responseId,
|
|
@@ -37,8 +44,11 @@ function assembleResponseEnvelope(params) {
|
|
|
37
44
|
response: {
|
|
38
45
|
speech_id: speechId,
|
|
39
46
|
audio_url: mouthDelivery?.audioUrl ?? (speechId ? `/voice/stream?id=${speechId}` : undefined),
|
|
40
|
-
subtitle_ja: mouthDelivery?.subtitles?.ja ?? speech,
|
|
41
|
-
subtitle_en: mouthDelivery?.subtitles?.en ?? speech,
|
|
47
|
+
subtitle_ja: mouthDelivery?.subtitles?.ja ?? resolvedSubtitles['ja'] ?? speech,
|
|
48
|
+
subtitle_en: mouthDelivery?.subtitles?.en ?? resolvedSubtitles['en'] ?? speech,
|
|
49
|
+
subtitle: subtitle ?? (subtitleLanguage ? resolvedSubtitles[subtitleLanguage] : undefined),
|
|
50
|
+
subtitle_language: subtitleLanguage,
|
|
51
|
+
subtitles: resolvedSubtitles,
|
|
42
52
|
},
|
|
43
53
|
delivery: mouthDelivery,
|
|
44
54
|
metadata: {
|
|
@@ -46,6 +56,7 @@ function assembleResponseEnvelope(params) {
|
|
|
46
56
|
language,
|
|
47
57
|
proposals: createdMemoryProposals,
|
|
48
58
|
memory_proposals: memoryProposalReceipts,
|
|
59
|
+
behavioral_proposals: behavioralProposalReceipts || [],
|
|
49
60
|
action_results: actionResults,
|
|
50
61
|
evidence_ids: filteredEvidenceIds,
|
|
51
62
|
citations: filteredCitations,
|
package/dist/runtime.d.ts
CHANGED
|
@@ -38,6 +38,48 @@ export declare class SiduriRuntime {
|
|
|
38
38
|
initialize(): Promise<void>;
|
|
39
39
|
getSessionHistory(sessionKey: string): Message[];
|
|
40
40
|
clearHistory(sessionKey?: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Approves a memory proposal or behavior proposal and canonically promotes
|
|
43
|
+
* Self-affecting mutations to SelfRepository.
|
|
44
|
+
*/
|
|
45
|
+
approveProposal(proposalId: string, options?: {
|
|
46
|
+
companionId?: string;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
success: boolean;
|
|
49
|
+
target?: string;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Rejects a memory or behavior proposal.
|
|
53
|
+
*/
|
|
54
|
+
rejectProposal(proposalId: string, options?: {
|
|
55
|
+
companionId?: string;
|
|
56
|
+
}): Promise<{
|
|
57
|
+
success: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Approves a behavioral directive in Self and Memory.
|
|
61
|
+
*/
|
|
62
|
+
approveDirective(directiveId: string, options?: {
|
|
63
|
+
companionId?: string;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
success: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Rejects a behavioral directive in Self and Memory.
|
|
69
|
+
*/
|
|
70
|
+
rejectDirective(directiveId: string, options?: {
|
|
71
|
+
companionId?: string;
|
|
72
|
+
}): Promise<{
|
|
73
|
+
success: boolean;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Revokes a behavioral directive in Self and Memory.
|
|
77
|
+
*/
|
|
78
|
+
revokeDirective(directiveId: string, options?: {
|
|
79
|
+
companionId?: string;
|
|
80
|
+
}): Promise<{
|
|
81
|
+
success: boolean;
|
|
82
|
+
}>;
|
|
41
83
|
/**
|
|
42
84
|
* Processes an incoming perception (sensory audio, text, platform event, or observation alert)
|
|
43
85
|
* through the decoupled PerceptionPipeline.
|
|
@@ -46,5 +88,9 @@ export declare class SiduriRuntime {
|
|
|
46
88
|
/**
|
|
47
89
|
* Primary entrypoint for text chat messages.
|
|
48
90
|
*/
|
|
49
|
-
handleUserMessage(message: string, roleOrContext?: 'OWNER' | 'VIEWER' | 'OPERATOR' | RequestContext | string, history?: Message[], medium?: MouthMedium, signal?: AbortSignal): Promise<any>;
|
|
91
|
+
handleUserMessage(message: string, roleOrContext?: 'OWNER' | 'VIEWER' | 'OPERATOR' | RequestContext | string, history?: Message[], medium?: MouthMedium, signal?: AbortSignal, subtitleLanguage?: string): Promise<any>;
|
|
50
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Canonically promotes an approved Claim into SelfRepository state.
|
|
95
|
+
*/
|
|
96
|
+
export declare function promoteApprovedClaimToSelf(claim: any, self: SelfRepository, companionId?: string): Promise<void>;
|