@siduri-x/core 1.0.5 → 1.0.7
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/action-executor.d.ts +12 -0
- package/dist/action-executor.js +50 -0
- package/dist/action-policy.d.ts +45 -0
- package/dist/action-policy.js +219 -0
- package/dist/action-policy.test.d.ts +1 -0
- package/dist/action-policy.test.js +194 -0
- package/dist/action.d.ts +72 -0
- package/dist/action.js +2 -0
- package/dist/adversarial.test.d.ts +1 -0
- package/dist/adversarial.test.js +493 -0
- package/dist/architecture-boundary.test.d.ts +1 -0
- package/dist/architecture-boundary.test.js +117 -0
- package/dist/capability.d.ts +65 -0
- package/dist/capability.js +157 -0
- package/dist/capability.test.d.ts +1 -0
- package/dist/capability.test.js +269 -0
- package/dist/chat-contract.d.ts +81 -0
- package/dist/chat-contract.js +68 -0
- package/dist/cognition-planner.d.ts +15 -0
- package/dist/cognition-planner.js +23 -0
- package/dist/context-retriever.d.ts +24 -0
- package/dist/context-retriever.js +92 -0
- package/dist/context.d.ts +45 -0
- package/dist/context.js +72 -0
- package/dist/context.test.d.ts +1 -0
- package/dist/context.test.js +76 -0
- package/dist/dispatcher.d.ts +14 -0
- package/dist/dispatcher.js +40 -0
- package/dist/dispatcher.test.d.ts +1 -0
- package/dist/dispatcher.test.js +60 -0
- package/dist/ear-types.d.ts +33 -0
- package/dist/ear-types.js +2 -0
- package/dist/evidence.d.ts +76 -0
- package/dist/evidence.js +47 -0
- package/dist/evidence.test.d.ts +1 -0
- package/dist/evidence.test.js +101 -0
- package/dist/experience-emitter.d.ts +21 -0
- package/dist/experience-emitter.js +48 -0
- package/dist/experience.d.ts +57 -0
- package/dist/experience.js +79 -0
- package/dist/experience.test.d.ts +1 -0
- package/dist/experience.test.js +59 -0
- package/dist/gating.d.ts +46 -0
- package/dist/gating.js +185 -0
- package/dist/gating.test.d.ts +1 -0
- package/dist/gating.test.js +190 -0
- package/dist/index.d.ts +250 -0
- package/dist/index.js +43 -0
- package/dist/input-normalizer.d.ts +14 -0
- package/dist/input-normalizer.js +58 -0
- package/dist/input-normalizer.test.d.ts +1 -0
- package/dist/input-normalizer.test.js +39 -0
- package/dist/intent-classifier.d.ts +24 -0
- package/dist/intent-classifier.js +53 -0
- package/dist/intent-classifier.test.d.ts +1 -0
- package/dist/intent-classifier.test.js +68 -0
- package/dist/memory-settler.d.ts +27 -0
- package/dist/memory-settler.js +95 -0
- package/dist/mouth-types.d.ts +85 -0
- package/dist/mouth-types.js +2 -0
- package/dist/perception-cycle.test.d.ts +1 -0
- package/dist/perception-cycle.test.js +155 -0
- package/dist/prompt-compiler.d.ts +20 -0
- package/dist/prompt-compiler.js +57 -0
- package/dist/prompt-compiler.test.d.ts +1 -0
- package/dist/prompt-compiler.test.js +76 -0
- package/dist/proposals.d.ts +30 -0
- package/dist/proposals.js +2 -0
- package/dist/response-envelope.d.ts +25 -0
- package/dist/response-envelope.js +64 -0
- package/dist/runtime-facades.test.d.ts +1 -0
- package/dist/runtime-facades.test.js +69 -0
- package/dist/runtime.d.ts +114 -0
- package/dist/runtime.js +412 -0
- package/dist/session-history.d.ts +20 -0
- package/dist/session-history.js +55 -0
- package/dist/session-history.test.d.ts +1 -0
- package/dist/session-history.test.js +38 -0
- package/dist/sqlite-action-store.d.ts +20 -0
- package/dist/sqlite-action-store.js +225 -0
- package/dist/sqlite-action-store.test.d.ts +1 -0
- package/dist/sqlite-action-store.test.js +252 -0
- package/dist/teaching.d.ts +15 -0
- package/dist/teaching.js +159 -0
- package/package.json +1 -1
package/dist/teaching.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractDeterministicTeaching = extractDeterministicTeaching;
|
|
4
|
+
function cleanValue(value, limit = 160) {
|
|
5
|
+
return value.replace(/\s+/g, ' ').replace(/^[ .,!?:;"']+|[ .,!?:;"']+$/g, '').slice(0, limit);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Deterministically extracts teaching candidates from user messages according to neutral T1/T2 contracts.
|
|
9
|
+
*
|
|
10
|
+
* Rules:
|
|
11
|
+
* - Scoped to the requesting actor context (subject: `actor:${actorId}`), NEVER `primary_user`.
|
|
12
|
+
* - Candidates are pending proposals only, never active/approved.
|
|
13
|
+
* - Allowed audiences derive from the request conversation or policy context (e.g. direct audience).
|
|
14
|
+
* - Companion identity is isolated.
|
|
15
|
+
*/
|
|
16
|
+
function extractDeterministicTeaching(message, context, sourceEventId) {
|
|
17
|
+
const text = cleanValue(message, 1000);
|
|
18
|
+
const claims = [];
|
|
19
|
+
const behaviorProposals = [];
|
|
20
|
+
if (!text) {
|
|
21
|
+
return { claims, behaviorProposals };
|
|
22
|
+
}
|
|
23
|
+
const actorId = context?.actor?.actorId;
|
|
24
|
+
const actorSubject = actorId ? `actor:${actorId}` : 'actor:anonymous';
|
|
25
|
+
const companionId = context?.companionId || 'default';
|
|
26
|
+
const defaultAudience = context?.conversation?.audienceId || (context?.conversation?.channel === 'direct' ? `audience-direct-${actorId}` : 'audience-public');
|
|
27
|
+
const sensitivity = context?.conversation?.channel === 'public' ? 'public' : 'private';
|
|
28
|
+
// 1. Companion's Name: "your name is X" / "you are called X"
|
|
29
|
+
const companionNameMatch = text.match(/\b(?:your name is|you are called)\s+(.+?)(?=\s+and\s+(?:i\b|my\b|you\b)|[.;,]|$)/i);
|
|
30
|
+
if (companionNameMatch) {
|
|
31
|
+
const name = cleanValue(companionNameMatch[1], 80);
|
|
32
|
+
claims.push({
|
|
33
|
+
subject: `companion:${companionId}`,
|
|
34
|
+
predicate: 'name',
|
|
35
|
+
value: name,
|
|
36
|
+
content: `The companion's name is ${name}.`,
|
|
37
|
+
claimType: 'semantic',
|
|
38
|
+
provenance: 'deterministic_teaching',
|
|
39
|
+
sensitivity: 'public',
|
|
40
|
+
allowedAudiences: ['audience-public'],
|
|
41
|
+
sourceEventId,
|
|
42
|
+
});
|
|
43
|
+
behaviorProposals.push({
|
|
44
|
+
directive: `Acknowledge configured name as ${name}`,
|
|
45
|
+
priority: 70,
|
|
46
|
+
subject: `companion:${companionId}`,
|
|
47
|
+
predicate: 'name',
|
|
48
|
+
value: name,
|
|
49
|
+
memoryClass: 'identity',
|
|
50
|
+
sourceEventId,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// 2. Actor's Name: "my name is X"
|
|
54
|
+
const myNameMatch = text.match(/\bmy name is\s+(.+?)(?=\s+and\s+(?:i\b|my\b|you\b)|[.;,]|$)/i);
|
|
55
|
+
if (myNameMatch && !/\b(?:private|public|everywhere)\b/i.test(text)) {
|
|
56
|
+
const name = cleanValue(myNameMatch[1], 80);
|
|
57
|
+
claims.push({
|
|
58
|
+
subject: actorSubject,
|
|
59
|
+
predicate: 'name',
|
|
60
|
+
value: name,
|
|
61
|
+
content: `The actor's name is ${name}.`,
|
|
62
|
+
claimType: 'preference',
|
|
63
|
+
provenance: 'deterministic_teaching',
|
|
64
|
+
sensitivity,
|
|
65
|
+
allowedAudiences: [defaultAudience],
|
|
66
|
+
sourceEventId,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// 3. Preferred Address / Call me X: "call me X"
|
|
70
|
+
const callMeMatch = text.match(/\b(?:(?:from now on|only),?\s*)?call me\s+(.+?)(?:\s+(in private|privately|in public|publicly|everywhere|in direct conversations))?(?=\s+and\s+(?:i\b|my\b|you\b)|[.;,]|$)/i);
|
|
71
|
+
if (callMeMatch) {
|
|
72
|
+
const address = cleanValue(callMeMatch[1], 80);
|
|
73
|
+
const scopePhrase = (callMeMatch[2] || '').toLowerCase();
|
|
74
|
+
let claimAudiences = [defaultAudience];
|
|
75
|
+
let claimSensitivity = sensitivity;
|
|
76
|
+
let directiveInstruction = `Address ${actorSubject} as ${address}`;
|
|
77
|
+
if (scopePhrase.includes('private') || scopePhrase.includes('privately')) {
|
|
78
|
+
claimSensitivity = 'private';
|
|
79
|
+
claimAudiences = [context?.conversation?.audienceId || `audience-private-${actorId}`];
|
|
80
|
+
directiveInstruction += ' in private conversations';
|
|
81
|
+
}
|
|
82
|
+
else if (scopePhrase.includes('public') || scopePhrase.includes('publicly')) {
|
|
83
|
+
claimSensitivity = 'public';
|
|
84
|
+
claimAudiences = ['audience-public'];
|
|
85
|
+
directiveInstruction += ' in public conversations';
|
|
86
|
+
}
|
|
87
|
+
else if (scopePhrase.includes('direct')) {
|
|
88
|
+
claimSensitivity = 'private';
|
|
89
|
+
claimAudiences = [context?.conversation?.audienceId || `audience-direct-${actorId}`];
|
|
90
|
+
directiveInstruction += ' in direct conversations';
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
directiveInstruction += ' when addressing the actor';
|
|
94
|
+
}
|
|
95
|
+
claims.push({
|
|
96
|
+
subject: actorSubject,
|
|
97
|
+
predicate: 'preferred_address',
|
|
98
|
+
value: address,
|
|
99
|
+
content: `The actor's preferred address is ${address}.`,
|
|
100
|
+
claimType: 'relationship',
|
|
101
|
+
provenance: 'deterministic_teaching',
|
|
102
|
+
sensitivity: claimSensitivity,
|
|
103
|
+
allowedAudiences: claimAudiences,
|
|
104
|
+
sourceEventId,
|
|
105
|
+
});
|
|
106
|
+
behaviorProposals.push({
|
|
107
|
+
directive: directiveInstruction,
|
|
108
|
+
priority: 80,
|
|
109
|
+
subject: actorSubject,
|
|
110
|
+
predicate: 'preferred_address',
|
|
111
|
+
value: address,
|
|
112
|
+
memoryClass: 'behavioral',
|
|
113
|
+
sourceEventId,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// 4. Stated relationship: "I am your X" / "I'm your creator"
|
|
117
|
+
const relMatch = text.match(/\b(?:i am|i'm)\s+your\s+([A-Za-z0-9_\s-]+?)(?=\s+and\s+(?:i\b|my\b|you\b)|[.;,]|$)/i);
|
|
118
|
+
if (relMatch) {
|
|
119
|
+
const relationship = cleanValue(relMatch[1], 60);
|
|
120
|
+
claims.push({
|
|
121
|
+
subject: actorSubject,
|
|
122
|
+
predicate: 'stated_relationship',
|
|
123
|
+
value: relationship,
|
|
124
|
+
content: `The actor stated their relationship as ${relationship}.`,
|
|
125
|
+
claimType: 'relationship',
|
|
126
|
+
provenance: 'deterministic_teaching',
|
|
127
|
+
sensitivity: 'private',
|
|
128
|
+
allowedAudiences: [defaultAudience],
|
|
129
|
+
sourceEventId,
|
|
130
|
+
});
|
|
131
|
+
behaviorProposals.push({
|
|
132
|
+
directive: `Recognize ${actorSubject} stated relationship as ${relationship}`,
|
|
133
|
+
priority: 75,
|
|
134
|
+
subject: actorSubject,
|
|
135
|
+
predicate: 'stated_relationship',
|
|
136
|
+
value: relationship,
|
|
137
|
+
memoryClass: 'relationship',
|
|
138
|
+
sourceEventId,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// 5. Explicit Domain / Preference fact: "my preferred X is Y" / "my X is Y"
|
|
142
|
+
const prefMatch = text.match(/\bmy\s+preferred\s+([A-Za-z0-9_]+)\s+is\s+(.+?)(?=\s+and\s+(?:i\b|my\b|you\b)|[.;,]|$)/i);
|
|
143
|
+
if (prefMatch) {
|
|
144
|
+
const predicate = cleanValue(prefMatch[1], 40);
|
|
145
|
+
const val = cleanValue(prefMatch[2], 100);
|
|
146
|
+
claims.push({
|
|
147
|
+
subject: actorSubject,
|
|
148
|
+
predicate: `preferred_${predicate}`,
|
|
149
|
+
value: val,
|
|
150
|
+
content: `The actor's preferred ${predicate} is ${val}.`,
|
|
151
|
+
claimType: 'preference',
|
|
152
|
+
provenance: 'deterministic_teaching',
|
|
153
|
+
sensitivity,
|
|
154
|
+
allowedAudiences: [defaultAudience],
|
|
155
|
+
sourceEventId,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return { claims, behaviorProposals };
|
|
159
|
+
}
|
package/package.json
CHANGED