@siduri-x/core 1.0.9 → 2.0.1
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-policy.d.ts +28 -1
- package/dist/action-policy.js +167 -7
- package/dist/action-policy.test.js +104 -0
- package/dist/adversarial.test.js +4 -2
- package/dist/architecture-boundary.test.js +4 -12
- package/dist/capability.d.ts +11 -2
- package/dist/capability.js +8 -1
- package/dist/capability.test.js +43 -1
- package/dist/context-retriever.d.ts +8 -5
- package/dist/context-retriever.js +44 -15
- package/dist/database.d.ts +1 -0
- package/dist/database.js +17 -0
- package/dist/index.d.ts +46 -7
- package/dist/index.js +2 -0
- package/dist/prompt-compiler.d.ts +1 -0
- package/dist/prompt-compiler.js +7 -1
- package/dist/runtime.d.ts +12 -5
- package/dist/runtime.js +26 -8
- package/dist/schema-validator.test.js +2 -2
- package/dist/siduri-db.d.ts +138 -0
- package/dist/siduri-db.js +687 -0
- package/dist/siduri-db.test.d.ts +1 -0
- package/dist/siduri-db.test.js +863 -0
- package/dist/sqlite-action-store.d.ts +3 -2
- package/dist/sqlite-action-store.js +27 -4
- package/dist/sqlite-action-store.test.js +1 -0
- package/package.json +6 -6
|
@@ -2,41 +2,69 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.retrieveRuntimeContext = retrieveRuntimeContext;
|
|
4
4
|
/**
|
|
5
|
-
* Concurrently queries Knowledge
|
|
6
|
-
*
|
|
5
|
+
* Concurrently queries Self, Knowledge (Life DB), External Knowledge, and Memory
|
|
6
|
+
* in a single parallel pass with graceful degradation.
|
|
7
7
|
*/
|
|
8
8
|
async function retrieveRuntimeContext(params) {
|
|
9
|
-
const { companionId, perceivedText, requestContext, role, isContextObject, shouldQueryKnowledge, knowledge, memory, } = params;
|
|
9
|
+
const { companionId, perceivedText, requestContext, role, isContextObject, shouldQueryKnowledge, knowledge, memory, self, externalKnowledge, } = params;
|
|
10
10
|
const queryOptions = isContextObject
|
|
11
11
|
? {
|
|
12
12
|
limit: 5,
|
|
13
13
|
}
|
|
14
14
|
: role;
|
|
15
15
|
const subsystemDiagnostics = {};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
// 1. Resolve External Knowledge organ (either explicitly passed or from legacy knowledge with .search)
|
|
17
|
+
const extKnowledge = externalKnowledge || (knowledge && typeof knowledge.search === 'function' ? knowledge : undefined);
|
|
18
|
+
// 2. Query all 4 streams in parallel
|
|
19
|
+
const [knowledgeData, memoryData, selfOrMemoryDirectives, lifeContext] = await Promise.all([
|
|
20
|
+
// Stream A: External Cited Lore / Documentation
|
|
21
|
+
extKnowledge && shouldQueryKnowledge && typeof extKnowledge.search === 'function'
|
|
22
|
+
? extKnowledge.search(perceivedText).catch((e) => {
|
|
19
23
|
console.error('[SiduriRuntime] Knowledge search failed:', e.message);
|
|
20
24
|
subsystemDiagnostics['knowledge'] = `UNAVAILABLE: ${e.message}`;
|
|
21
25
|
return [];
|
|
22
26
|
})
|
|
23
27
|
: Promise.resolve([]),
|
|
28
|
+
// Stream B: Episodic Memory / Verified Claims (SQLite FTS5)
|
|
24
29
|
memory && typeof memory.searchClaims === 'function'
|
|
25
|
-
?
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
? (async () => {
|
|
31
|
+
try {
|
|
32
|
+
// Support both (companionId, query, limit) and (query, options, limit)
|
|
33
|
+
const result = await memory.searchClaims(perceivedText, queryOptions, 5);
|
|
34
|
+
return result || [];
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
console.error('[SiduriRuntime] Memory search failed:', e.message);
|
|
38
|
+
subsystemDiagnostics['memory_claims'] = `UNAVAILABLE: ${e.message}`;
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
})()
|
|
42
|
+
: Promise.resolve([]),
|
|
43
|
+
// Stream C: Active Directives from Self (or fallback Memory)
|
|
44
|
+
self && typeof self.getActiveDirectives === 'function'
|
|
45
|
+
? self.getActiveDirectives(companionId).catch((e) => {
|
|
46
|
+
console.error('[SiduriRuntime] Self directives failed:', e.message);
|
|
47
|
+
subsystemDiagnostics['self_directives'] = `UNAVAILABLE: ${e.message}`;
|
|
28
48
|
return [];
|
|
29
49
|
})
|
|
30
|
-
:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
50
|
+
: memory && typeof memory.getDirectives === 'function'
|
|
51
|
+
? memory.getDirectives().catch((e) => {
|
|
52
|
+
console.error('[SiduriRuntime] Memory directives failed:', e.message);
|
|
53
|
+
subsystemDiagnostics['memory_directives'] = `UNAVAILABLE: ${e.message}`;
|
|
54
|
+
return [];
|
|
55
|
+
})
|
|
56
|
+
: Promise.resolve([]),
|
|
57
|
+
// Stream D: Sovereign Life DB Context (Finances, Inventory, Schedule, Preferences)
|
|
58
|
+
knowledge && typeof knowledge.queryContext === 'function'
|
|
59
|
+
? knowledge.queryContext(companionId, perceivedText).catch((e) => {
|
|
60
|
+
console.error('[SiduriRuntime] Life DB context failed:', e.message);
|
|
61
|
+
subsystemDiagnostics['life_db'] = `UNAVAILABLE: ${e.message}`;
|
|
35
62
|
return [];
|
|
36
63
|
})
|
|
37
64
|
: Promise.resolve([]),
|
|
38
65
|
]);
|
|
39
|
-
|
|
66
|
+
const activeDirectives = (selfOrMemoryDirectives || []);
|
|
67
|
+
// Build evidence records from retrieved external knowledge context
|
|
40
68
|
const collectedEvidence = [];
|
|
41
69
|
const citations = [];
|
|
42
70
|
if (knowledgeData.length > 0) {
|
|
@@ -86,5 +114,6 @@ async function retrieveRuntimeContext(params) {
|
|
|
86
114
|
subsystemDiagnostics,
|
|
87
115
|
collectedEvidence,
|
|
88
116
|
citations,
|
|
117
|
+
lifeContext,
|
|
89
118
|
};
|
|
90
119
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './siduri-db';
|
package/dist/database.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./siduri-db"), exports);
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export * from './experience-emitter';
|
|
|
23
23
|
export * from './response-envelope';
|
|
24
24
|
export * from './session-history';
|
|
25
25
|
export * from './schema-validator';
|
|
26
|
+
export * from './siduri-db';
|
|
27
|
+
export * from './database';
|
|
26
28
|
import { EvidenceRecord } from './evidence';
|
|
27
29
|
import { ActionIntent } from './action';
|
|
28
30
|
import { RequestContext } from './context';
|
|
@@ -122,13 +124,15 @@ export interface MemoryOrgan {
|
|
|
122
124
|
markClaimSessionOnly?(id: string): Promise<void>;
|
|
123
125
|
expireClaim?(id: string): Promise<void>;
|
|
124
126
|
revokeClaim?(id: string, reason?: string): Promise<void>;
|
|
125
|
-
getDirectives(): Promise<BehaviorDirective[]>;
|
|
126
|
-
proposeDirective(directiveData: Omit<BehaviorDirective, 'id' | 'status' | 'companionId'>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
getDirectives(companionId?: string): Promise<BehaviorDirective[]>;
|
|
128
|
+
proposeDirective(directiveData: Omit<BehaviorDirective, 'id' | 'status' | 'companionId'> & {
|
|
129
|
+
companionId?: string;
|
|
130
|
+
}): Promise<BehaviorDirective>;
|
|
131
|
+
approveDirective(id: string, companionId?: string): Promise<void>;
|
|
132
|
+
rejectDirective(id: string, companionId?: string): Promise<void>;
|
|
133
|
+
revokeDirective(id: string, companionId?: string): Promise<void>;
|
|
134
|
+
disableDirective(id: string, companionId?: string): Promise<void>;
|
|
135
|
+
expireDirective?(id: string, companionId?: string): Promise<void>;
|
|
132
136
|
supersedeClaim?(id: string, replacement: Omit<Claim, 'id' | 'status' | 'companionId'>): Promise<Claim>;
|
|
133
137
|
updateClaim?(id: string, updates: Partial<Pick<Claim, 'subject' | 'predicate' | 'value' | 'scope' | 'sensitivity' | 'confidence' | 'validFrom' | 'validUntil'>>): Promise<Claim>;
|
|
134
138
|
resetMemory?(): Promise<void>;
|
|
@@ -249,3 +253,38 @@ export interface HealthProbeResult {
|
|
|
249
253
|
}
|
|
250
254
|
export type HealthProbeFn = (context: HealthProbeContext) => Promise<HealthProbeResult> | HealthProbeResult;
|
|
251
255
|
export * from './mouth-types';
|
|
256
|
+
import type { SelfIdentity, PersonalityTraits, SelfDirective, SelfRelationship, LifeInventoryItem, LifeScheduleItem, LifePreference, MemoryClaim, EpisodicEvent } from './siduri-db';
|
|
257
|
+
export interface SelfRepository {
|
|
258
|
+
getIdentity(companionId: string): Promise<SelfIdentity | undefined>;
|
|
259
|
+
getPersonality(companionId: string): Promise<PersonalityTraits>;
|
|
260
|
+
getActiveDirectives(companionId: string): Promise<SelfDirective[]>;
|
|
261
|
+
getRelationship(companionId: string, entityId: string): Promise<SelfRelationship | null>;
|
|
262
|
+
commitDirectives(companionId: string, directives: SelfDirective[]): Promise<void>;
|
|
263
|
+
updateRelationship(companionId: string, rel: SelfRelationship): Promise<void>;
|
|
264
|
+
disableDirective?(id: string): Promise<void>;
|
|
265
|
+
getActiveSelf?(companionId: string): Promise<{
|
|
266
|
+
identity?: SelfIdentity;
|
|
267
|
+
personality: PersonalityTraits;
|
|
268
|
+
directives: SelfDirective[];
|
|
269
|
+
}>;
|
|
270
|
+
}
|
|
271
|
+
export interface LifeDatabase {
|
|
272
|
+
getInventory(companionId: string, domain?: string): Promise<LifeInventoryItem[]>;
|
|
273
|
+
getFinanceSummary?(companionId: string): Promise<any>;
|
|
274
|
+
getSchedule?(companionId: string, windowStart?: Date, windowEnd?: Date): Promise<LifeScheduleItem[]>;
|
|
275
|
+
getPreferences?(companionId: string): Promise<Record<string, string> | LifePreference[]>;
|
|
276
|
+
queryContext(companionId: string, query: string): Promise<string[]>;
|
|
277
|
+
searchLifeContext?(queryText: string): Promise<string[]>;
|
|
278
|
+
}
|
|
279
|
+
export interface EpisodicMemoryStore {
|
|
280
|
+
recordEvent(companionId: string, event: any): Promise<void>;
|
|
281
|
+
searchClaims(companionId: string, query: string, limit?: number): Promise<MemoryClaim[]>;
|
|
282
|
+
proposeClaim(claim: any): Promise<MemoryClaim>;
|
|
283
|
+
approveClaim(claimId: string): Promise<void>;
|
|
284
|
+
rejectClaim?(claimId: string): Promise<void>;
|
|
285
|
+
getApprovedClaims?(companionId: string, limit?: number): Promise<MemoryClaim[]>;
|
|
286
|
+
getRecentEvents?(companionId: string, limit?: number): Promise<EpisodicEvent[]>;
|
|
287
|
+
}
|
|
288
|
+
export interface EKnowledgeOrgan {
|
|
289
|
+
search(query: string): Promise<KnowledgeItem[]>;
|
|
290
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -40,5 +40,7 @@ __exportStar(require("./experience-emitter"), exports);
|
|
|
40
40
|
__exportStar(require("./response-envelope"), exports);
|
|
41
41
|
__exportStar(require("./session-history"), exports);
|
|
42
42
|
__exportStar(require("./schema-validator"), exports);
|
|
43
|
+
__exportStar(require("./siduri-db"), exports);
|
|
44
|
+
__exportStar(require("./database"), exports);
|
|
43
45
|
// Mouth (Communication & Output Delivery)
|
|
44
46
|
__exportStar(require("./mouth-types"), exports);
|
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, } = params;
|
|
8
|
+
const { companionName, companionId, role, requestContext, behavior, activeDirectives, subsystemDiagnostics, knowledgeData, memoryData, lifeContext, } = params;
|
|
9
9
|
let contextPrompt = '';
|
|
10
10
|
if (Object.keys(subsystemDiagnostics).length > 0) {
|
|
11
11
|
contextPrompt +=
|
|
@@ -29,6 +29,12 @@ async function compilePrompts(params) {
|
|
|
29
29
|
memoryData.map((m) => `- ${m.subject} ${m.predicate} ${m.value}`).join('\n') +
|
|
30
30
|
'\n';
|
|
31
31
|
}
|
|
32
|
+
if (lifeContext && lifeContext.length > 0) {
|
|
33
|
+
contextPrompt +=
|
|
34
|
+
'LIFE CONTEXT:\n' +
|
|
35
|
+
lifeContext.map((l) => `- ${l}`).join('\n') +
|
|
36
|
+
'\n';
|
|
37
|
+
}
|
|
32
38
|
// Compile Behavior with neutral context metadata
|
|
33
39
|
const behaviorInjections = behavior && typeof behavior.compile === 'function'
|
|
34
40
|
? await behavior.compile({
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrainOrgan, MemoryOrgan, VoiceOrgan, KnowledgeOrgan, VisionOrgan, BehaviorOrgan, BodyOrgan, HandsOrgan, EarOrgan, ObservationOrgan, ObservationResult, Observation, Message, RequestContext, ActionPolicyEngine, ActionStore, ResponseGatingEngine, StageResponseOptions, ApproveResponseOptions, RejectResponseOptions, ExperienceDispatcher, ExperienceAdapter, OrganConfig, Claim, BehaviorDirective, StagedResponsePlan, ResponseGateEvaluation, EvidenceRecord, MouthOrgan, MouthUtterance, MouthMedium, FormattedMouthOutput, MouthStreamChunk, MouthChannel } from './index';
|
|
1
|
+
import { BrainOrgan, MemoryOrgan, VoiceOrgan, KnowledgeOrgan, VisionOrgan, BehaviorOrgan, BodyOrgan, HandsOrgan, EarOrgan, ObservationOrgan, ObservationResult, Observation, Message, RequestContext, ActionPolicyEngine, ApproveActionOptions, ActionApprovalResult, ActionStore, ResponseGatingEngine, StageResponseOptions, ApproveResponseOptions, RejectResponseOptions, ExperienceDispatcher, ExperienceAdapter, OrganConfig, Claim, BehaviorDirective, StagedResponsePlan, ResponseGateEvaluation, EvidenceRecord, MouthOrgan, MouthUtterance, MouthMedium, FormattedMouthOutput, MouthStreamChunk, MouthChannel, SelfRepository, EKnowledgeOrgan } from './index';
|
|
2
2
|
export interface SiduriRuntimeConfig {
|
|
3
3
|
name: string;
|
|
4
4
|
brain?: OrganConfig | Record<string, unknown>;
|
|
@@ -12,6 +12,8 @@ export interface SiduriRuntimeConfig {
|
|
|
12
12
|
ear?: OrganConfig | Record<string, unknown>;
|
|
13
13
|
observation?: OrganConfig | Record<string, unknown>;
|
|
14
14
|
mouth?: OrganConfig | Record<string, unknown>;
|
|
15
|
+
self?: OrganConfig | Record<string, unknown>;
|
|
16
|
+
externalKnowledge?: OrganConfig | Record<string, unknown>;
|
|
15
17
|
actionPolicy?: Record<string, unknown>;
|
|
16
18
|
actionStore?: 'in-memory' | 'sqlite' | {
|
|
17
19
|
type: 'sqlite' | 'in-memory';
|
|
@@ -32,6 +34,8 @@ export interface RuntimeOrgans {
|
|
|
32
34
|
ear?: EarOrgan;
|
|
33
35
|
observation?: ObservationOrgan;
|
|
34
36
|
mouth?: MouthOrgan;
|
|
37
|
+
self?: SelfRepository;
|
|
38
|
+
externalKnowledge?: EKnowledgeOrgan;
|
|
35
39
|
actionStore?: ActionStore;
|
|
36
40
|
actionPolicy?: ActionPolicyEngine;
|
|
37
41
|
}
|
|
@@ -65,6 +69,8 @@ export declare class SiduriRuntime {
|
|
|
65
69
|
ear?: EarOrgan;
|
|
66
70
|
observation?: ObservationOrgan;
|
|
67
71
|
mouth?: MouthOrgan;
|
|
72
|
+
self?: SelfRepository;
|
|
73
|
+
externalKnowledge?: EKnowledgeOrgan;
|
|
68
74
|
gating: ResponseGatingEngine;
|
|
69
75
|
actionPolicy: ActionPolicyEngine;
|
|
70
76
|
dispatcher: ExperienceDispatcher;
|
|
@@ -85,10 +91,10 @@ export declare class SiduriRuntime {
|
|
|
85
91
|
approveClaim(id: string): Promise<void>;
|
|
86
92
|
rejectClaim(id: string): Promise<void>;
|
|
87
93
|
updateClaim(id: string, updates: Partial<Pick<Claim, 'subject' | 'predicate' | 'value' | 'scope' | 'sensitivity' | 'confidence' | 'validFrom' | 'validUntil'>>): Promise<Claim>;
|
|
88
|
-
approveDirective(id: string): Promise<void>;
|
|
89
|
-
rejectDirective(id: string): Promise<void>;
|
|
90
|
-
revokeDirective(id: string): Promise<void>;
|
|
91
|
-
disableDirective(id: string): Promise<void>;
|
|
94
|
+
approveDirective(id: string, companionId?: string): Promise<void>;
|
|
95
|
+
rejectDirective(id: string, companionId?: string): Promise<void>;
|
|
96
|
+
revokeDirective(id: string, companionId?: string): Promise<void>;
|
|
97
|
+
disableDirective(id: string, companionId?: string): Promise<void>;
|
|
92
98
|
resetMemory(): Promise<void>;
|
|
93
99
|
stageResponse(options: StageResponseOptions): StagedResponsePlan;
|
|
94
100
|
evaluateGate(plan: StagedResponsePlan, evidenceRecords?: EvidenceRecord[]): ResponseGateEvaluation;
|
|
@@ -102,6 +108,7 @@ export declare class SiduriRuntime {
|
|
|
102
108
|
reason?: string;
|
|
103
109
|
plan?: StagedResponsePlan;
|
|
104
110
|
};
|
|
111
|
+
approveAction(options: ApproveActionOptions): Promise<ActionApprovalResult>;
|
|
105
112
|
getStagedPlan(responseId: string): StagedResponsePlan | undefined;
|
|
106
113
|
findStagedPlanByCorrelation(companionId: string, correlationId: string): StagedResponsePlan | undefined;
|
|
107
114
|
/**
|
package/dist/runtime.js
CHANGED
|
@@ -31,6 +31,8 @@ class SiduriRuntime {
|
|
|
31
31
|
ear;
|
|
32
32
|
observation;
|
|
33
33
|
mouth;
|
|
34
|
+
self;
|
|
35
|
+
externalKnowledge;
|
|
34
36
|
gating;
|
|
35
37
|
actionPolicy;
|
|
36
38
|
dispatcher;
|
|
@@ -56,6 +58,8 @@ class SiduriRuntime {
|
|
|
56
58
|
this.ear = organs.ear;
|
|
57
59
|
this.observation = organs.observation;
|
|
58
60
|
this.mouth = organs.mouth;
|
|
61
|
+
this.self = organs.self;
|
|
62
|
+
this.externalKnowledge = organs.externalKnowledge;
|
|
59
63
|
this.gating = new index_1.ResponseGatingEngine();
|
|
60
64
|
let actionStore = organs.actionStore;
|
|
61
65
|
if (!actionStore) {
|
|
@@ -159,29 +163,37 @@ class SiduriRuntime {
|
|
|
159
163
|
}
|
|
160
164
|
return this.memory.updateClaim(id, updates);
|
|
161
165
|
}
|
|
162
|
-
async approveDirective(id) {
|
|
166
|
+
async approveDirective(id, companionId) {
|
|
163
167
|
if (!this.memory || typeof this.memory.approveDirective !== 'function') {
|
|
164
168
|
throw new Error('Memory organ not configured');
|
|
165
169
|
}
|
|
166
|
-
return
|
|
170
|
+
return companionId !== undefined
|
|
171
|
+
? this.memory.approveDirective(id, companionId)
|
|
172
|
+
: this.memory.approveDirective(id);
|
|
167
173
|
}
|
|
168
|
-
async rejectDirective(id) {
|
|
174
|
+
async rejectDirective(id, companionId) {
|
|
169
175
|
if (!this.memory || typeof this.memory.rejectDirective !== 'function') {
|
|
170
176
|
throw new Error('Memory organ not configured');
|
|
171
177
|
}
|
|
172
|
-
return
|
|
178
|
+
return companionId !== undefined
|
|
179
|
+
? this.memory.rejectDirective(id, companionId)
|
|
180
|
+
: this.memory.rejectDirective(id);
|
|
173
181
|
}
|
|
174
|
-
async revokeDirective(id) {
|
|
182
|
+
async revokeDirective(id, companionId) {
|
|
175
183
|
if (!this.memory || typeof this.memory.revokeDirective !== 'function') {
|
|
176
184
|
throw new Error('Memory organ not configured');
|
|
177
185
|
}
|
|
178
|
-
return
|
|
186
|
+
return companionId !== undefined
|
|
187
|
+
? this.memory.revokeDirective(id, companionId)
|
|
188
|
+
: this.memory.revokeDirective(id);
|
|
179
189
|
}
|
|
180
|
-
async disableDirective(id) {
|
|
190
|
+
async disableDirective(id, companionId) {
|
|
181
191
|
if (!this.memory || typeof this.memory.disableDirective !== 'function') {
|
|
182
192
|
throw new Error('Memory organ not configured');
|
|
183
193
|
}
|
|
184
|
-
return
|
|
194
|
+
return companionId !== undefined
|
|
195
|
+
? this.memory.disableDirective(id, companionId)
|
|
196
|
+
: this.memory.disableDirective(id);
|
|
185
197
|
}
|
|
186
198
|
async resetMemory() {
|
|
187
199
|
if (!this.memory || typeof this.memory.resetMemory !== 'function') {
|
|
@@ -202,6 +214,9 @@ class SiduriRuntime {
|
|
|
202
214
|
rejectResponse(options) {
|
|
203
215
|
return this.gating.rejectResponse(options);
|
|
204
216
|
}
|
|
217
|
+
async approveAction(options) {
|
|
218
|
+
return this.actionPolicy.approveAction(options);
|
|
219
|
+
}
|
|
205
220
|
getStagedPlan(responseId) {
|
|
206
221
|
return this.gating.getStagedPlan(responseId);
|
|
207
222
|
}
|
|
@@ -244,6 +259,8 @@ class SiduriRuntime {
|
|
|
244
259
|
shouldQueryKnowledge: intent.shouldQueryKnowledge,
|
|
245
260
|
knowledge: this.knowledge,
|
|
246
261
|
memory: this.memory,
|
|
262
|
+
self: this.self,
|
|
263
|
+
externalKnowledge: this.externalKnowledge,
|
|
247
264
|
});
|
|
248
265
|
// 4. Neutral system prompt and contextual prompt compilation
|
|
249
266
|
const prompts = await (0, prompt_compiler_1.compilePrompts)({
|
|
@@ -256,6 +273,7 @@ class SiduriRuntime {
|
|
|
256
273
|
subsystemDiagnostics: contextRetrieval.subsystemDiagnostics,
|
|
257
274
|
knowledgeData: contextRetrieval.knowledgeData,
|
|
258
275
|
memoryData: contextRetrieval.memoryData,
|
|
276
|
+
lifeContext: contextRetrieval.lifeContext,
|
|
259
277
|
});
|
|
260
278
|
// 5. Cognition planning via BrainOrgan
|
|
261
279
|
const plan = await (0, cognition_planner_1.generateCognitionPlan)({
|
|
@@ -31,7 +31,7 @@ describe('validateCompanionConfig', () => {
|
|
|
31
31
|
properties: {
|
|
32
32
|
provider: {
|
|
33
33
|
type: 'string',
|
|
34
|
-
enum: ['
|
|
34
|
+
enum: ['sqlite', 'in-memory', 'none'],
|
|
35
35
|
},
|
|
36
36
|
maxConnections: { type: 'number' },
|
|
37
37
|
},
|
|
@@ -107,7 +107,7 @@ describe('validateCompanionConfig', () => {
|
|
|
107
107
|
name: 'Test',
|
|
108
108
|
organs: {
|
|
109
109
|
memory: {
|
|
110
|
-
provider: '
|
|
110
|
+
provider: 'sqlite',
|
|
111
111
|
maxConnections: 'ten', // should be number
|
|
112
112
|
},
|
|
113
113
|
},
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export interface SelfIdentity {
|
|
2
|
+
companionId: string;
|
|
3
|
+
name: string;
|
|
4
|
+
archetype?: string;
|
|
5
|
+
version: string;
|
|
6
|
+
updatedAt: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PersonalityTraits {
|
|
9
|
+
warmth: number;
|
|
10
|
+
formality: number;
|
|
11
|
+
sarcasm: number;
|
|
12
|
+
verbosity: number;
|
|
13
|
+
curiosity: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SelfDirective {
|
|
16
|
+
id: string;
|
|
17
|
+
companionId: string;
|
|
18
|
+
priority: number;
|
|
19
|
+
directive: string;
|
|
20
|
+
status: 'PENDING' | 'ACTIVE' | 'DISABLED' | 'SUPERSEDED' | 'REJECTED' | 'REVOKED' | 'EXPIRED';
|
|
21
|
+
category: 'behavioral' | 'guardrail' | 'relational' | string;
|
|
22
|
+
supersedesId?: string;
|
|
23
|
+
createdAt?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SelfRelationship {
|
|
26
|
+
companionId: string;
|
|
27
|
+
entityId: string;
|
|
28
|
+
entityType: 'human' | 'companion' | 'system';
|
|
29
|
+
trustScore: number;
|
|
30
|
+
familiarity: number;
|
|
31
|
+
interactionConventions: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface LifeInventoryItem {
|
|
34
|
+
id: string;
|
|
35
|
+
companionId: string;
|
|
36
|
+
domain: string;
|
|
37
|
+
entityName: string;
|
|
38
|
+
properties: Record<string, unknown>;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
}
|
|
41
|
+
export interface LifeFinanceEntry {
|
|
42
|
+
id: string;
|
|
43
|
+
companionId: string;
|
|
44
|
+
category: string;
|
|
45
|
+
amount: number;
|
|
46
|
+
currency: string;
|
|
47
|
+
timestamp: string;
|
|
48
|
+
metadata?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
export interface LifeScheduleItem {
|
|
51
|
+
id: string;
|
|
52
|
+
companionId: string;
|
|
53
|
+
title: string;
|
|
54
|
+
startTime: string;
|
|
55
|
+
endTime?: string;
|
|
56
|
+
isRecurring: boolean;
|
|
57
|
+
status: string;
|
|
58
|
+
}
|
|
59
|
+
export interface LifePreference {
|
|
60
|
+
id: string;
|
|
61
|
+
companionId: string;
|
|
62
|
+
preferenceKey: string;
|
|
63
|
+
preferenceValue: string;
|
|
64
|
+
category: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
}
|
|
67
|
+
export interface EpisodicEvent {
|
|
68
|
+
id: string;
|
|
69
|
+
companionId: string;
|
|
70
|
+
sourceType: 'chat_turn' | 'tool_result' | 'sensory';
|
|
71
|
+
occurredAt: string;
|
|
72
|
+
payload: Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
export interface MemoryClaim {
|
|
75
|
+
id: string;
|
|
76
|
+
companionId: string;
|
|
77
|
+
subject: string;
|
|
78
|
+
predicate: string;
|
|
79
|
+
value: string;
|
|
80
|
+
status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'SESSION_ONLY' | 'SUPERSEDED' | 'REVOKED' | 'EXPIRED';
|
|
81
|
+
confidence: number;
|
|
82
|
+
validFrom?: string;
|
|
83
|
+
validUntil?: string;
|
|
84
|
+
evidence?: string[];
|
|
85
|
+
assertedAt: string;
|
|
86
|
+
supersedes?: string;
|
|
87
|
+
sourceEventId?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface SiduriDatabaseOptions {
|
|
90
|
+
dbPath?: string;
|
|
91
|
+
}
|
|
92
|
+
export declare class SiduriDatabase {
|
|
93
|
+
private db;
|
|
94
|
+
constructor(options?: SiduriDatabaseOptions);
|
|
95
|
+
private initSchema;
|
|
96
|
+
close(): void;
|
|
97
|
+
getIdentity(companionId: string): SelfIdentity | undefined;
|
|
98
|
+
setIdentity(identity: SelfIdentity): void;
|
|
99
|
+
getPersonality(companionId: string): PersonalityTraits | undefined;
|
|
100
|
+
setPersonality(companionId: string, traits: PersonalityTraits): void;
|
|
101
|
+
getActiveDirectives(companionId: string): SelfDirective[];
|
|
102
|
+
commitDirective(directive: SelfDirective): void;
|
|
103
|
+
getDirective(id: string, companionId?: string): SelfDirective | undefined;
|
|
104
|
+
approveDirective(id: string, companionId?: string): void;
|
|
105
|
+
rejectDirective(id: string, companionId?: string): void;
|
|
106
|
+
revokeDirective(id: string, companionId?: string): void;
|
|
107
|
+
expireDirective(id: string, companionId?: string): void;
|
|
108
|
+
disableDirective(id: string, companionId?: string): void;
|
|
109
|
+
getRelationship(companionId: string, entityId: string): SelfRelationship | undefined;
|
|
110
|
+
upsertRelationship(rel: SelfRelationship): void;
|
|
111
|
+
getInventory(companionId: string, domain?: string): LifeInventoryItem[];
|
|
112
|
+
upsertInventoryItem(item: LifeInventoryItem): void;
|
|
113
|
+
getFinanceEntries(companionId: string, limit?: number): LifeFinanceEntry[];
|
|
114
|
+
addFinanceEntry(entry: LifeFinanceEntry): void;
|
|
115
|
+
getSchedule(companionId: string): LifeScheduleItem[];
|
|
116
|
+
upsertScheduleItem(item: LifeScheduleItem): void;
|
|
117
|
+
getPreferences(companionId: string): LifePreference[];
|
|
118
|
+
upsertPreference(pref: LifePreference): void;
|
|
119
|
+
recordEvent(event: EpisodicEvent): void;
|
|
120
|
+
getRecentEvents(companionId: string, limit?: number): EpisodicEvent[];
|
|
121
|
+
getEvent(id: string): EpisodicEvent | undefined;
|
|
122
|
+
proposeClaim(claim: Omit<MemoryClaim, 'status' | 'confidence' | 'assertedAt'> & {
|
|
123
|
+
confidence?: number;
|
|
124
|
+
assertedAt?: string;
|
|
125
|
+
supersedes?: string;
|
|
126
|
+
sourceEventId?: string;
|
|
127
|
+
}): MemoryClaim;
|
|
128
|
+
approveClaim(id: string, companionId?: string): void;
|
|
129
|
+
rejectClaim(id: string, companionId?: string): void;
|
|
130
|
+
revokeClaim(id: string, companionId?: string): void;
|
|
131
|
+
expireClaim(id: string, companionId?: string): void;
|
|
132
|
+
markClaimSessionOnly(id: string, companionId?: string): void;
|
|
133
|
+
searchClaims(companionId: string, query: string, limit?: number): MemoryClaim[];
|
|
134
|
+
getPendingClaims(companionId: string, limit?: number): MemoryClaim[];
|
|
135
|
+
getApprovedClaims(companionId: string, limit?: number): MemoryClaim[];
|
|
136
|
+
getClaim(id: string): MemoryClaim | undefined;
|
|
137
|
+
resetMemory(companionId: string): void;
|
|
138
|
+
}
|