@aletheia-labs/episodic 0.1.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/LICENSE +176 -0
- package/README.md +92 -0
- package/dist/episodic-timeline.d.ts +202 -0
- package/dist/episodic-timeline.d.ts.map +1 -0
- package/dist/episodic-timeline.js +505 -0
- package/dist/episodic-timeline.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
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 consequential 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
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @aletheia-labs/episodic
|
|
2
|
+
|
|
3
|
+
Subjective time and episodic continuity projections for Aletheia.
|
|
4
|
+
|
|
5
|
+
> **Status**: `0.1.0` experimental public baseline. Episodic timeline projections are live; they read from existing event and memory stores and do not add authority by themselves.
|
|
6
|
+
|
|
7
|
+
## Quickstart
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @aletheia-labs/core @aletheia-labs/store-sqlite @aletheia-labs/episodic
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { AgentIdSchema, staticVisibilityPolicy } from '@aletheia-labs/core';
|
|
15
|
+
import { EpisodicTimeline } from '@aletheia-labs/episodic';
|
|
16
|
+
import { openSqliteStores } from '@aletheia-labs/store-sqlite';
|
|
17
|
+
|
|
18
|
+
const stores = openSqliteStores('./aletheia.sqlite');
|
|
19
|
+
const timeline = new EpisodicTimeline({
|
|
20
|
+
eventLedger: stores.eventLedger,
|
|
21
|
+
memoryStore: stores.memoryStore,
|
|
22
|
+
visibilityPolicy: staticVisibilityPolicy([{ kind: 'private:user' }]),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const catalog = await timeline.listEpisodes({
|
|
26
|
+
agentId: AgentIdSchema.parse('agent-1'),
|
|
27
|
+
scope: { kind: 'project', projectId: 'demo' },
|
|
28
|
+
kind: 'conversation',
|
|
29
|
+
limit: 10,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
console.log(catalog.decision.outcome, catalog.episodes.length);
|
|
33
|
+
stores.close();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The timeline only projects what the caller can already see through visibility and scope filtering.
|
|
37
|
+
|
|
38
|
+
## What this package does
|
|
39
|
+
|
|
40
|
+
- Extracts explicit episodic anchors from event payloads.
|
|
41
|
+
- Lists visible episodes by conversation, task, decision context, or session.
|
|
42
|
+
- Finds memories formed during a visible conversation, task, session, or decision context.
|
|
43
|
+
- Reconstructs belief snapshots at a historical instant from visible atoms plus audited status history.
|
|
44
|
+
- Compares visible belief snapshots at two episode boundaries to show added, removed, persisted, and status-changed beliefs.
|
|
45
|
+
- Exposes a permission-guarded timeline for one visible memory's audited status history.
|
|
46
|
+
- Builds a self-state snapshot so a restarted agent can recover what it currently believes, doubts, distrusts, or must route to a human.
|
|
47
|
+
|
|
48
|
+
## Non-goals
|
|
49
|
+
|
|
50
|
+
- No semantic search, vector ranking, or fuzzy topic inference.
|
|
51
|
+
- No new permission model. Host-provided visibility is still the boundary.
|
|
52
|
+
- No action authorization. Episodic projections are audit context, not permission tokens.
|
|
53
|
+
|
|
54
|
+
## Event payload convention
|
|
55
|
+
|
|
56
|
+
Events can opt into subjective time by carrying an `episodic` object:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"episodic": {
|
|
61
|
+
"episodeId": "conversation-2026-05-17-a",
|
|
62
|
+
"kind": "conversation",
|
|
63
|
+
"sessionId": "session-a",
|
|
64
|
+
"conversationId": "conversation-a"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Supported `kind` values are `conversation`, `task`, `decision_context`, and `session`.
|
|
70
|
+
|
|
71
|
+
## Stability
|
|
72
|
+
|
|
73
|
+
Public surface for the initial library cycle:
|
|
74
|
+
|
|
75
|
+
- `EpisodicTimeline`
|
|
76
|
+
- episode catalog/projection/comparison types
|
|
77
|
+
- belief snapshot and self-state snapshot types
|
|
78
|
+
- memory timeline types
|
|
79
|
+
- explicit `EpisodeAnchor` payload convention
|
|
80
|
+
|
|
81
|
+
Everything else is projection plumbing and may change during the `0.x` line. Episodic outputs are audit context, not permission tokens; callers must still route actions through `tryAct()`.
|
|
82
|
+
|
|
83
|
+
## Development
|
|
84
|
+
|
|
85
|
+
From the repo root:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pnpm install
|
|
89
|
+
pnpm -F @aletheia-labs/episodic typecheck
|
|
90
|
+
pnpm -F @aletheia-labs/episodic test
|
|
91
|
+
pnpm -F @aletheia-labs/episodic build
|
|
92
|
+
```
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { type AgentId, type Clock, type Decision, type Event, type EventId, type EventLedger, type IsoTimestamp, type MemoryAtom, type MemoryId, type MemoryStatus, type MemoryStore, type Scope, type StatusTransitionReason, type VisibilityPolicy } from '@aletheia-labs/core';
|
|
2
|
+
export type EpisodeKind = 'conversation' | 'task' | 'decision_context' | 'session';
|
|
3
|
+
export interface EpisodeAnchor {
|
|
4
|
+
readonly episodeId: string;
|
|
5
|
+
readonly kind: EpisodeKind;
|
|
6
|
+
readonly sessionId?: string;
|
|
7
|
+
readonly conversationId?: string;
|
|
8
|
+
readonly taskId?: string;
|
|
9
|
+
readonly decisionContextId?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface EpisodeEvent {
|
|
12
|
+
readonly event: Event;
|
|
13
|
+
readonly anchor: EpisodeAnchor;
|
|
14
|
+
}
|
|
15
|
+
export interface EpisodeSummary {
|
|
16
|
+
readonly episodeId: string;
|
|
17
|
+
readonly kind: EpisodeKind;
|
|
18
|
+
readonly firstOccurredAt: IsoTimestamp;
|
|
19
|
+
readonly lastOccurredAt: IsoTimestamp;
|
|
20
|
+
readonly eventIds: readonly EventId[];
|
|
21
|
+
readonly memoryIds: readonly MemoryId[];
|
|
22
|
+
}
|
|
23
|
+
export interface EpisodeCatalog {
|
|
24
|
+
readonly decision: Decision;
|
|
25
|
+
readonly episodes: readonly EpisodeSummary[];
|
|
26
|
+
readonly events: readonly EpisodeEvent[];
|
|
27
|
+
}
|
|
28
|
+
export interface MemoryStatusAt {
|
|
29
|
+
readonly memoryId: MemoryId;
|
|
30
|
+
readonly status: MemoryStatus;
|
|
31
|
+
readonly at: IsoTimestamp;
|
|
32
|
+
}
|
|
33
|
+
export interface MemoryTimelineEntry {
|
|
34
|
+
readonly at: IsoTimestamp;
|
|
35
|
+
readonly fromStatus: MemoryStatus | null;
|
|
36
|
+
readonly toStatus: MemoryStatus;
|
|
37
|
+
readonly reason: StatusTransitionReason;
|
|
38
|
+
}
|
|
39
|
+
export interface MemoryTimeline {
|
|
40
|
+
readonly decision: Decision;
|
|
41
|
+
readonly atom: MemoryAtom | null;
|
|
42
|
+
readonly history: readonly MemoryTimelineEntry[];
|
|
43
|
+
}
|
|
44
|
+
export interface EpisodeProjection {
|
|
45
|
+
readonly decision: Decision;
|
|
46
|
+
readonly episode: EpisodeSummary | null;
|
|
47
|
+
readonly events: readonly EpisodeEvent[];
|
|
48
|
+
readonly atoms: readonly MemoryAtom[];
|
|
49
|
+
readonly statusesAt: readonly MemoryStatusAt[];
|
|
50
|
+
}
|
|
51
|
+
export interface BeliefSnapshot {
|
|
52
|
+
readonly decision: Decision;
|
|
53
|
+
readonly at: IsoTimestamp;
|
|
54
|
+
readonly atoms: readonly MemoryAtom[];
|
|
55
|
+
readonly statusesAt: readonly MemoryStatusAt[];
|
|
56
|
+
}
|
|
57
|
+
export interface EpisodeComparison {
|
|
58
|
+
readonly decision: Decision;
|
|
59
|
+
readonly fromEpisode: EpisodeSummary | null;
|
|
60
|
+
readonly toEpisode: EpisodeSummary | null;
|
|
61
|
+
readonly addedMemoryIds: readonly MemoryId[];
|
|
62
|
+
readonly removedMemoryIds: readonly MemoryId[];
|
|
63
|
+
readonly persistedMemoryIds: readonly MemoryId[];
|
|
64
|
+
readonly statusChanged: readonly {
|
|
65
|
+
readonly memoryId: MemoryId;
|
|
66
|
+
readonly fromStatus: MemoryStatus;
|
|
67
|
+
readonly toStatus: MemoryStatus;
|
|
68
|
+
}[];
|
|
69
|
+
}
|
|
70
|
+
export interface SelfStateSnapshot {
|
|
71
|
+
readonly decision: Decision;
|
|
72
|
+
readonly at: IsoTimestamp;
|
|
73
|
+
readonly beliefs: readonly MemoryAtom[];
|
|
74
|
+
readonly uncertain: readonly MemoryAtom[];
|
|
75
|
+
readonly distrusted: readonly MemoryAtom[];
|
|
76
|
+
readonly humanRequired: readonly MemoryAtom[];
|
|
77
|
+
readonly statusHistory: readonly {
|
|
78
|
+
readonly memoryId: MemoryId;
|
|
79
|
+
readonly status: MemoryStatus;
|
|
80
|
+
readonly at: IsoTimestamp;
|
|
81
|
+
}[];
|
|
82
|
+
}
|
|
83
|
+
export interface EpisodicTimelineOptions {
|
|
84
|
+
readonly eventLedger: EventLedger;
|
|
85
|
+
readonly memoryStore: MemoryStore;
|
|
86
|
+
readonly visibilityPolicy?: VisibilityPolicy;
|
|
87
|
+
readonly clock?: Clock;
|
|
88
|
+
}
|
|
89
|
+
export interface EpisodicQueryBase {
|
|
90
|
+
readonly agentId: AgentId;
|
|
91
|
+
readonly scope: Scope;
|
|
92
|
+
}
|
|
93
|
+
export interface EpisodeQuery extends EpisodicQueryBase {
|
|
94
|
+
readonly episodeId: string;
|
|
95
|
+
readonly statusesAt?: readonly MemoryStatus[];
|
|
96
|
+
readonly asOf?: IsoTimestamp;
|
|
97
|
+
}
|
|
98
|
+
export interface EpisodeCatalogQuery extends EpisodicQueryBase {
|
|
99
|
+
readonly kind?: EpisodeKind;
|
|
100
|
+
readonly since?: IsoTimestamp;
|
|
101
|
+
readonly until?: IsoTimestamp;
|
|
102
|
+
readonly limit?: number;
|
|
103
|
+
}
|
|
104
|
+
export interface BeliefsAtQuery extends EpisodicQueryBase {
|
|
105
|
+
readonly asOf: IsoTimestamp;
|
|
106
|
+
readonly statusesAt?: readonly MemoryStatus[];
|
|
107
|
+
readonly contentIncludes?: string;
|
|
108
|
+
readonly limit?: number;
|
|
109
|
+
}
|
|
110
|
+
export interface CompareEpisodesQuery extends EpisodicQueryBase {
|
|
111
|
+
readonly fromEpisodeId: string;
|
|
112
|
+
readonly toEpisodeId: string;
|
|
113
|
+
readonly statusesAt?: readonly MemoryStatus[];
|
|
114
|
+
}
|
|
115
|
+
export interface SelfStateQuery extends EpisodicQueryBase {
|
|
116
|
+
readonly at?: IsoTimestamp;
|
|
117
|
+
}
|
|
118
|
+
export interface MemoryTimelineQuery extends EpisodicQueryBase {
|
|
119
|
+
readonly memoryId: MemoryId;
|
|
120
|
+
readonly until?: IsoTimestamp;
|
|
121
|
+
}
|
|
122
|
+
export declare class EpisodicTimeline {
|
|
123
|
+
private readonly options;
|
|
124
|
+
private readonly visibilityPolicy;
|
|
125
|
+
private readonly clock;
|
|
126
|
+
/**
|
|
127
|
+
* Create subjective-time projections over existing event and memory stores.
|
|
128
|
+
*
|
|
129
|
+
* @remarks
|
|
130
|
+
* This component is read-only. It does not create memory, authorize actions,
|
|
131
|
+
* or infer permission from episode membership.
|
|
132
|
+
*/
|
|
133
|
+
constructor(options: EpisodicTimelineOptions);
|
|
134
|
+
/**
|
|
135
|
+
* List visible explicit episodes in a scope.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* Use this to populate session/conversation/task catalogs. The implementation
|
|
139
|
+
* queries permitted events first, extracts only explicit `payload.episodic`
|
|
140
|
+
* anchors, groups them by episode, and fails closed when none are visible.
|
|
141
|
+
*/
|
|
142
|
+
listEpisodes(query: EpisodeCatalogQuery): Promise<EpisodeCatalog>;
|
|
143
|
+
/**
|
|
144
|
+
* Project memories formed from the source events of one episode.
|
|
145
|
+
*
|
|
146
|
+
* @remarks
|
|
147
|
+
* The method first verifies the episode events are visible and in scope, then
|
|
148
|
+
* reconstructs memory status at the requested episode instant. It returns
|
|
149
|
+
* audit context only; callers still need `tryAct()` before acting.
|
|
150
|
+
*/
|
|
151
|
+
episodeMemories(query: EpisodeQuery): Promise<EpisodeProjection>;
|
|
152
|
+
/**
|
|
153
|
+
* Reconstruct the caller-visible belief snapshot at a historical instant.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* Status is read from `MemoryStore.statusHistory()` rather than trusting the
|
|
157
|
+
* atom's current status, so reopened stores can answer "what was believed
|
|
158
|
+
* then" even after later decay or reconsolidation.
|
|
159
|
+
*/
|
|
160
|
+
beliefsAt(query: BeliefsAtQuery): Promise<BeliefSnapshot>;
|
|
161
|
+
/**
|
|
162
|
+
* Compare visible belief snapshots at two episode boundaries.
|
|
163
|
+
*
|
|
164
|
+
* @remarks
|
|
165
|
+
* This compares the agent's visible belief state at each boundary, not only
|
|
166
|
+
* atoms born inside those episodes. It reports added, removed, persisted, and
|
|
167
|
+
* status-changed memory IDs.
|
|
168
|
+
*/
|
|
169
|
+
compareEpisodes(query: CompareEpisodesQuery): Promise<EpisodeComparison>;
|
|
170
|
+
/**
|
|
171
|
+
* Build a restart-oriented self-state snapshot.
|
|
172
|
+
*
|
|
173
|
+
* @remarks
|
|
174
|
+
* Use this when a host wants to rehydrate an agent's current memory posture:
|
|
175
|
+
* beliefs, uncertain candidates, distrusted/deprecated atoms, and
|
|
176
|
+
* human-required material remain separate categories.
|
|
177
|
+
*/
|
|
178
|
+
selfState(query: SelfStateQuery): Promise<SelfStateSnapshot>;
|
|
179
|
+
/**
|
|
180
|
+
* Return the permission-guarded status timeline for one memory.
|
|
181
|
+
*
|
|
182
|
+
* @remarks
|
|
183
|
+
* The atom must be visible and exactly in scope before status history is
|
|
184
|
+
* exposed. This prevents timeline lookups from leaking hidden memory IDs.
|
|
185
|
+
*/
|
|
186
|
+
memoryTimeline(query: MemoryTimelineQuery): Promise<MemoryTimeline>;
|
|
187
|
+
private permittedFor;
|
|
188
|
+
private loadEpisodeEvents;
|
|
189
|
+
private loadAnchoredEvents;
|
|
190
|
+
private loadSnapshot;
|
|
191
|
+
private statusAt;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Parse an explicit episodic anchor from an event payload.
|
|
195
|
+
*
|
|
196
|
+
* @remarks
|
|
197
|
+
* This helper is intentionally conservative: malformed or missing
|
|
198
|
+
* `payload.episodic` objects return `null` instead of being inferred from
|
|
199
|
+
* prose, timestamps, or event kind.
|
|
200
|
+
*/
|
|
201
|
+
export declare function episodeAnchorFromEvent(event: Event): EpisodeAnchor | null;
|
|
202
|
+
//# sourceMappingURL=episodic-timeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"episodic-timeline.d.ts","sourceRoot":"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|
+
'deprecated',
|
|
7
|
+
'rejected',
|
|
8
|
+
'sealed',
|
|
9
|
+
'human_required',
|
|
10
|
+
];
|
|
11
|
+
const BELIEF_STATUSES = ['verified', 'trusted'];
|
|
12
|
+
const SYSTEM_CLOCK = {
|
|
13
|
+
now: () => new Date().toISOString(),
|
|
14
|
+
};
|
|
15
|
+
export class EpisodicTimeline {
|
|
16
|
+
options;
|
|
17
|
+
visibilityPolicy;
|
|
18
|
+
clock;
|
|
19
|
+
/**
|
|
20
|
+
* Create subjective-time projections over existing event and memory stores.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* This component is read-only. It does not create memory, authorize actions,
|
|
24
|
+
* or infer permission from episode membership.
|
|
25
|
+
*/
|
|
26
|
+
constructor(options) {
|
|
27
|
+
this.options = options;
|
|
28
|
+
this.visibilityPolicy = options.visibilityPolicy ?? DENY_ALL_VISIBILITY_POLICY;
|
|
29
|
+
this.clock = options.clock ?? SYSTEM_CLOCK;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* List visible explicit episodes in a scope.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Use this to populate session/conversation/task catalogs. The implementation
|
|
36
|
+
* queries permitted events first, extracts only explicit `payload.episodic`
|
|
37
|
+
* anchors, groups them by episode, and fails closed when none are visible.
|
|
38
|
+
*/
|
|
39
|
+
async listEpisodes(query) {
|
|
40
|
+
const emittedAt = this.clock.now();
|
|
41
|
+
const permitted = this.permittedFor(query.agentId);
|
|
42
|
+
if (permitted.length === 0) {
|
|
43
|
+
return emptyCatalog(failClosed('visibility_denied', 'caller has no permitted visibility planes', emittedAt));
|
|
44
|
+
}
|
|
45
|
+
const events = await this.loadAnchoredEvents(query, permitted);
|
|
46
|
+
const matchingEvents = query.kind !== undefined
|
|
47
|
+
? events.filter((event) => event.anchor.kind === query.kind)
|
|
48
|
+
: events;
|
|
49
|
+
const episodes = summarizeEpisodes(matchingEvents);
|
|
50
|
+
const limitedEpisodes = query.limit !== undefined ? episodes.slice(0, query.limit) : episodes;
|
|
51
|
+
const limitedEpisodeIds = new Set(limitedEpisodes.map((episode) => episode.episodeId));
|
|
52
|
+
const limitedEvents = matchingEvents.filter((event) => limitedEpisodeIds.has(event.anchor.episodeId));
|
|
53
|
+
if (limitedEpisodes.length === 0) {
|
|
54
|
+
return emptyCatalog(failClosed('tuple_incomplete', 'episodeAnchors', emittedAt));
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
decision: decision('allow_local_shadow', [{ kind: 'all_checks_passed', citedMemoryIds: [] }], [], [], emittedAt),
|
|
58
|
+
episodes: limitedEpisodes,
|
|
59
|
+
events: limitedEvents,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Project memories formed from the source events of one episode.
|
|
64
|
+
*
|
|
65
|
+
* @remarks
|
|
66
|
+
* The method first verifies the episode events are visible and in scope, then
|
|
67
|
+
* reconstructs memory status at the requested episode instant. It returns
|
|
68
|
+
* audit context only; callers still need `tryAct()` before acting.
|
|
69
|
+
*/
|
|
70
|
+
async episodeMemories(query) {
|
|
71
|
+
const emittedAt = this.clock.now();
|
|
72
|
+
const permitted = this.permittedFor(query.agentId);
|
|
73
|
+
if (permitted.length === 0) {
|
|
74
|
+
return emptyEpisodeProjection(failClosed('visibility_denied', 'caller has no permitted visibility planes', emittedAt));
|
|
75
|
+
}
|
|
76
|
+
const events = await this.loadEpisodeEvents(query, permitted);
|
|
77
|
+
if (events.length === 0) {
|
|
78
|
+
return emptyEpisodeProjection(failClosed('tuple_incomplete', `episodeEvents:${query.episodeId}`, emittedAt));
|
|
79
|
+
}
|
|
80
|
+
const asOf = query.asOf ?? maxIso(events.map((event) => event.event.occurredAt));
|
|
81
|
+
const snapshot = await this.loadSnapshot({
|
|
82
|
+
agentId: query.agentId,
|
|
83
|
+
scope: query.scope,
|
|
84
|
+
asOf,
|
|
85
|
+
statusesAt: query.statusesAt ?? ALL_STATUSES,
|
|
86
|
+
}, permitted);
|
|
87
|
+
const eventIds = new Set(events.map((event) => event.event.eventId));
|
|
88
|
+
const atoms = snapshot.atoms.filter((atom) => atom.sourceEventIds.some((eventId) => eventIds.has(eventId)));
|
|
89
|
+
const statusesAt = snapshot.statusesAt.filter((status) => atoms.some((atom) => atom.memoryId === status.memoryId));
|
|
90
|
+
if (atoms.length === 0) {
|
|
91
|
+
return {
|
|
92
|
+
decision: failClosed('tuple_incomplete', `episodeMemoryAtoms:${query.episodeId}`, emittedAt),
|
|
93
|
+
episode: summarizeEpisode(query.episodeId, events, []),
|
|
94
|
+
events,
|
|
95
|
+
atoms: [],
|
|
96
|
+
statusesAt: [],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
decision: decision('allow_local_shadow', [{ kind: 'all_checks_passed', citedMemoryIds: atoms.map((atom) => atom.memoryId) }], atoms.map((atom) => atom.memoryId), [], emittedAt),
|
|
101
|
+
episode: summarizeEpisode(query.episodeId, events, atoms),
|
|
102
|
+
events,
|
|
103
|
+
atoms,
|
|
104
|
+
statusesAt,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Reconstruct the caller-visible belief snapshot at a historical instant.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* Status is read from `MemoryStore.statusHistory()` rather than trusting the
|
|
112
|
+
* atom's current status, so reopened stores can answer "what was believed
|
|
113
|
+
* then" even after later decay or reconsolidation.
|
|
114
|
+
*/
|
|
115
|
+
async beliefsAt(query) {
|
|
116
|
+
const emittedAt = this.clock.now();
|
|
117
|
+
const permitted = this.permittedFor(query.agentId);
|
|
118
|
+
if (permitted.length === 0) {
|
|
119
|
+
return emptyBeliefSnapshot(query.asOf, failClosed('visibility_denied', 'caller has no permitted visibility planes', emittedAt));
|
|
120
|
+
}
|
|
121
|
+
const snapshot = await this.loadSnapshot(query, permitted);
|
|
122
|
+
if (snapshot.atoms.length === 0) {
|
|
123
|
+
return emptyBeliefSnapshot(query.asOf, failClosed('tuple_incomplete', 'memoryAtoms', emittedAt));
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
decision: decision('allow_local_shadow', [
|
|
127
|
+
{
|
|
128
|
+
kind: 'all_checks_passed',
|
|
129
|
+
citedMemoryIds: snapshot.atoms.map((atom) => atom.memoryId),
|
|
130
|
+
},
|
|
131
|
+
], snapshot.atoms.map((atom) => atom.memoryId), [], emittedAt),
|
|
132
|
+
at: query.asOf,
|
|
133
|
+
atoms: snapshot.atoms,
|
|
134
|
+
statusesAt: snapshot.statusesAt,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Compare visible belief snapshots at two episode boundaries.
|
|
139
|
+
*
|
|
140
|
+
* @remarks
|
|
141
|
+
* This compares the agent's visible belief state at each boundary, not only
|
|
142
|
+
* atoms born inside those episodes. It reports added, removed, persisted, and
|
|
143
|
+
* status-changed memory IDs.
|
|
144
|
+
*/
|
|
145
|
+
async compareEpisodes(query) {
|
|
146
|
+
const emittedAt = this.clock.now();
|
|
147
|
+
const permitted = this.permittedFor(query.agentId);
|
|
148
|
+
if (permitted.length === 0) {
|
|
149
|
+
return emptyComparison(failClosed('visibility_denied', 'caller has no permitted visibility planes', emittedAt));
|
|
150
|
+
}
|
|
151
|
+
const fromEvents = await this.loadEpisodeEvents({ agentId: query.agentId, scope: query.scope, episodeId: query.fromEpisodeId }, permitted);
|
|
152
|
+
const toEvents = await this.loadEpisodeEvents({ agentId: query.agentId, scope: query.scope, episodeId: query.toEpisodeId }, permitted);
|
|
153
|
+
if (fromEvents.length === 0 || toEvents.length === 0) {
|
|
154
|
+
return emptyComparison(failClosed('tuple_incomplete', fromEvents.length === 0
|
|
155
|
+
? `episodeEvents:${query.fromEpisodeId}`
|
|
156
|
+
: `episodeEvents:${query.toEpisodeId}`, emittedAt));
|
|
157
|
+
}
|
|
158
|
+
const fromAt = maxIso(fromEvents.map((event) => event.event.occurredAt));
|
|
159
|
+
const toAt = maxIso(toEvents.map((event) => event.event.occurredAt));
|
|
160
|
+
const statusesAt = query.statusesAt ?? BELIEF_STATUSES;
|
|
161
|
+
const fromSnapshot = await this.loadSnapshot({ agentId: query.agentId, scope: query.scope, asOf: fromAt, statusesAt }, permitted);
|
|
162
|
+
const toSnapshot = await this.loadSnapshot({ agentId: query.agentId, scope: query.scope, asOf: toAt, statusesAt }, permitted);
|
|
163
|
+
const fromById = new Map(fromSnapshot.statusesAt.map((status) => [status.memoryId, status]));
|
|
164
|
+
const toById = new Map(toSnapshot.statusesAt.map((status) => [status.memoryId, status]));
|
|
165
|
+
const fromIds = new Set(fromById.keys());
|
|
166
|
+
const toIds = new Set(toById.keys());
|
|
167
|
+
const addedMemoryIds = [...toIds].filter((memoryId) => !fromIds.has(memoryId));
|
|
168
|
+
const removedMemoryIds = [...fromIds].filter((memoryId) => !toIds.has(memoryId));
|
|
169
|
+
const persistedMemoryIds = [...toIds].filter((memoryId) => fromIds.has(memoryId));
|
|
170
|
+
const statusChanged = persistedMemoryIds.flatMap((memoryId) => {
|
|
171
|
+
const fromStatus = fromById.get(memoryId)?.status;
|
|
172
|
+
const toStatus = toById.get(memoryId)?.status;
|
|
173
|
+
if (fromStatus === undefined || toStatus === undefined || fromStatus === toStatus) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
return [{ memoryId, fromStatus, toStatus }];
|
|
177
|
+
});
|
|
178
|
+
const relatedMemoryIds = uniqueMemoryIds([
|
|
179
|
+
...addedMemoryIds,
|
|
180
|
+
...removedMemoryIds,
|
|
181
|
+
...persistedMemoryIds,
|
|
182
|
+
]);
|
|
183
|
+
return {
|
|
184
|
+
decision: decision('allow_local_shadow', [{ kind: 'all_checks_passed', citedMemoryIds: [...relatedMemoryIds] }], relatedMemoryIds, [], emittedAt),
|
|
185
|
+
fromEpisode: summarizeEpisode(query.fromEpisodeId, fromEvents, fromSnapshot.atoms),
|
|
186
|
+
toEpisode: summarizeEpisode(query.toEpisodeId, toEvents, toSnapshot.atoms),
|
|
187
|
+
addedMemoryIds,
|
|
188
|
+
removedMemoryIds,
|
|
189
|
+
persistedMemoryIds,
|
|
190
|
+
statusChanged,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Build a restart-oriented self-state snapshot.
|
|
195
|
+
*
|
|
196
|
+
* @remarks
|
|
197
|
+
* Use this when a host wants to rehydrate an agent's current memory posture:
|
|
198
|
+
* beliefs, uncertain candidates, distrusted/deprecated atoms, and
|
|
199
|
+
* human-required material remain separate categories.
|
|
200
|
+
*/
|
|
201
|
+
async selfState(query) {
|
|
202
|
+
const at = query.at ?? this.clock.now();
|
|
203
|
+
const emittedAt = this.clock.now();
|
|
204
|
+
const permitted = this.permittedFor(query.agentId);
|
|
205
|
+
if (permitted.length === 0) {
|
|
206
|
+
return emptySelfState(at, failClosed('visibility_denied', 'caller has no permitted visibility planes', emittedAt));
|
|
207
|
+
}
|
|
208
|
+
const snapshot = await this.loadSnapshot({ agentId: query.agentId, scope: query.scope, asOf: at, statusesAt: ALL_STATUSES }, permitted);
|
|
209
|
+
if (snapshot.atoms.length === 0) {
|
|
210
|
+
return emptySelfState(at, failClosed('tuple_incomplete', 'memoryAtoms', emittedAt));
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
decision: decision('allow_local_shadow', [
|
|
214
|
+
{
|
|
215
|
+
kind: 'all_checks_passed',
|
|
216
|
+
citedMemoryIds: snapshot.atoms.map((atom) => atom.memoryId),
|
|
217
|
+
},
|
|
218
|
+
], snapshot.atoms.map((atom) => atom.memoryId), [], emittedAt),
|
|
219
|
+
at,
|
|
220
|
+
beliefs: atomsWithStatus(snapshot, ['verified', 'trusted']),
|
|
221
|
+
uncertain: atomsWithStatus(snapshot, ['candidate']),
|
|
222
|
+
distrusted: atomsWithStatus(snapshot, ['deprecated', 'rejected']),
|
|
223
|
+
humanRequired: atomsWithStatus(snapshot, ['sealed', 'human_required']),
|
|
224
|
+
statusHistory: snapshot.statusesAt,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Return the permission-guarded status timeline for one memory.
|
|
229
|
+
*
|
|
230
|
+
* @remarks
|
|
231
|
+
* The atom must be visible and exactly in scope before status history is
|
|
232
|
+
* exposed. This prevents timeline lookups from leaking hidden memory IDs.
|
|
233
|
+
*/
|
|
234
|
+
async memoryTimeline(query) {
|
|
235
|
+
const emittedAt = this.clock.now();
|
|
236
|
+
const permitted = this.permittedFor(query.agentId);
|
|
237
|
+
if (permitted.length === 0) {
|
|
238
|
+
return emptyMemoryTimeline(failClosed('visibility_denied', 'caller has no permitted visibility planes', emittedAt));
|
|
239
|
+
}
|
|
240
|
+
const atom = await this.options.memoryStore.get(query.memoryId, permitted);
|
|
241
|
+
if (atom === null) {
|
|
242
|
+
return emptyMemoryTimeline(failClosed('source_check_failed', 'memory is missing or not visible', emittedAt));
|
|
243
|
+
}
|
|
244
|
+
if (scopeKey(atom.scope) !== scopeKey(query.scope)) {
|
|
245
|
+
return emptyMemoryTimeline(failClosed('scope_outside_boundary', scopeKey(query.scope), emittedAt, scopeKey(atom.scope)));
|
|
246
|
+
}
|
|
247
|
+
const fullHistory = await this.options.memoryStore.statusHistory(atom.memoryId);
|
|
248
|
+
const until = query.until;
|
|
249
|
+
const history = until !== undefined ? fullHistory.filter((entry) => entry.at <= until) : fullHistory;
|
|
250
|
+
if (history.length === 0) {
|
|
251
|
+
return emptyMemoryTimeline(failClosed('tuple_incomplete', `statusHistory:${atom.memoryId}`, emittedAt));
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
decision: decision('allow_local_shadow', [{ kind: 'all_checks_passed', citedMemoryIds: [atom.memoryId] }], [atom.memoryId], [], emittedAt),
|
|
255
|
+
atom,
|
|
256
|
+
history,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
permittedFor(agentId) {
|
|
260
|
+
return this.visibilityPolicy.permittedVisibilitiesForAgent(agentId);
|
|
261
|
+
}
|
|
262
|
+
async loadEpisodeEvents(query, permitted) {
|
|
263
|
+
const events = await this.loadAnchoredEvents(query, permitted);
|
|
264
|
+
return events.filter((event) => event.anchor.episodeId === query.episodeId);
|
|
265
|
+
}
|
|
266
|
+
async loadAnchoredEvents(query, permitted) {
|
|
267
|
+
const events = await this.options.eventLedger.query({
|
|
268
|
+
scope: query.scope,
|
|
269
|
+
permittedVisibilities: permitted,
|
|
270
|
+
...(query.since !== undefined ? { since: query.since } : {}),
|
|
271
|
+
...(query.until !== undefined ? { until: query.until } : {}),
|
|
272
|
+
});
|
|
273
|
+
return events
|
|
274
|
+
.map((event) => {
|
|
275
|
+
const anchor = episodeAnchorFromEvent(event);
|
|
276
|
+
return anchor !== null ? { event, anchor } : null;
|
|
277
|
+
})
|
|
278
|
+
.filter((event) => event !== null);
|
|
279
|
+
}
|
|
280
|
+
async loadSnapshot(query, permitted) {
|
|
281
|
+
const atoms = await this.options.memoryStore.query({
|
|
282
|
+
statuses: ALL_STATUSES,
|
|
283
|
+
scope: query.scope,
|
|
284
|
+
permittedVisibilities: permitted,
|
|
285
|
+
validAt: query.asOf,
|
|
286
|
+
});
|
|
287
|
+
const statusResults = await Promise.all(atoms.map(async (atom) => {
|
|
288
|
+
const status = await this.statusAt(atom, query.asOf);
|
|
289
|
+
if (status === null)
|
|
290
|
+
return null;
|
|
291
|
+
return {
|
|
292
|
+
memoryId: atom.memoryId,
|
|
293
|
+
status,
|
|
294
|
+
at: query.asOf,
|
|
295
|
+
};
|
|
296
|
+
}));
|
|
297
|
+
const statusesAt = statusResults.filter((status) => status !== null);
|
|
298
|
+
const statusByMemoryId = new Map(statusesAt.map((status) => [status.memoryId, status.status]));
|
|
299
|
+
const allowedStatuses = new Set(query.statusesAt ?? BELIEF_STATUSES);
|
|
300
|
+
const matchingAtoms = atoms.filter((atom) => {
|
|
301
|
+
const status = statusByMemoryId.get(atom.memoryId);
|
|
302
|
+
if (status === undefined || !allowedStatuses.has(status))
|
|
303
|
+
return false;
|
|
304
|
+
if (query.contentIncludes !== undefined && !atom.content.includes(query.contentIncludes)) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
return true;
|
|
308
|
+
});
|
|
309
|
+
const filteredAtoms = query.limit !== undefined ? matchingAtoms.slice(0, query.limit) : matchingAtoms;
|
|
310
|
+
const filteredIds = new Set(filteredAtoms.map((atom) => atom.memoryId));
|
|
311
|
+
return {
|
|
312
|
+
atoms: filteredAtoms,
|
|
313
|
+
statusesAt: statusesAt.filter((status) => filteredIds.has(status.memoryId)),
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
async statusAt(atom, at) {
|
|
317
|
+
const history = await this.options.memoryStore.statusHistory(atom.memoryId);
|
|
318
|
+
const latest = history.filter((entry) => entry.at <= at).at(-1);
|
|
319
|
+
return latest?.toStatus ?? null;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Parse an explicit episodic anchor from an event payload.
|
|
324
|
+
*
|
|
325
|
+
* @remarks
|
|
326
|
+
* This helper is intentionally conservative: malformed or missing
|
|
327
|
+
* `payload.episodic` objects return `null` instead of being inferred from
|
|
328
|
+
* prose, timestamps, or event kind.
|
|
329
|
+
*/
|
|
330
|
+
export function episodeAnchorFromEvent(event) {
|
|
331
|
+
if (!hasEpisodicPayload(event.payload))
|
|
332
|
+
return null;
|
|
333
|
+
const raw = event.payload.episodic;
|
|
334
|
+
if (!isRecord(raw))
|
|
335
|
+
return null;
|
|
336
|
+
const episodeId = stringField(raw, 'episodeId');
|
|
337
|
+
const kind = episodeKindField(raw, 'kind');
|
|
338
|
+
if (episodeId === null || kind === null)
|
|
339
|
+
return null;
|
|
340
|
+
return optionalFields({
|
|
341
|
+
episodeId,
|
|
342
|
+
kind,
|
|
343
|
+
sessionId: stringField(raw, 'sessionId'),
|
|
344
|
+
conversationId: stringField(raw, 'conversationId'),
|
|
345
|
+
taskId: stringField(raw, 'taskId'),
|
|
346
|
+
decisionContextId: stringField(raw, 'decisionContextId'),
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
function failClosed(kind, detail, emittedAt, allowedScope) {
|
|
350
|
+
return decision('fetch_abstain', [failClosedReason(kind, detail, allowedScope)], [], [], emittedAt);
|
|
351
|
+
}
|
|
352
|
+
function failClosedReason(kind, detail, allowedScope) {
|
|
353
|
+
if (kind === 'tuple_incomplete')
|
|
354
|
+
return { kind, missingFields: [detail] };
|
|
355
|
+
if (kind === 'scope_outside_boundary') {
|
|
356
|
+
return {
|
|
357
|
+
kind,
|
|
358
|
+
requestedScope: detail,
|
|
359
|
+
allowedScope: allowedScope ?? 'unknown',
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
return { kind, detail };
|
|
363
|
+
}
|
|
364
|
+
function emptyCatalog(decisionValue) {
|
|
365
|
+
return {
|
|
366
|
+
decision: decisionValue,
|
|
367
|
+
episodes: [],
|
|
368
|
+
events: [],
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function emptyEpisodeProjection(decisionValue) {
|
|
372
|
+
return {
|
|
373
|
+
decision: decisionValue,
|
|
374
|
+
episode: null,
|
|
375
|
+
events: [],
|
|
376
|
+
atoms: [],
|
|
377
|
+
statusesAt: [],
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
function emptyBeliefSnapshot(at, decisionValue) {
|
|
381
|
+
return {
|
|
382
|
+
decision: decisionValue,
|
|
383
|
+
at,
|
|
384
|
+
atoms: [],
|
|
385
|
+
statusesAt: [],
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function emptyComparison(decisionValue) {
|
|
389
|
+
return {
|
|
390
|
+
decision: decisionValue,
|
|
391
|
+
fromEpisode: null,
|
|
392
|
+
toEpisode: null,
|
|
393
|
+
addedMemoryIds: [],
|
|
394
|
+
removedMemoryIds: [],
|
|
395
|
+
persistedMemoryIds: [],
|
|
396
|
+
statusChanged: [],
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function emptySelfState(at, decisionValue) {
|
|
400
|
+
return {
|
|
401
|
+
decision: decisionValue,
|
|
402
|
+
at,
|
|
403
|
+
beliefs: [],
|
|
404
|
+
uncertain: [],
|
|
405
|
+
distrusted: [],
|
|
406
|
+
humanRequired: [],
|
|
407
|
+
statusHistory: [],
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function emptyMemoryTimeline(decisionValue) {
|
|
411
|
+
return {
|
|
412
|
+
decision: decisionValue,
|
|
413
|
+
atom: null,
|
|
414
|
+
history: [],
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function summarizeEpisodes(events) {
|
|
418
|
+
const grouped = new Map();
|
|
419
|
+
for (const event of events) {
|
|
420
|
+
const key = `${event.anchor.kind}:${event.anchor.episodeId}`;
|
|
421
|
+
const existing = grouped.get(key);
|
|
422
|
+
if (existing !== undefined) {
|
|
423
|
+
existing.push(event);
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
grouped.set(key, [event]);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return [...grouped.values()]
|
|
430
|
+
.map((episodeEvents) => summarizeEpisode(episodeEvents[0]?.anchor.episodeId ?? '', episodeEvents, []))
|
|
431
|
+
.sort((a, b) => {
|
|
432
|
+
if (a.firstOccurredAt !== b.firstOccurredAt) {
|
|
433
|
+
return a.firstOccurredAt.localeCompare(b.firstOccurredAt);
|
|
434
|
+
}
|
|
435
|
+
return a.episodeId.localeCompare(b.episodeId);
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
function summarizeEpisode(episodeId, events, atoms) {
|
|
439
|
+
const kind = events[0]?.anchor.kind ?? 'session';
|
|
440
|
+
const occurredAts = events.map((event) => event.event.occurredAt);
|
|
441
|
+
return {
|
|
442
|
+
episodeId,
|
|
443
|
+
kind,
|
|
444
|
+
firstOccurredAt: minIso(occurredAts),
|
|
445
|
+
lastOccurredAt: maxIso(occurredAts),
|
|
446
|
+
eventIds: events.map((event) => event.event.eventId),
|
|
447
|
+
memoryIds: atoms.map((atom) => atom.memoryId),
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
function atomsWithStatus(snapshot, statuses) {
|
|
451
|
+
const allowed = new Set(statuses);
|
|
452
|
+
const statusByMemoryId = new Map(snapshot.statusesAt.map((status) => [status.memoryId, status.status]));
|
|
453
|
+
return snapshot.atoms.filter((atom) => {
|
|
454
|
+
const status = statusByMemoryId.get(atom.memoryId);
|
|
455
|
+
return status !== undefined && allowed.has(status);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
function uniqueMemoryIds(memoryIds) {
|
|
459
|
+
return [...new Set(memoryIds)];
|
|
460
|
+
}
|
|
461
|
+
function minIso(values) {
|
|
462
|
+
const first = values[0];
|
|
463
|
+
if (first === undefined) {
|
|
464
|
+
throw new Error('minIso requires at least one timestamp');
|
|
465
|
+
}
|
|
466
|
+
return values.reduce((min, value) => (value < min ? value : min), first);
|
|
467
|
+
}
|
|
468
|
+
function maxIso(values) {
|
|
469
|
+
const first = values[0];
|
|
470
|
+
if (first === undefined) {
|
|
471
|
+
throw new Error('maxIso requires at least one timestamp');
|
|
472
|
+
}
|
|
473
|
+
return values.reduce((max, value) => (value > max ? value : max), first);
|
|
474
|
+
}
|
|
475
|
+
function isRecord(value) {
|
|
476
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
477
|
+
}
|
|
478
|
+
function hasEpisodicPayload(value) {
|
|
479
|
+
return isRecord(value);
|
|
480
|
+
}
|
|
481
|
+
function stringField(record, key) {
|
|
482
|
+
const value = record[key];
|
|
483
|
+
return typeof value === 'string' && value.length > 0 ? value : null;
|
|
484
|
+
}
|
|
485
|
+
function episodeKindField(record, key) {
|
|
486
|
+
const value = record[key];
|
|
487
|
+
if (value === 'conversation' ||
|
|
488
|
+
value === 'task' ||
|
|
489
|
+
value === 'decision_context' ||
|
|
490
|
+
value === 'session') {
|
|
491
|
+
return value;
|
|
492
|
+
}
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
function optionalFields(anchor) {
|
|
496
|
+
return {
|
|
497
|
+
episodeId: anchor.episodeId,
|
|
498
|
+
kind: anchor.kind,
|
|
499
|
+
...(anchor.sessionId !== null ? { sessionId: anchor.sessionId } : {}),
|
|
500
|
+
...(anchor.conversationId !== null ? { conversationId: anchor.conversationId } : {}),
|
|
501
|
+
...(anchor.taskId !== null ? { taskId: anchor.taskId } : {}),
|
|
502
|
+
...(anchor.decisionContextId !== null ? { decisionContextId: anchor.decisionContextId } : {}),
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
//# sourceMappingURL=episodic-timeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"episodic-timeline.js","sourceRoot":"","sources":["../src/episodic-timeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,0BAA0B,EAc1B,QAAQ,EACR,QAAQ,GACT,MAAM,qBAAqB,CAAC;AA8I7B,MAAM,YAAY,GAA4B;IAC5C,WAAW;IACX,UAAU;IACV,SAAS;IACT,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,gBAAgB;CACjB,CAAC;AAEF,MAAM,eAAe,GAA4B,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAEzE,MAAM,YAAY,GAAU;IAC1B,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAkB;CACpD,CAAC;AAEF,MAAM,OAAO,gBAAgB;IAWE;IAVZ,gBAAgB,CAAmB;IACnC,KAAK,CAAQ;IAE9B;;;;;;OAMG;IACH,YAA6B,OAAgC;QAAhC,YAAO,GAAP,OAAO,CAAyB;QAC3D,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,0BAA0B,CAAC;QAC/E,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC;IAC7C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,YAAY,CAAC,KAA0B;Q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AAC,EAAE,CAAC;QACrE,GAAG,CAAC,MAAM,CAAC,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpF,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5D,GAAG,CAAC,MAAM,CAAC,iBAAiB,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9F,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aletheia-labs/episodic",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Subjective time and episodic continuity projections for Aletheia memory stores.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@aletheia-labs/core": "0.1.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^22.10.0",
|
|
26
|
+
"typescript": "^5.6.3",
|
|
27
|
+
"vitest": "^2.1.8"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"aletheia",
|
|
34
|
+
"llm",
|
|
35
|
+
"memory",
|
|
36
|
+
"episodic",
|
|
37
|
+
"agents"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc -p tsconfig.json",
|
|
41
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest"
|
|
44
|
+
}
|
|
45
|
+
}
|