@sidurijs/core 1.0.0 → 1.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/LICENSE +190 -0
- package/dist/container.d.ts +6 -4
- package/dist/container.js +1 -4
- package/dist/context-retriever.d.ts +3 -2
- package/dist/context-retriever.js +24 -3
- package/dist/conversational-teach.test.js +40 -32
- package/dist/index.d.ts +37 -27
- package/dist/index.js +1 -0
- package/dist/interaction-settler.d.ts +58 -0
- package/dist/interaction-settler.js +177 -0
- package/dist/memory-settler.d.ts +3 -47
- package/dist/memory-settler.js +17 -157
- package/dist/perception-pipeline.d.ts +5 -3
- package/dist/perception-pipeline.js +10 -7
- package/dist/response-envelope.d.ts +1 -1
- package/dist/response-envelope.js +1 -0
- package/dist/runtime-facades.test.js +12 -35
- package/dist/runtime.d.ts +16 -10
- package/dist/runtime.js +85 -107
- package/dist/session-history.d.ts +3 -3
- package/dist/session-history.js +1 -1
- package/dist/siduri-db.d.ts +8 -28
- package/dist/siduri-db.js +179 -434
- package/dist/siduri-db.test.js +113 -281
- package/package.json +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or exemplary damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 VXNUS Creative Technology Studio
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/dist/container.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BrainOrgan,
|
|
1
|
+
import { BrainOrgan, ArchiveLedger, VoiceOrgan, KnowledgeOrgan, VisionOrgan, BehaviorOrgan, BodyOrgan, HandsOrgan, EarOrgan, ObservationOrgan, MouthOrgan, SelfRepository, EKnowledgeOrgan, OrganConfig, ActionStore, ActionPolicyEngine, ResponseGatingEngine, ExperienceDispatcher, ExperienceAdapter } from './index';
|
|
2
2
|
import { SessionHistoryManager } from './session-history';
|
|
3
3
|
import { SiduriRuntime } from './runtime';
|
|
4
4
|
export interface SiduriRuntimeConfig {
|
|
5
5
|
name: string;
|
|
6
6
|
brain?: OrganConfig | Record<string, unknown>;
|
|
7
7
|
voice?: OrganConfig | Record<string, unknown>;
|
|
8
|
-
|
|
8
|
+
archive?: OrganConfig | Record<string, unknown>;
|
|
9
9
|
knowledge?: OrganConfig | Record<string, unknown>;
|
|
10
10
|
behavior?: OrganConfig | Record<string, unknown>;
|
|
11
11
|
body?: OrganConfig | Record<string, unknown>;
|
|
@@ -26,7 +26,7 @@ export interface SiduriRuntimeConfig {
|
|
|
26
26
|
}
|
|
27
27
|
export interface RuntimeOrgans {
|
|
28
28
|
brain?: BrainOrgan;
|
|
29
|
-
|
|
29
|
+
archive?: ArchiveLedger;
|
|
30
30
|
voice?: VoiceOrgan | ExperienceAdapter;
|
|
31
31
|
knowledge?: KnowledgeOrgan;
|
|
32
32
|
vision?: VisionOrgan;
|
|
@@ -40,6 +40,8 @@ export interface RuntimeOrgans {
|
|
|
40
40
|
externalKnowledge?: EKnowledgeOrgan;
|
|
41
41
|
actionStore?: ActionStore;
|
|
42
42
|
actionPolicy?: ActionPolicyEngine;
|
|
43
|
+
memory?: any;
|
|
44
|
+
[key: string]: unknown;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* CompanionContainer manages the lifecycle, discovery, wiring, and dependency injection
|
|
@@ -56,7 +58,7 @@ export declare class CompanionContainer {
|
|
|
56
58
|
private _runtime?;
|
|
57
59
|
constructor(id: string, config: SiduriRuntimeConfig, organs?: RuntimeOrgans);
|
|
58
60
|
get brain(): BrainOrgan | undefined;
|
|
59
|
-
get
|
|
61
|
+
get archive(): ArchiveLedger | undefined;
|
|
60
62
|
get voice(): ExperienceAdapter | VoiceOrgan | undefined;
|
|
61
63
|
get knowledge(): KnowledgeOrgan | undefined;
|
|
62
64
|
get vision(): VisionOrgan | undefined;
|
package/dist/container.js
CHANGED
|
@@ -47,7 +47,7 @@ class CompanionContainer {
|
|
|
47
47
|
}
|
|
48
48
|
// Direct organ accessors
|
|
49
49
|
get brain() { return this.organs.brain; }
|
|
50
|
-
get
|
|
50
|
+
get archive() { return this.organs.archive; }
|
|
51
51
|
get voice() { return this.organs.voice; }
|
|
52
52
|
get knowledge() { return this.organs.knowledge; }
|
|
53
53
|
get vision() { return this.organs.vision; }
|
|
@@ -61,9 +61,6 @@ class CompanionContainer {
|
|
|
61
61
|
get self() { return this.organs.self; }
|
|
62
62
|
get externalKnowledge() { return this.organs.externalKnowledge; }
|
|
63
63
|
async initialize() {
|
|
64
|
-
if (this.organs.memory && typeof this.organs.memory.initialize === 'function') {
|
|
65
|
-
await this.organs.memory.initialize(this.id);
|
|
66
|
-
}
|
|
67
64
|
if (this.organs.hands && typeof this.organs.hands.listTools === 'function') {
|
|
68
65
|
const tools = await this.organs.hands.listTools();
|
|
69
66
|
for (const tool of tools) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KnowledgeOrgan,
|
|
1
|
+
import { KnowledgeOrgan, KnowledgeItem, Claim, BehaviorDirective, EvidenceRecord, ResponseCitation, RequestContext, SelfRepository, LifeDatabase, ArchiveLedger, EpisodicMemoryStore, EKnowledgeOrgan } from './index';
|
|
2
2
|
export interface ContextRetrievalParams {
|
|
3
3
|
companionId: string;
|
|
4
4
|
perceivedText: string;
|
|
@@ -10,7 +10,8 @@ export interface ContextRetrievalParams {
|
|
|
10
10
|
memoryQueries?: string[];
|
|
11
11
|
isSelfIdentityRequest?: boolean;
|
|
12
12
|
knowledge?: KnowledgeOrgan | LifeDatabase;
|
|
13
|
-
|
|
13
|
+
archive?: ArchiveLedger;
|
|
14
|
+
memory?: EpisodicMemoryStore;
|
|
14
15
|
self?: SelfRepository;
|
|
15
16
|
externalKnowledge?: EKnowledgeOrgan | KnowledgeOrgan;
|
|
16
17
|
}
|
|
@@ -7,7 +7,7 @@ const intent_classifier_1 = require("./intent-classifier");
|
|
|
7
7
|
* in a single parallel pass with graceful degradation.
|
|
8
8
|
*/
|
|
9
9
|
async function retrieveRuntimeContext(params) {
|
|
10
|
-
const { companionId, perceivedText, requestContext, role, isContextObject, shouldQueryKnowledge, knowledgeQueries, memoryQueries, isSelfIdentityRequest, knowledge, memory, self, externalKnowledge, } = params;
|
|
10
|
+
const { companionId, perceivedText, requestContext, role, isContextObject, shouldQueryKnowledge, knowledgeQueries, memoryQueries, isSelfIdentityRequest, knowledge, archive, memory, self, externalKnowledge, } = params;
|
|
11
11
|
const queryOptions = isContextObject
|
|
12
12
|
? {
|
|
13
13
|
limit: 5,
|
|
@@ -59,7 +59,7 @@ async function retrieveRuntimeContext(params) {
|
|
|
59
59
|
return merged;
|
|
60
60
|
})
|
|
61
61
|
: Promise.resolve([]),
|
|
62
|
-
// Stream B:
|
|
62
|
+
// Stream B: Interaction Archive / Verified Claims (FTS5 search with fallback)
|
|
63
63
|
memory && typeof memory.searchClaims === 'function'
|
|
64
64
|
? (async () => {
|
|
65
65
|
try {
|
|
@@ -93,7 +93,28 @@ async function retrieveRuntimeContext(params) {
|
|
|
93
93
|
return [];
|
|
94
94
|
}
|
|
95
95
|
})()
|
|
96
|
-
:
|
|
96
|
+
: archive && typeof archive.searchEvents === 'function'
|
|
97
|
+
? (async () => {
|
|
98
|
+
try {
|
|
99
|
+
const events = await archive.searchEvents(companionId, memoryQueryToRun, 5);
|
|
100
|
+
return (events || []).map((evt) => ({
|
|
101
|
+
id: evt.id,
|
|
102
|
+
companionId: evt.companionId,
|
|
103
|
+
subject: evt.sourceType,
|
|
104
|
+
predicate: 'event',
|
|
105
|
+
value: typeof evt.payload === 'string' ? evt.payload : JSON.stringify(evt.payload),
|
|
106
|
+
status: 'approved',
|
|
107
|
+
provenance: 'archive_ledger',
|
|
108
|
+
claimType: 'event',
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
console.error('[SiduriRuntime] Archive search failed:', e.message);
|
|
113
|
+
subsystemDiagnostics['archive'] = `UNAVAILABLE: ${e.message}`;
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
})()
|
|
117
|
+
: Promise.resolve([]),
|
|
97
118
|
// Stream C: Active Directives from Self (or fallback Memory)
|
|
98
119
|
self && typeof self.getActiveDirectives === 'function'
|
|
99
120
|
? self.getActiveDirectives(companionId).catch((e) => {
|
|
@@ -81,18 +81,31 @@ describe('Conversational Teach Mode End-to-End Lifecycle', () => {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* Helper to build a MemoryOrgan wrapping a SiduriDatabase
|
|
84
|
+
* Helper to build a MemoryOrgan wrapping a SiduriDatabase & local claim mock
|
|
85
85
|
*/
|
|
86
86
|
function createMemoryOrgan(db) {
|
|
87
|
+
const claims = [];
|
|
87
88
|
return {
|
|
88
89
|
initialize: async () => { },
|
|
89
|
-
proposeClaim: async (claim) =>
|
|
90
|
+
proposeClaim: async (claim) => {
|
|
91
|
+
const c = { id: claim.id || `claim-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`, status: 'pending', ...claim };
|
|
92
|
+
claims.push(c);
|
|
93
|
+
return c;
|
|
94
|
+
},
|
|
90
95
|
searchClaims: async () => [],
|
|
91
|
-
getApprovedClaims: async (companionId, limit) =>
|
|
92
|
-
getClaims: async (limit) =>
|
|
93
|
-
getPendingClaims: async (limit) =>
|
|
94
|
-
approveClaim: async (id) =>
|
|
95
|
-
|
|
96
|
+
getApprovedClaims: async (companionId, limit) => claims.filter((c) => c.status === 'approved').slice(0, limit || 50),
|
|
97
|
+
getClaims: async (limit) => claims.slice(0, limit || 500),
|
|
98
|
+
getPendingClaims: async (limit) => claims.filter((c) => c.status === 'pending').slice(0, limit || 500),
|
|
99
|
+
approveClaim: async (id) => {
|
|
100
|
+
const found = claims.find((c) => c.id === id);
|
|
101
|
+
if (found)
|
|
102
|
+
found.status = 'approved';
|
|
103
|
+
},
|
|
104
|
+
rejectClaim: async (id) => {
|
|
105
|
+
const found = claims.find((c) => c.id === id);
|
|
106
|
+
if (found)
|
|
107
|
+
found.status = 'rejected';
|
|
108
|
+
},
|
|
96
109
|
getDirectives: async (companionId) => db.getActiveDirectives(companionId || 'default'),
|
|
97
110
|
proposeDirective: async (dir) => {
|
|
98
111
|
const id = `dir-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
@@ -376,7 +389,6 @@ describe('Conversational Teach Mode End-to-End Lifecycle', () => {
|
|
|
376
389
|
const mockBrain = createCognitiveMockBrain(companionId);
|
|
377
390
|
const runtime = new index_1.SiduriRuntime(companionId, { name: 'Siduri' }, {
|
|
378
391
|
brain: mockBrain,
|
|
379
|
-
memory,
|
|
380
392
|
self,
|
|
381
393
|
behavior,
|
|
382
394
|
});
|
|
@@ -426,7 +438,6 @@ describe('Conversational Teach Mode End-to-End Lifecycle', () => {
|
|
|
426
438
|
};
|
|
427
439
|
const runtime = new index_1.SiduriRuntime(companionId, { name: 'Siduri' }, {
|
|
428
440
|
brain: mockBrain,
|
|
429
|
-
memory,
|
|
430
441
|
self,
|
|
431
442
|
});
|
|
432
443
|
await runtime.initialize();
|
|
@@ -459,7 +470,6 @@ describe('Conversational Teach Mode End-to-End Lifecycle', () => {
|
|
|
459
470
|
const mockBrain = createCognitiveMockBrain(companionId);
|
|
460
471
|
const runtime = new index_1.SiduriRuntime(companionId, { name: 'Siduri' }, {
|
|
461
472
|
brain: mockBrain,
|
|
462
|
-
memory,
|
|
463
473
|
self,
|
|
464
474
|
});
|
|
465
475
|
await runtime.initialize();
|
|
@@ -841,48 +851,47 @@ describe('Conversational Teach Mode End-to-End Lifecycle', () => {
|
|
|
841
851
|
initialMode: 'teach',
|
|
842
852
|
}, {
|
|
843
853
|
self,
|
|
844
|
-
memory,
|
|
845
854
|
knowledge: mockKnowledge,
|
|
846
855
|
});
|
|
847
|
-
// 1. Propose knowledge claims
|
|
848
|
-
const entityClaim =
|
|
856
|
+
// 1. Propose knowledge claims (quarantined as PENDING)
|
|
857
|
+
const entityClaim = {
|
|
858
|
+
id: 'claim-ent-1',
|
|
849
859
|
companionId,
|
|
850
860
|
subject: 'entity:Workstation Rig',
|
|
851
861
|
predicate: 'inventory',
|
|
852
862
|
value: 'Threadripper 64-core',
|
|
853
863
|
claimType: 'life_entity',
|
|
854
864
|
evidence: { domain: 'hardware', properties: { cores: 64, ram: '256GB' } },
|
|
855
|
-
}
|
|
856
|
-
const eventClaim =
|
|
865
|
+
};
|
|
866
|
+
const eventClaim = {
|
|
867
|
+
id: 'claim-evt-1',
|
|
857
868
|
companionId,
|
|
858
869
|
subject: 'finance:expense',
|
|
859
870
|
predicate: 'expense',
|
|
860
871
|
value: '45.00',
|
|
861
872
|
claimType: 'life_event',
|
|
862
873
|
evidence: { metricValue: -45.0, stream: 'finance', category: 'dining' },
|
|
863
|
-
}
|
|
864
|
-
const taskClaim =
|
|
874
|
+
};
|
|
875
|
+
const taskClaim = {
|
|
876
|
+
id: 'claim-task-1',
|
|
865
877
|
companionId,
|
|
866
878
|
subject: 'task:Review PR',
|
|
867
879
|
predicate: 'todo',
|
|
868
880
|
value: 'Review PR #42 for Life DB',
|
|
869
881
|
claimType: 'life_task',
|
|
870
882
|
evidence: { status: 'in_progress' },
|
|
871
|
-
}
|
|
883
|
+
};
|
|
872
884
|
// Before approval, Life DB tables in sqlite are empty
|
|
873
885
|
expect(db.getEntities(companionId)).toHaveLength(0);
|
|
874
886
|
expect(db.getEvents(companionId)).toHaveLength(0);
|
|
875
887
|
expect(db.getTasks(companionId)).toHaveLength(0);
|
|
876
888
|
// 2. Truth Gate Approval
|
|
877
|
-
const resEntity = await
|
|
878
|
-
expect(resEntity
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
expect(
|
|
883
|
-
const resTask = await runtime.approveProposal(taskClaim.id, { companionId });
|
|
884
|
-
expect(resTask.success).toBe(true);
|
|
885
|
-
expect(resTask.target).toBe('knowledge');
|
|
889
|
+
const resEntity = await (0, index_1.promoteApprovedClaimToKnowledge)(entityClaim, mockKnowledge, companionId);
|
|
890
|
+
expect(resEntity).toBe(true);
|
|
891
|
+
const resEvent = await (0, index_1.promoteApprovedClaimToKnowledge)(eventClaim, mockKnowledge, companionId);
|
|
892
|
+
expect(resEvent).toBe(true);
|
|
893
|
+
const resTask = await (0, index_1.promoteApprovedClaimToKnowledge)(taskClaim, mockKnowledge, companionId);
|
|
894
|
+
expect(resTask).toBe(true);
|
|
886
895
|
// 3. Verify persistent commit to sovereign Life DB in SQLite
|
|
887
896
|
const entities = db.getEntities(companionId);
|
|
888
897
|
expect(entities).toHaveLength(1);
|
|
@@ -901,10 +910,8 @@ describe('Conversational Teach Mode End-to-End Lifecycle', () => {
|
|
|
901
910
|
it('updates companion identity name dynamically when companion naming claim or directive is approved', async () => {
|
|
902
911
|
const companionId = 'dynamic-companion';
|
|
903
912
|
const db = new index_1.SiduriDatabase({ dbPath: ':memory:' });
|
|
904
|
-
const memory = createMemoryOrgan(db);
|
|
905
913
|
const self = createSelfRepository(db);
|
|
906
914
|
const runtime = new index_1.SiduriRuntime(companionId, { name: 'Siduri' }, {
|
|
907
|
-
memory,
|
|
908
915
|
self,
|
|
909
916
|
});
|
|
910
917
|
await runtime.initialize();
|
|
@@ -912,14 +919,15 @@ describe('Conversational Teach Mode End-to-End Lifecycle', () => {
|
|
|
912
919
|
const initialIdentity = await self.getIdentity(companionId);
|
|
913
920
|
expect(initialIdentity?.name || 'Siduri').toBe('Siduri');
|
|
914
921
|
// 1. Propose and approve claim with subject "assistant" and predicate "name"
|
|
915
|
-
const nameClaim =
|
|
922
|
+
const nameClaim = {
|
|
923
|
+
id: 'claim-name-1',
|
|
916
924
|
companionId,
|
|
917
925
|
subject: 'assistant',
|
|
918
926
|
predicate: 'name',
|
|
919
927
|
value: 'Athena',
|
|
920
928
|
claimType: 'semantic',
|
|
921
|
-
}
|
|
922
|
-
await
|
|
929
|
+
};
|
|
930
|
+
await (0, index_1.promoteApprovedClaimToSelf)(nameClaim, self, companionId);
|
|
923
931
|
const identityAfterClaim = await self.getIdentity(companionId);
|
|
924
932
|
expect(identityAfterClaim?.name).toBe('Athena');
|
|
925
933
|
// 2. Propose and approve behavioral directive "Address companion as Athena Prime"
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from './intent-classifier';
|
|
|
17
17
|
export * from './context-retriever';
|
|
18
18
|
export * from './prompt-compiler';
|
|
19
19
|
export * from './cognition-planner';
|
|
20
|
+
export * from './interaction-settler';
|
|
20
21
|
export * from './memory-settler';
|
|
21
22
|
export * from './action-executor';
|
|
22
23
|
export * from './experience-emitter';
|
|
@@ -41,7 +42,7 @@ export interface CompanionConfig {
|
|
|
41
42
|
name: string;
|
|
42
43
|
brain: OrganConfig;
|
|
43
44
|
voice: OrganConfig;
|
|
44
|
-
|
|
45
|
+
archive: OrganConfig;
|
|
45
46
|
knowledge: OrganConfig;
|
|
46
47
|
behavior: OrganConfig;
|
|
47
48
|
body: OrganConfig;
|
|
@@ -172,32 +173,41 @@ export interface MemoryQueryOptions {
|
|
|
172
173
|
now?: string | Date;
|
|
173
174
|
[key: string]: unknown;
|
|
174
175
|
}
|
|
175
|
-
export interface
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
176
|
+
export interface ArchiveEvent {
|
|
177
|
+
id: string;
|
|
178
|
+
companionId: string;
|
|
179
|
+
sourceType: string;
|
|
180
|
+
occurredAt: string;
|
|
181
|
+
payload: Record<string, unknown>;
|
|
182
|
+
}
|
|
183
|
+
export interface ArchiveQueryOptions {
|
|
184
|
+
limit?: number;
|
|
185
|
+
sourceType?: string;
|
|
186
|
+
since?: string;
|
|
187
|
+
until?: string;
|
|
188
|
+
[key: string]: unknown;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Sovereign interaction archive: cold, append-only interaction audit ledger and full-text search.
|
|
192
|
+
* Replaces the overloaded 'Memory' metaphor for audit trails, past tool runs, and historical interaction logs.
|
|
193
|
+
*/
|
|
194
|
+
export interface ArchiveLedger {
|
|
195
|
+
recordEvent(event: ArchiveEvent | SourceEvent): Promise<ArchiveEvent | SourceEvent>;
|
|
196
|
+
getRecentEvents(companionId: string, limit?: number): Promise<ArchiveEvent[]>;
|
|
197
|
+
getEvent?(id: string): Promise<ArchiveEvent | undefined>;
|
|
198
|
+
searchEvents?(companionId: string, query: string, limit?: number): Promise<ArchiveEvent[]>;
|
|
199
|
+
close?(): void;
|
|
200
|
+
}
|
|
201
|
+
export type ArchiveStore = ArchiveLedger;
|
|
202
|
+
export type EpisodicLedger = ArchiveLedger;
|
|
203
|
+
/**
|
|
204
|
+
* Active dialogue continuity interface for working conversational context.
|
|
205
|
+
*/
|
|
206
|
+
export interface DialogueHistory {
|
|
207
|
+
getHistory(sessionKey?: string): Message[];
|
|
208
|
+
setHistory(sessionKey: string, history: Message[]): void;
|
|
209
|
+
append(sessionKey: string, message: Message): void;
|
|
210
|
+
clear(sessionKey?: string): void;
|
|
201
211
|
}
|
|
202
212
|
export interface AudioEvent {
|
|
203
213
|
type: 'STARTED' | 'COMPLETED' | 'FAILED';
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __exportStar(require("./intent-classifier"), exports);
|
|
|
35
35
|
__exportStar(require("./context-retriever"), exports);
|
|
36
36
|
__exportStar(require("./prompt-compiler"), exports);
|
|
37
37
|
__exportStar(require("./cognition-planner"), exports);
|
|
38
|
+
__exportStar(require("./interaction-settler"), exports);
|
|
38
39
|
__exportStar(require("./memory-settler"), exports);
|
|
39
40
|
__exportStar(require("./action-executor"), exports);
|
|
40
41
|
__exportStar(require("./experience-emitter"), exports);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ArchiveLedger, SelfRepository, Claim, BehaviorDirective, ResponsePlan, RequestContext, InteractionMode } from './index';
|
|
2
|
+
import { extractDeterministicTeaching } from './teaching';
|
|
3
|
+
export interface InteractionSettlementParams {
|
|
4
|
+
companionId: string;
|
|
5
|
+
perceivedText: string;
|
|
6
|
+
role: 'OWNER' | 'VIEWER' | 'OPERATOR';
|
|
7
|
+
requestContext: RequestContext;
|
|
8
|
+
archive?: ArchiveLedger;
|
|
9
|
+
self?: SelfRepository;
|
|
10
|
+
explicitTeaching: ReturnType<typeof extractDeterministicTeaching>;
|
|
11
|
+
plan: ResponsePlan;
|
|
12
|
+
effectiveMode?: InteractionMode;
|
|
13
|
+
/** @deprecated Legacy memory organ reference. Direct domain routing routes to self or archive directly. */
|
|
14
|
+
memory?: any;
|
|
15
|
+
}
|
|
16
|
+
export interface ProposalReceipt {
|
|
17
|
+
proposal_id: string;
|
|
18
|
+
subject: string;
|
|
19
|
+
predicate: string;
|
|
20
|
+
value: string;
|
|
21
|
+
status: string;
|
|
22
|
+
claim_type?: string;
|
|
23
|
+
content?: string;
|
|
24
|
+
}
|
|
25
|
+
export type MemoryProposalReceipt = ProposalReceipt;
|
|
26
|
+
export interface BehavioralProposalReceipt {
|
|
27
|
+
directive_id: string;
|
|
28
|
+
domain?: string;
|
|
29
|
+
knowledge_domain?: string;
|
|
30
|
+
memory_class?: string;
|
|
31
|
+
runtime_effect?: string;
|
|
32
|
+
subject?: string;
|
|
33
|
+
predicate?: string;
|
|
34
|
+
value?: string;
|
|
35
|
+
status: string;
|
|
36
|
+
behavior?: {
|
|
37
|
+
instruction: string;
|
|
38
|
+
frequency?: string;
|
|
39
|
+
preferred_positions?: string[];
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface InteractionSettlementResult {
|
|
43
|
+
createdMemoryProposals: Claim[];
|
|
44
|
+
memoryProposalReceipts: ProposalReceipt[];
|
|
45
|
+
createdBehavioralProposals?: BehaviorDirective[];
|
|
46
|
+
behavioralProposalReceipts?: BehavioralProposalReceipt[];
|
|
47
|
+
}
|
|
48
|
+
export type MemorySettlementParams = InteractionSettlementParams;
|
|
49
|
+
export type MemorySettlementResult = InteractionSettlementResult;
|
|
50
|
+
/**
|
|
51
|
+
* Persists source events to ArchiveLedger and behavioral directive proposals directly to SelfRepository.
|
|
52
|
+
* Direct Domain Routing under RFC VX-26-13: Deconstructing Memory into Sovereign Primitives.
|
|
53
|
+
*/
|
|
54
|
+
export declare function settleInteractionProposals(params: InteractionSettlementParams): Promise<InteractionSettlementResult>;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Use `settleInteractionProposals` instead. RFC VX-26-13.
|
|
57
|
+
*/
|
|
58
|
+
export declare const settleMemoryProposals: typeof settleInteractionProposals;
|