@spine-event-engine/storage 2.0.0-snapshot.22 → 2.0.0-snapshot.24

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.
Files changed (127) hide show
  1. package/README.md +7 -0
  2. package/REFERENCE.md +131 -7
  3. package/dist/entity/agent-execution-record-spec.d.ts +87 -0
  4. package/dist/entity/agent-execution-record-spec.d.ts.map +1 -0
  5. package/dist/entity/agent-execution-record-spec.js +230 -0
  6. package/dist/entity/agent-execution-record-spec.js.map +1 -0
  7. package/dist/entity/agent-execution-sizes.d.ts +30 -0
  8. package/dist/entity/agent-execution-sizes.d.ts.map +1 -0
  9. package/dist/entity/agent-execution-sizes.js +51 -0
  10. package/dist/entity/agent-execution-sizes.js.map +1 -0
  11. package/dist/entity/agent-execution-transitions.d.ts +72 -0
  12. package/dist/entity/agent-execution-transitions.d.ts.map +1 -0
  13. package/dist/entity/agent-execution-transitions.js +165 -0
  14. package/dist/entity/agent-execution-transitions.js.map +1 -0
  15. package/dist/entity/agent-execution-values.d.ts +143 -0
  16. package/dist/entity/agent-execution-values.d.ts.map +1 -0
  17. package/dist/entity/agent-execution-values.js +251 -0
  18. package/dist/entity/agent-execution-values.js.map +1 -0
  19. package/dist/entity/agent-execution.d.ts +235 -0
  20. package/dist/entity/agent-execution.d.ts.map +1 -0
  21. package/dist/entity/agent-execution.js +15 -0
  22. package/dist/entity/agent-execution.js.map +1 -0
  23. package/dist/entity/agent-history-conformance.d.ts +78 -0
  24. package/dist/entity/agent-history-conformance.d.ts.map +1 -0
  25. package/dist/entity/agent-history-conformance.js +493 -0
  26. package/dist/entity/agent-history-conformance.js.map +1 -0
  27. package/dist/entity/agent-history-provider-page.d.ts +39 -0
  28. package/dist/entity/agent-history-provider-page.d.ts.map +1 -0
  29. package/dist/entity/agent-history-provider-page.js +82 -0
  30. package/dist/entity/agent-history-provider-page.js.map +1 -0
  31. package/dist/entity/agent-history-record-spec.d.ts +79 -0
  32. package/dist/entity/agent-history-record-spec.d.ts.map +1 -0
  33. package/dist/entity/agent-history-record-spec.js +147 -0
  34. package/dist/entity/agent-history-record-spec.js.map +1 -0
  35. package/dist/entity/agent-history.d.ts +196 -0
  36. package/dist/entity/agent-history.d.ts.map +1 -0
  37. package/dist/entity/agent-history.js +136 -0
  38. package/dist/entity/agent-history.js.map +1 -0
  39. package/dist/event/event-store.d.ts +41 -35
  40. package/dist/event/event-store.d.ts.map +1 -1
  41. package/dist/event/event-store.js +149 -144
  42. package/dist/event/event-store.js.map +1 -1
  43. package/dist/index.d.ts +1 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/internal/agent-execution.d.ts +51 -0
  48. package/dist/internal/agent-execution.d.ts.map +1 -0
  49. package/dist/internal/agent-execution.js +53 -0
  50. package/dist/internal/agent-execution.js.map +1 -0
  51. package/dist/internal/agent-history.d.ts +48 -0
  52. package/dist/internal/agent-history.d.ts.map +1 -0
  53. package/dist/internal/agent-history.js +52 -0
  54. package/dist/internal/agent-history.js.map +1 -0
  55. package/dist/internal/entity-commit.d.ts +30 -11
  56. package/dist/internal/entity-commit.d.ts.map +1 -1
  57. package/dist/internal/entity-commit.js +45 -2
  58. package/dist/internal/entity-commit.js.map +1 -1
  59. package/dist/internal/entity-history.d.ts +11 -0
  60. package/dist/internal/entity-history.d.ts.map +1 -1
  61. package/dist/internal/entity-history.js +10 -0
  62. package/dist/internal/entity-history.js.map +1 -1
  63. package/dist/internal/event-store.d.ts +1 -1
  64. package/dist/internal/event-store.d.ts.map +1 -1
  65. package/dist/internal/event-store.js +1 -1
  66. package/dist/internal/event-store.js.map +1 -1
  67. package/dist/internal/tenancy.d.ts +87 -1
  68. package/dist/internal/tenancy.d.ts.map +1 -1
  69. package/dist/internal/tenancy.js +39 -0
  70. package/dist/internal/tenancy.js.map +1 -1
  71. package/dist/memory/agent-execution-head-index.d.ts +52 -0
  72. package/dist/memory/agent-execution-head-index.d.ts.map +1 -0
  73. package/dist/memory/agent-execution-head-index.js +91 -0
  74. package/dist/memory/agent-execution-head-index.js.map +1 -0
  75. package/dist/memory/agent-history-index.d.ts +49 -0
  76. package/dist/memory/agent-history-index.d.ts.map +1 -0
  77. package/dist/memory/agent-history-index.js +239 -0
  78. package/dist/memory/agent-history-index.js.map +1 -0
  79. package/dist/memory/agent-history-mutation-queue.d.ts +17 -0
  80. package/dist/memory/agent-history-mutation-queue.d.ts.map +1 -0
  81. package/dist/memory/agent-history-mutation-queue.js +31 -0
  82. package/dist/memory/agent-history-mutation-queue.js.map +1 -0
  83. package/dist/memory/in-memory-agent-execution.d.ts +21 -0
  84. package/dist/memory/in-memory-agent-execution.d.ts.map +1 -0
  85. package/dist/memory/in-memory-agent-execution.js +587 -0
  86. package/dist/memory/in-memory-agent-execution.js.map +1 -0
  87. package/dist/memory/in-memory-agent-history.d.ts +21 -0
  88. package/dist/memory/in-memory-agent-history.d.ts.map +1 -0
  89. package/dist/memory/in-memory-agent-history.js +133 -0
  90. package/dist/memory/in-memory-agent-history.js.map +1 -0
  91. package/dist/memory/in-memory-entity-commit.d.ts +107 -28
  92. package/dist/memory/in-memory-entity-commit.d.ts.map +1 -1
  93. package/dist/memory/in-memory-entity-commit.js +198 -286
  94. package/dist/memory/in-memory-entity-commit.js.map +1 -1
  95. package/dist/memory/in-memory-entity-history.d.ts +1 -1
  96. package/dist/memory/in-memory-entity-history.d.ts.map +1 -1
  97. package/dist/memory/in-memory-entity-history.js.map +1 -1
  98. package/dist/memory/in-memory-storage-backend.d.ts +18 -0
  99. package/dist/memory/in-memory-storage-backend.d.ts.map +1 -1
  100. package/dist/memory/in-memory-storage-backend.js +71 -0
  101. package/dist/memory/in-memory-storage-backend.js.map +1 -1
  102. package/dist/memory/in-memory-storage-factory.d.ts +38 -3
  103. package/dist/memory/in-memory-storage-factory.d.ts.map +1 -1
  104. package/dist/memory/in-memory-storage-factory.js +146 -10
  105. package/dist/memory/in-memory-storage-factory.js.map +1 -1
  106. package/dist/memory/tenant-records.d.ts +1 -1
  107. package/dist/memory/tenant-records.d.ts.map +1 -1
  108. package/dist/memory/tenant-records.js +3 -2
  109. package/dist/memory/tenant-records.js.map +1 -1
  110. package/dist/provider.d.ts +0 -1
  111. package/dist/provider.d.ts.map +1 -1
  112. package/dist/provider.js +0 -1
  113. package/dist/provider.js.map +1 -1
  114. package/dist/record/record-query.d.ts +10 -2
  115. package/dist/record/record-query.d.ts.map +1 -1
  116. package/dist/record/record-query.js +9 -0
  117. package/dist/record/record-query.js.map +1 -1
  118. package/dist/tsconfig.tsbuildinfo +1 -1
  119. package/package.json +3 -2
  120. package/dist/internal/delivery-cleanup.d.ts +0 -99
  121. package/dist/internal/delivery-cleanup.d.ts.map +0 -1
  122. package/dist/internal/delivery-cleanup.js +0 -38
  123. package/dist/internal/delivery-cleanup.js.map +0 -1
  124. package/dist/memory/memory-delivery-cleanup.d.ts +0 -32
  125. package/dist/memory/memory-delivery-cleanup.d.ts.map +0 -1
  126. package/dist/memory/memory-delivery-cleanup.js +0 -61
  127. package/dist/memory/memory-delivery-cleanup.js.map +0 -1
@@ -0,0 +1,79 @@
1
+ import { type AgentHistoryEntry } from "@spine-event-engine/proto/agent";
2
+ import { type AgentHistoryRecord } from "@spine-event-engine/proto/generated/spine/server/agent/history_record_pb.js";
3
+ import { RecordColumn } from "../record/record-column.js";
4
+ import { RecordSpec } from "../record/record-spec.js";
5
+ import { StorageGroup } from "../record/storage-group.js";
6
+ /**
7
+ * Describes materialization of original Agent history records and indexed columns.
8
+ */
9
+ interface AgentHistoryRecordLayout {
10
+ /**
11
+ * Identifies the physical family shared within one tenant.
12
+ */
13
+ readonly group: StorageGroup;
14
+ /**
15
+ * Builds the complete internal envelope.
16
+ *
17
+ * @param stateType Generated Agent state type name.
18
+ * @param agentKey Canonical typed identifier key.
19
+ * @param entry Complete original history entry.
20
+ * @returns Internal storage envelope.
21
+ */
22
+ record(stateType: string, agentKey: string, entry: AgentHistoryEntry): AgentHistoryRecord;
23
+ /**
24
+ * Encodes the immutable logical record identity.
25
+ *
26
+ * @param record Internal history envelope.
27
+ * @returns Complete logical identity.
28
+ */
29
+ slot(record: AgentHistoryRecord): string;
30
+ /**
31
+ * Encodes the complete Agent repository scope.
32
+ *
33
+ * @param stateType Generated Agent state type name.
34
+ * @param agentKey Canonical typed identifier key.
35
+ * @returns Complete logical scope.
36
+ */
37
+ scope(stateType: string, agentKey: string): string;
38
+ /**
39
+ * Builds provider columns with a fixed-width physical digest.
40
+ *
41
+ * @param digest Provider digest of a complete logical identity.
42
+ * @returns Shared native record specification.
43
+ */
44
+ spec(digest: (value: string) => string): RecordSpec<string, AgentHistoryRecord>;
45
+ /**
46
+ * Reads the validated repository scope from an envelope.
47
+ *
48
+ * @param record Internal history envelope.
49
+ * @returns Complete original scope.
50
+ */
51
+ requiredScope(record: AgentHistoryRecord): NonNullable<AgentHistoryRecord["scope"]>;
52
+ /**
53
+ * Reads the original history entry from an envelope.
54
+ *
55
+ * @param record Internal history envelope.
56
+ * @returns Complete original history entry.
57
+ */
58
+ requiredEntry(record: AgentHistoryRecord): AgentHistoryEntry;
59
+ /**
60
+ * Builds the materialized repository scope columns.
61
+ *
62
+ * @param digest Provider digest of a complete logical identity.
63
+ * @returns Complete scope columns.
64
+ */
65
+ scopeColumns(digest: (value: string) => string): RecordColumn<AgentHistoryRecord>[];
66
+ /**
67
+ * Builds the materialized order and conversation columns.
68
+ *
69
+ * @param digest Provider digest of a complete logical identity.
70
+ * @returns Complete order and conversation columns.
71
+ */
72
+ orderColumns(digest: (value: string) => string): RecordColumn<AgentHistoryRecord>[];
73
+ }
74
+ /**
75
+ * Internal record layout for one tenant's shared Agent history family.
76
+ */
77
+ export declare const AgentHistoryRecords: AgentHistoryRecordLayout;
78
+ export {};
79
+ //# sourceMappingURL=agent-history-record-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-history-record-spec.d.ts","sourceRoot":"","sources":["../../src/entity/agent-history-record-spec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AAkB,CAAC,EAAE,CAAC;CACrF;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,wBAsJjC,CAAC"}
@@ -0,0 +1,147 @@
1
+ /*
2
+ * Copyright 2026, CodeMatters. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * https://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+ import { create, ScalarType } from "@bufbuild/protobuf";
15
+ import { AgentHistoryEntrySchema } from "@spine-event-engine/proto/agent";
16
+ import { AgentHistoryRecordSchema, AgentHistoryStorageKeySchema as AgentStorageKeySchema, } from "@spine-event-engine/proto/generated/spine/server/agent/history_record_pb.js";
17
+ import { RecordColumn } from "../record/record-column.js";
18
+ import { ColumnTypes } from "../record/column-type.js";
19
+ import { RecordSpec } from "../record/record-spec.js";
20
+ import { StorageGroup } from "../record/storage-group.js";
21
+ import { AgentHistoryKeys } from "./agent-history.js";
22
+ /**
23
+ * Physical family shared by Agent state types within one tenant.
24
+ */
25
+ const agentHistoryGroup = new StorageGroup("agent_history");
26
+ /**
27
+ * Internal record layout for one tenant's shared Agent history family.
28
+ */
29
+ export const AgentHistoryRecords = {
30
+ /**
31
+ * Physical family shared by Agent state types within one tenant.
32
+ */
33
+ group: agentHistoryGroup,
34
+ /**
35
+ * Stores one original entry with its canonical repository scope.
36
+ *
37
+ * @param stateType Generated Agent state type name.
38
+ * @param agentKey Canonical typed identifier key.
39
+ * @param entry Complete original history entry.
40
+ * @returns Internal storage envelope.
41
+ */
42
+ record(stateType, agentKey, entry) {
43
+ if (stateType.length === 0 || agentKey.length === 0)
44
+ throw new TypeError("Agent history requires state type and Agent key.");
45
+ AgentHistoryKeys.fromEntry(entry);
46
+ return create(AgentHistoryRecordSchema, {
47
+ scope: create(AgentStorageKeySchema, { stateType, agentKey }),
48
+ entry,
49
+ });
50
+ },
51
+ /**
52
+ * Builds the full logical identity hashed into a provider physical ID.
53
+ *
54
+ * @param record Internal history envelope.
55
+ * @returns Unambiguous identity without an ordering position.
56
+ */
57
+ slot(record) {
58
+ const scope = AgentHistoryRecords.requiredScope(record);
59
+ const key = AgentHistoryKeys.fromEntry(AgentHistoryRecords.requiredEntry(record));
60
+ return JSON.stringify([scope.stateType, scope.agentKey, key.category, key.recordId]);
61
+ },
62
+ /**
63
+ * Encodes the complete repository scope before provider hashing.
64
+ *
65
+ * @param stateType Generated Agent state type.
66
+ * @param agentKey Canonical typed Agent key.
67
+ * @returns Unambiguous complete scope identity.
68
+ */
69
+ scope(stateType, agentKey) {
70
+ return JSON.stringify([stateType, agentKey]);
71
+ },
72
+ /**
73
+ * Builds materialized columns with one provider's bounded physical digest.
74
+ *
75
+ * @param digest Maps a complete identity to a fixed-width digest.
76
+ * @returns Shared record specification for native providers.
77
+ */
78
+ spec(digest) {
79
+ return new RecordSpec({
80
+ sourceType: AgentHistoryEntrySchema,
81
+ recordType: AgentHistoryRecordSchema,
82
+ idKind: "string",
83
+ extractId: (record) => digest(AgentHistoryRecords.slot(record)),
84
+ columns: [
85
+ ...AgentHistoryRecords.scopeColumns(digest),
86
+ ...AgentHistoryRecords.orderColumns(digest),
87
+ ],
88
+ });
89
+ },
90
+ /**
91
+ * Reads the repository scope required by every stored history entry.
92
+ *
93
+ * @param record Stored history envelope.
94
+ * @returns Complete original scope.
95
+ */
96
+ requiredScope(record) {
97
+ if (record.scope === undefined ||
98
+ record.scope.stateType.length === 0 ||
99
+ record.scope.agentKey.length === 0)
100
+ throw new TypeError("Agent history record requires a complete repository scope.");
101
+ return record.scope;
102
+ },
103
+ /**
104
+ * Reads the original history entry required by the storage envelope.
105
+ *
106
+ * @param record Stored history envelope.
107
+ * @returns Complete original history entry.
108
+ */
109
+ requiredEntry(record) {
110
+ if (record.entry === undefined)
111
+ throw new TypeError("Agent history record requires an entry.");
112
+ return record.entry;
113
+ },
114
+ /**
115
+ * Builds complete scope columns and their bounded indexed digest.
116
+ *
117
+ * @param digest Provider physical-identity digest.
118
+ * @returns Native scope columns.
119
+ */
120
+ scopeColumns(digest) {
121
+ const string = ColumnTypes.scalar(ScalarType.STRING);
122
+ return [
123
+ new RecordColumn("state_type", string, (record) => AgentHistoryRecords.requiredScope(record).stateType),
124
+ new RecordColumn("agent_key", string, (record) => AgentHistoryRecords.requiredScope(record).agentKey),
125
+ new RecordColumn("scope_digest", string, (record) => digest(AgentHistoryRecords.scope(AgentHistoryRecords.requiredScope(record).stateType, AgentHistoryRecords.requiredScope(record).agentKey))),
126
+ ];
127
+ },
128
+ /**
129
+ * Builds complete order and conversation selector columns.
130
+ *
131
+ * @param digest Provider physical-identity digest.
132
+ * @returns Native order and conversation columns.
133
+ */
134
+ orderColumns(digest) {
135
+ const string = ColumnTypes.scalar(ScalarType.STRING);
136
+ const conversation = (record) => record.entry?.item.case === "conversationRecord"
137
+ ? (record.entry.item.value.conversation?.value ?? "")
138
+ : "";
139
+ return [
140
+ new RecordColumn("category", string, (record) => AgentHistoryKeys.fromEntry(AgentHistoryRecords.requiredEntry(record)).category),
141
+ new RecordColumn("conversation_key", string, conversation),
142
+ new RecordColumn("conversation_digest", string, (record) => digest(conversation(record))),
143
+ new RecordColumn("order_key", string, (record) => AgentHistoryKeys.indexValue(AgentHistoryKeys.fromEntry(AgentHistoryRecords.requiredEntry(record)))),
144
+ ];
145
+ },
146
+ };
147
+ //# sourceMappingURL=agent-history-record-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-history-record-spec.js","sourceRoot":"","sources":["../../src/entity/agent-history-record-spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;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AE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;YACzF,IAAI,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAC/C,gBAAgB,CAAC,UAAU,CACzB,gBAAgB,CAAC,SAAS,CAAC,mBAAmB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CACtE,CACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,196 @@
1
+ import type { Timestamp } from "@bufbuild/protobuf/wkt";
2
+ import type { AgentHistoryEntry, ConversationId } from "@spine-event-engine/proto/agent";
3
+ import type { StorageContext } from "../storage/storage.js";
4
+ /**
5
+ * Converts a typed Agent identifier to its canonical storage key.
6
+ *
7
+ * @typeParam Id Typed Agent identifier.
8
+ */
9
+ interface AgentHistoryIdCodec<Id> {
10
+ /**
11
+ * Maps one typed Agent identifier to its canonical key.
12
+ *
13
+ * @param id Typed Agent identifier.
14
+ * @returns Canonical key within the repository scope.
15
+ */
16
+ readonly key: (id: Id) => string;
17
+ }
18
+ /**
19
+ * Identifies one existing record in the Agent history order.
20
+ */
21
+ export interface AgentHistoryOrderKey {
22
+ /**
23
+ * Original occurrence timestamp, with full seconds and nanoseconds.
24
+ */
25
+ readonly occurredAt: Timestamp;
26
+ /**
27
+ * Selects the category tie-break after equal timestamps.
28
+ */
29
+ readonly category: "conversation" | "system" | "domain";
30
+ /**
31
+ * Immutable record or Event ID.
32
+ */
33
+ readonly recordId: string;
34
+ }
35
+ /**
36
+ * Selects one indexed view of the Agent's append-only history.
37
+ */
38
+ export type AgentHistoryView = AgentHistoryFullView | AgentHistoryConversationView | AgentHistorySystemView | AgentHistoryDomainView;
39
+ /**
40
+ * Selects every recorded category.
41
+ */
42
+ interface AgentHistoryFullView {
43
+ /**
44
+ * Identifies the full view.
45
+ */
46
+ readonly kind: "full";
47
+ }
48
+ /**
49
+ * Selects records of one conversation.
50
+ */
51
+ interface AgentHistoryConversationView {
52
+ /**
53
+ * Identifies the conversation view.
54
+ */
55
+ readonly kind: "conversation";
56
+ /**
57
+ * Existing conversation identifier.
58
+ */
59
+ readonly conversation: ConversationId;
60
+ }
61
+ /**
62
+ * Selects recorded Agent System Events.
63
+ */
64
+ interface AgentHistorySystemView {
65
+ /**
66
+ * Identifies the System view.
67
+ */
68
+ readonly kind: "system";
69
+ }
70
+ /**
71
+ * Selects recorded Agent domain Events.
72
+ */
73
+ interface AgentHistoryDomainView {
74
+ /**
75
+ * Identifies the domain view.
76
+ */
77
+ readonly kind: "domain";
78
+ }
79
+ /**
80
+ * Identifies a repository and its complete tenant boundary for Agent history.
81
+ *
82
+ * @typeParam Id Typed Agent identifier.
83
+ */
84
+ export interface AgentHistoryStorageInput<Id> {
85
+ /**
86
+ * Bounded Context and complete tenant selection.
87
+ */
88
+ readonly context: StorageContext;
89
+ /**
90
+ * Generated Agent state type name.
91
+ */
92
+ readonly stateType: string;
93
+ /**
94
+ * Canonical typed Entity ID conversion supplied by the repository.
95
+ */
96
+ readonly id: AgentHistoryIdCodec<Id>;
97
+ }
98
+ /**
99
+ * Selects a bounded provider page after an optional complete ordering key.
100
+ *
101
+ * @typeParam Id Typed Agent identifier.
102
+ */
103
+ export interface AgentHistoryRead<Id> {
104
+ /**
105
+ * Typed Agent identifier in the configured repository scope.
106
+ */
107
+ readonly entityId: Id;
108
+ /**
109
+ * Full, conversation, System, or domain index.
110
+ */
111
+ readonly view: AgentHistoryView;
112
+ /**
113
+ * Last returned key from the preceding page, when continuing.
114
+ */
115
+ readonly after?: AgentHistoryOrderKey;
116
+ /**
117
+ * Maximum number of entries to return; any positive safe integer is allowed.
118
+ */
119
+ readonly count: number;
120
+ /**
121
+ * Optional maximum sum of serialized AgentHistoryEntry byte lengths.
122
+ */
123
+ readonly maxBytes?: number;
124
+ }
125
+ /**
126
+ * Returns one bounded page and indicates whether older entries remain.
127
+ */
128
+ export interface AgentHistoryPage {
129
+ /**
130
+ * Independent copies of complete Proto history entries.
131
+ */
132
+ readonly entries: readonly AgentHistoryEntry[];
133
+ /**
134
+ * True when another entry follows this page in the selected view.
135
+ */
136
+ readonly hasMore: boolean;
137
+ }
138
+ /**
139
+ * Provider handle for one repository state type and tenant boundary.
140
+ *
141
+ * @typeParam Id Typed Agent identifier.
142
+ */
143
+ export interface AgentHistoryStorage<Id> {
144
+ /**
145
+ * Adds one immutable occurrence, or accepts an identical repeated append.
146
+ *
147
+ * @param entityId Typed Agent identifier.
148
+ * @param entry Complete conversation, System, or domain entry.
149
+ * @returns Resolves after the occurrence is recorded.
150
+ */
151
+ append(entityId: Id, entry: AgentHistoryEntry): Promise<void>;
152
+ /**
153
+ * Reads a bounded live continuation from one indexed view.
154
+ *
155
+ * @param request Scope, view, complete-key boundary, and response bounds.
156
+ * @returns Independent entries and whether older results remain.
157
+ */
158
+ read(request: AgentHistoryRead<Id>): Promise<AgentHistoryPage>;
159
+ /**
160
+ * Closes this handle without deleting any recorded history.
161
+ */
162
+ close(): void;
163
+ }
164
+ /**
165
+ * Operations on the complete, provider-independent ordering key.
166
+ */
167
+ export interface AgentHistoryKeyOperations {
168
+ /**
169
+ * Reads the original ordering key from a history entry.
170
+ *
171
+ * @param entry Complete history entry.
172
+ * @returns Original complete ordering key.
173
+ */
174
+ fromEntry(entry: AgentHistoryEntry): AgentHistoryOrderKey;
175
+ /**
176
+ * Encodes a key for binary-collated provider indexes.
177
+ *
178
+ * @param key Original complete ordering key.
179
+ * @returns Prefix-safe sortable index value.
180
+ */
181
+ indexValue(key: AgentHistoryOrderKey): string;
182
+ /**
183
+ * Compares two keys in newest-first order.
184
+ *
185
+ * @param left First complete key.
186
+ * @param right Second complete key.
187
+ * @returns Negative, zero, or positive comparison.
188
+ */
189
+ compare(left: AgentHistoryOrderKey, right: AgentHistoryOrderKey): number;
190
+ }
191
+ /**
192
+ * Builds and compares the provider-independent complete Agent history key.
193
+ */
194
+ export declare const AgentHistoryKeys: AgentHistoryKeyOperations;
195
+ export {};
196
+ //# sourceMappingURL=agent-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-history.d.ts","sourceRoot":"","sources":["../../src/entity/agent-history.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;GAIG;AACH,UAAU,mBAAmB,CAAC,EAAE;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAExD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,oBAAoB,GACpB,4BAA4B,GAC5B,sBAAsB,GACtB,sBAAsB,CAAC;AAE3B;;GAEG;AACH,UAAU,oBAAoB;IAC5B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,UAAU,4BAA4B;IACpC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,cAAc,CAAC;CACvC;AAED;;GAEG;AACH,UAAU,sBAAsB;IAC9B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB;AAED;;GAEG;AACH,UAAU,sBAAsB;IAC9B;;OAEG;IACH,QAAQ,CAAC,IAAI,EA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AAoB,CAAC;IAE1D;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,oBAAoB,GAAG,MAAM,CAAC;IAE9C;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAAC;CAC1E;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,yBAyD7B,CAAC"}
@@ -0,0 +1,136 @@
1
+ /*
2
+ * Copyright 2026, CodeMatters. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * https://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+ const minSeconds = -62135596800n;
15
+ const maxSeconds = 253402300799n;
16
+ const categoryRank = {
17
+ conversation: "0",
18
+ system: "1",
19
+ domain: "2",
20
+ };
21
+ /**
22
+ * Builds and compares the provider-independent complete Agent history key.
23
+ */
24
+ export const AgentHistoryKeys = Object.freeze({
25
+ /**
26
+ * Validates enclosed time and identity while reading the complete key.
27
+ *
28
+ * @param entry Recorded Proto oneof.
29
+ * @returns Complete key after validating the enclosed occurrence time.
30
+ */
31
+ fromEntry(entry) {
32
+ const occurredAt = entry.occurredAt;
33
+ const item = entry.item;
34
+ if (occurredAt === undefined || item.case === undefined)
35
+ throw new TypeError("Agent history requires an occurrence time and one item.");
36
+ if (item.case === "conversationRecord") {
37
+ const record = item.value;
38
+ if (record.conversation?.value === undefined || record.conversation.value.length === 0)
39
+ throw new TypeError("Conversation history requires a ConversationId.");
40
+ HistoryValidation.sameTime(occurredAt, record.occurredAt);
41
+ return { occurredAt, category: "conversation", recordId: record.id?.value ?? "" };
42
+ }
43
+ const event = item.value;
44
+ HistoryValidation.sameTime(occurredAt, event.context?.timestamp);
45
+ return {
46
+ occurredAt,
47
+ category: item.case === "systemEvent" ? "system" : "domain",
48
+ recordId: event.id?.value ?? "",
49
+ };
50
+ },
51
+ /**
52
+ * Encodes the full key for binary-collated SQL and Datastore range indexes.
53
+ *
54
+ * @param key Original complete history key.
55
+ * @returns Fixed-width reverse time, category rank, and prefix-safe UTF-8 hex ID.
56
+ */
57
+ indexValue(key) {
58
+ HistoryValidation.timestamp(key.occurredAt);
59
+ if (key.recordId.length === 0)
60
+ throw new TypeError("Agent history record ID is required.");
61
+ const seconds = (maxSeconds - key.occurredAt.seconds).toString().padStart(12, "0");
62
+ const nanos = (999999999 - key.occurredAt.nanos).toString().padStart(9, "0");
63
+ const rank = categoryRank[key.category];
64
+ if (rank === undefined)
65
+ throw new TypeError("Agent history category is required.");
66
+ const id = Utf8Ids.hex(key.recordId);
67
+ return `${seconds}${nanos}${rank}${id}!`;
68
+ },
69
+ /**
70
+ * Compares complete keys in newest-first Agent history order.
71
+ *
72
+ * @param left First complete key.
73
+ * @param right Second complete key.
74
+ * @returns Negative, zero, or positive key comparison.
75
+ */
76
+ compare(left, right) {
77
+ const first = this.indexValue(left);
78
+ const second = this.indexValue(right);
79
+ return first < second ? -1 : first > second ? 1 : 0;
80
+ },
81
+ });
82
+ /**
83
+ * Encodes valid Unicode IDs as unsigned UTF-8 byte hex for prefix-safe keys.
84
+ */
85
+ const Utf8Ids = Object.freeze({
86
+ /**
87
+ * Encodes an identifier without locale collation or platform byte APIs.
88
+ *
89
+ * @param value Existing immutable record ID.
90
+ * @returns Lowercase two-digit hex for every UTF-8 byte.
91
+ */
92
+ hex(value) {
93
+ const encoded = encodeURIComponent(value);
94
+ let result = "";
95
+ for (let index = 0; index < encoded.length; index += 1) {
96
+ if (encoded[index] === "%") {
97
+ result += encoded.slice(index + 1, index + 3).toLowerCase();
98
+ index += 2;
99
+ }
100
+ else {
101
+ result += encoded.charCodeAt(index).toString(16).padStart(2, "0");
102
+ }
103
+ }
104
+ return result;
105
+ },
106
+ });
107
+ /**
108
+ * Validates original occurrence times before indexing.
109
+ */
110
+ const HistoryValidation = Object.freeze({
111
+ /**
112
+ * Verifies an enclosed occurrence time.
113
+ *
114
+ * @param wrapper History wrapper occurrence time.
115
+ * @param enclosed Enclosed record or Event occurrence time.
116
+ */
117
+ sameTime(wrapper, enclosed) {
118
+ this.timestamp(wrapper);
119
+ if (wrapper.seconds !== enclosed?.seconds || wrapper.nanos !== enclosed.nanos)
120
+ throw new TypeError("Agent history wrapper time must equal its recorded occurrence time.");
121
+ },
122
+ /**
123
+ * Checks the complete Protobuf Timestamp range.
124
+ *
125
+ * @param value Original occurrence time.
126
+ */
127
+ timestamp(value) {
128
+ if (typeof value.seconds !== "bigint" ||
129
+ value.seconds < minSeconds ||
130
+ value.seconds > maxSeconds)
131
+ throw new RangeError("Agent history timestamp seconds are outside the Protobuf range.");
132
+ if (!Number.isInteger(value.nanos) || value.nanos < 0 || value.nanos > 999999999)
133
+ throw new RangeError("Agent history timestamp nanoseconds are outside the Protobuf range.");
134
+ },
135
+ });
136
+ //# sourceMappingURL=agent-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-history.js","sourceRoot":"","sources":["../../src/entity/agent-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAkMH,MAAM,UAAU,GAAG,CAAC,YAAY,CAAC;AACjC,MAAM,UAAU,GAAG,aAAa,CAAC;AACjC,MAAM,YAAY,GAAiD;IACjE,YAAY,EAAE,GAAG;IACjB,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;CACZ,CAAC;AAgCF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA8B,MAAM,CAAC,MAAM,CAAC;IACvE;;;;;OAKG;IACH,SAAS,CAAC,KAAwB;QAChC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,I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