@siduri-x/core 1.0.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/architecture-boundary.test.js +4 -12
- 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 +37 -0
- 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 +7 -1
- package/dist/runtime.js +7 -0
- package/dist/siduri-db.d.ts +119 -0
- package/dist/siduri-db.js +444 -0
- package/dist/siduri-db.test.d.ts +1 -0
- package/dist/siduri-db.test.js +580 -0
- package/package.json +1 -1
|
@@ -41,16 +41,14 @@ describe('Architecture: Core & Organ Package Boundaries (Phase 2)', () => {
|
|
|
41
41
|
const corePackageJsonPath = path.resolve(__dirname, '../package.json');
|
|
42
42
|
const EXPECTED_ORGANS = [
|
|
43
43
|
{ dir: 'brain', name: '@siduri-x/brain', organType: 'brain', configKey: 'brain' },
|
|
44
|
-
{ dir: 'memory', name: '@siduri-x/memory', organType: 'memory', configKey: 'memory' },
|
|
45
|
-
{ dir: 'knowledge', name: '@siduri-x/knowledge', organType: 'knowledge', configKey: 'knowledge' },
|
|
46
|
-
{ dir: 'behavior', name: '@siduri-x/behavior', organType: 'behavior', configKey: 'behavior' },
|
|
47
44
|
{ dir: 'ear', name: '@siduri-x/ear', organType: 'ear', configKey: 'ear' },
|
|
45
|
+
{ dir: 'voice', name: '@siduri-x/voice', organType: 'voice', configKey: 'voice' },
|
|
46
|
+
{ dir: 'mouth', name: '@siduri-x/mouth', organType: 'mouth', configKey: 'mouth' },
|
|
48
47
|
{ dir: 'vision', name: '@siduri-x/vision', organType: 'vision', configKey: 'vision' },
|
|
49
48
|
{ dir: 'hands', name: '@siduri-x/hands', organType: 'hands', configKey: 'hands' },
|
|
50
49
|
{ dir: 'body', name: '@siduri-x/body', organType: 'body', configKey: 'body' },
|
|
51
|
-
{ dir: 'voice', name: '@siduri-x/voice', organType: 'voice', configKey: 'voice' },
|
|
52
50
|
{ dir: 'observation', name: '@siduri-x/observation', organType: 'observation', configKey: 'observation' },
|
|
53
|
-
{ dir: '
|
|
51
|
+
{ dir: 'eknowledge', name: '@siduri-x/eknowledge', organType: 'eknowledge', configKey: 'eknowledge' },
|
|
54
52
|
];
|
|
55
53
|
it('package.json has zero dependencies on @siduri-x organ packages', () => {
|
|
56
54
|
const pkg = JSON.parse(fs.readFileSync(corePackageJsonPath, 'utf8'));
|
|
@@ -78,7 +76,7 @@ describe('Architecture: Core & Organ Package Boundaries (Phase 2)', () => {
|
|
|
78
76
|
}
|
|
79
77
|
expect(forbiddenImports).toEqual([]);
|
|
80
78
|
});
|
|
81
|
-
it('all
|
|
79
|
+
it('all 9 peripheral organ packages have a valid organ-manifest.json', () => {
|
|
82
80
|
for (const organ of EXPECTED_ORGANS) {
|
|
83
81
|
const manifestPath = path.join(rootOrgansDir, organ.dir, 'organ-manifest.json');
|
|
84
82
|
expect(fs.existsSync(manifestPath)).toBe(true);
|
|
@@ -108,10 +106,4 @@ describe('Architecture: Core & Organ Package Boundaries (Phase 2)', () => {
|
|
|
108
106
|
}
|
|
109
107
|
}
|
|
110
108
|
});
|
|
111
|
-
it('memory organ packages SQL migrations', () => {
|
|
112
|
-
const memoryMigrationsDir = path.join(rootOrgansDir, 'memory', 'migrations');
|
|
113
|
-
expect(fs.existsSync(memoryMigrationsDir)).toBe(true);
|
|
114
|
-
const files = fs.readdirSync(memoryMigrationsDir).filter((f) => f.endsWith('.sql'));
|
|
115
|
-
expect(files.length).toBeGreaterThanOrEqual(1);
|
|
116
|
-
});
|
|
117
109
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KnowledgeOrgan, MemoryOrgan, KnowledgeItem, Claim, BehaviorDirective, EvidenceRecord, ResponseCitation, RequestContext } from './index';
|
|
1
|
+
import { KnowledgeOrgan, MemoryOrgan, KnowledgeItem, Claim, BehaviorDirective, EvidenceRecord, ResponseCitation, RequestContext, SelfRepository, LifeDatabase, EpisodicMemoryStore, EKnowledgeOrgan } from './index';
|
|
2
2
|
export interface ContextRetrievalParams {
|
|
3
3
|
companionId: string;
|
|
4
4
|
perceivedText: string;
|
|
@@ -6,8 +6,10 @@ export interface ContextRetrievalParams {
|
|
|
6
6
|
role: 'OWNER' | 'VIEWER' | 'OPERATOR';
|
|
7
7
|
isContextObject: boolean;
|
|
8
8
|
shouldQueryKnowledge: boolean;
|
|
9
|
-
knowledge?: KnowledgeOrgan;
|
|
10
|
-
memory?: MemoryOrgan;
|
|
9
|
+
knowledge?: KnowledgeOrgan | LifeDatabase;
|
|
10
|
+
memory?: MemoryOrgan | EpisodicMemoryStore;
|
|
11
|
+
self?: SelfRepository;
|
|
12
|
+
externalKnowledge?: EKnowledgeOrgan | KnowledgeOrgan;
|
|
11
13
|
}
|
|
12
14
|
export interface RetrievedContext {
|
|
13
15
|
knowledgeData: KnowledgeItem[];
|
|
@@ -16,9 +18,10 @@ export interface RetrievedContext {
|
|
|
16
18
|
subsystemDiagnostics: Record<string, string>;
|
|
17
19
|
collectedEvidence: EvidenceRecord[];
|
|
18
20
|
citations: ResponseCitation[];
|
|
21
|
+
lifeContext?: string[];
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
|
-
* Concurrently queries Knowledge
|
|
22
|
-
*
|
|
24
|
+
* Concurrently queries Self, Knowledge (Life DB), External Knowledge, and Memory
|
|
25
|
+
* in a single parallel pass with graceful degradation.
|
|
23
26
|
*/
|
|
24
27
|
export declare function retrieveRuntimeContext(params: ContextRetrievalParams): Promise<RetrievedContext>;
|
|
@@ -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';
|
|
@@ -249,3 +251,38 @@ export interface HealthProbeResult {
|
|
|
249
251
|
}
|
|
250
252
|
export type HealthProbeFn = (context: HealthProbeContext) => Promise<HealthProbeResult> | HealthProbeResult;
|
|
251
253
|
export * from './mouth-types';
|
|
254
|
+
import type { SelfIdentity, PersonalityTraits, SelfDirective, SelfRelationship, LifeInventoryItem, LifeScheduleItem, LifePreference, MemoryClaim, EpisodicEvent } from './siduri-db';
|
|
255
|
+
export interface SelfRepository {
|
|
256
|
+
getIdentity(companionId: string): Promise<SelfIdentity | undefined>;
|
|
257
|
+
getPersonality(companionId: string): Promise<PersonalityTraits>;
|
|
258
|
+
getActiveDirectives(companionId: string): Promise<SelfDirective[]>;
|
|
259
|
+
getRelationship(companionId: string, entityId: string): Promise<SelfRelationship | null>;
|
|
260
|
+
commitDirectives(companionId: string, directives: SelfDirective[]): Promise<void>;
|
|
261
|
+
updateRelationship(companionId: string, rel: SelfRelationship): Promise<void>;
|
|
262
|
+
disableDirective?(id: string): Promise<void>;
|
|
263
|
+
getActiveSelf?(companionId: string): Promise<{
|
|
264
|
+
identity?: SelfIdentity;
|
|
265
|
+
personality: PersonalityTraits;
|
|
266
|
+
directives: SelfDirective[];
|
|
267
|
+
}>;
|
|
268
|
+
}
|
|
269
|
+
export interface LifeDatabase {
|
|
270
|
+
getInventory(companionId: string, domain?: string): Promise<LifeInventoryItem[]>;
|
|
271
|
+
getFinanceSummary?(companionId: string): Promise<any>;
|
|
272
|
+
getSchedule?(companionId: string, windowStart?: Date, windowEnd?: Date): Promise<LifeScheduleItem[]>;
|
|
273
|
+
getPreferences?(companionId: string): Promise<Record<string, string> | LifePreference[]>;
|
|
274
|
+
queryContext(companionId: string, query: string): Promise<string[]>;
|
|
275
|
+
searchLifeContext?(queryText: string): Promise<string[]>;
|
|
276
|
+
}
|
|
277
|
+
export interface EpisodicMemoryStore {
|
|
278
|
+
recordEvent(companionId: string, event: any): Promise<void>;
|
|
279
|
+
searchClaims(companionId: string, query: string, limit?: number): Promise<MemoryClaim[]>;
|
|
280
|
+
proposeClaim(claim: any): Promise<MemoryClaim>;
|
|
281
|
+
approveClaim(claimId: string): Promise<void>;
|
|
282
|
+
rejectClaim?(claimId: string): Promise<void>;
|
|
283
|
+
getApprovedClaims?(companionId: string, limit?: number): Promise<MemoryClaim[]>;
|
|
284
|
+
getRecentEvents?(companionId: string, limit?: number): Promise<EpisodicEvent[]>;
|
|
285
|
+
}
|
|
286
|
+
export interface EKnowledgeOrgan {
|
|
287
|
+
search(query: string): Promise<KnowledgeItem[]>;
|
|
288
|
+
}
|
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, 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;
|
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) {
|
|
@@ -244,6 +248,8 @@ class SiduriRuntime {
|
|
|
244
248
|
shouldQueryKnowledge: intent.shouldQueryKnowledge,
|
|
245
249
|
knowledge: this.knowledge,
|
|
246
250
|
memory: this.memory,
|
|
251
|
+
self: this.self,
|
|
252
|
+
externalKnowledge: this.externalKnowledge,
|
|
247
253
|
});
|
|
248
254
|
// 4. Neutral system prompt and contextual prompt compilation
|
|
249
255
|
const prompts = await (0, prompt_compiler_1.compilePrompts)({
|
|
@@ -256,6 +262,7 @@ class SiduriRuntime {
|
|
|
256
262
|
subsystemDiagnostics: contextRetrieval.subsystemDiagnostics,
|
|
257
263
|
knowledgeData: contextRetrieval.knowledgeData,
|
|
258
264
|
memoryData: contextRetrieval.memoryData,
|
|
265
|
+
lifeContext: contextRetrieval.lifeContext,
|
|
259
266
|
});
|
|
260
267
|
// 5. Cognition planning via BrainOrgan
|
|
261
268
|
const plan = await (0, cognition_planner_1.generateCognitionPlan)({
|
|
@@ -0,0 +1,119 @@
|
|
|
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: 'ACTIVE' | 'DISABLED' | 'SUPERSEDED';
|
|
21
|
+
category: 'behavioral' | 'guardrail' | 'relational';
|
|
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';
|
|
81
|
+
confidence: number;
|
|
82
|
+
validFrom?: string;
|
|
83
|
+
validUntil?: string;
|
|
84
|
+
evidence?: string[];
|
|
85
|
+
assertedAt: string;
|
|
86
|
+
}
|
|
87
|
+
export interface SiduriDatabaseOptions {
|
|
88
|
+
dbPath?: string;
|
|
89
|
+
}
|
|
90
|
+
export declare class SiduriDatabase {
|
|
91
|
+
private db;
|
|
92
|
+
constructor(options?: SiduriDatabaseOptions);
|
|
93
|
+
private initSchema;
|
|
94
|
+
close(): void;
|
|
95
|
+
getIdentity(companionId: string): SelfIdentity | undefined;
|
|
96
|
+
setIdentity(identity: SelfIdentity): void;
|
|
97
|
+
getPersonality(companionId: string): PersonalityTraits | undefined;
|
|
98
|
+
setPersonality(companionId: string, traits: PersonalityTraits): void;
|
|
99
|
+
getActiveDirectives(companionId: string): SelfDirective[];
|
|
100
|
+
commitDirective(directive: SelfDirective): void;
|
|
101
|
+
disableDirective(id: string): void;
|
|
102
|
+
getRelationship(companionId: string, entityId: string): SelfRelationship | undefined;
|
|
103
|
+
upsertRelationship(rel: SelfRelationship): void;
|
|
104
|
+
getInventory(companionId: string, domain?: string): LifeInventoryItem[];
|
|
105
|
+
upsertInventoryItem(item: LifeInventoryItem): void;
|
|
106
|
+
getFinanceEntries(companionId: string, limit?: number): LifeFinanceEntry[];
|
|
107
|
+
addFinanceEntry(entry: LifeFinanceEntry): void;
|
|
108
|
+
getSchedule(companionId: string): LifeScheduleItem[];
|
|
109
|
+
upsertScheduleItem(item: LifeScheduleItem): void;
|
|
110
|
+
getPreferences(companionId: string): LifePreference[];
|
|
111
|
+
upsertPreference(pref: LifePreference): void;
|
|
112
|
+
recordEvent(event: EpisodicEvent): void;
|
|
113
|
+
getRecentEvents(companionId: string, limit?: number): EpisodicEvent[];
|
|
114
|
+
proposeClaim(claim: Omit<MemoryClaim, 'status'>): MemoryClaim;
|
|
115
|
+
approveClaim(id: string): void;
|
|
116
|
+
rejectClaim(id: string): void;
|
|
117
|
+
searchClaims(companionId: string, query: string, limit?: number): MemoryClaim[];
|
|
118
|
+
getApprovedClaims(companionId: string, limit?: number): MemoryClaim[];
|
|
119
|
+
}
|