@red-codes/events 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/dist/bus.d.ts +24 -0
- package/dist/bus.d.ts.map +1 -0
- package/dist/bus.js +64 -0
- package/dist/bus.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.ts +72 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +374 -0
- package/dist/schema.js.map +1 -0
- package/dist/session-context.d.ts +57 -0
- package/dist/session-context.d.ts.map +1 -0
- package/dist/session-context.js +155 -0
- package/dist/session-context.js.map +1 -0
- package/dist/store.d.ts +7 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +64 -0
- package/dist/store.js.map +1 -0
- package/package.json +37 -0
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 the 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 the 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 any 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
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Jared Pleva
|
|
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/bus.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventBus — Strongly typed publish/subscribe event system.
|
|
3
|
+
*
|
|
4
|
+
* The backbone of AgentGuard. All modules communicate through events,
|
|
5
|
+
* never by direct coupling. Generic over an event map for full
|
|
6
|
+
* type safety at compile time.
|
|
7
|
+
*
|
|
8
|
+
* Pattern: synchronous dispatch, no middleware, no async.
|
|
9
|
+
* Returns an unsubscribe function from on().
|
|
10
|
+
*/
|
|
11
|
+
export declare class EventBus<T extends Record<string, any>> {
|
|
12
|
+
private readonly listeners;
|
|
13
|
+
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
14
|
+
on<K extends keyof T>(event: K, handler: (payload: T[K]) => void): () => void;
|
|
15
|
+
/** Remove a specific handler for an event. */
|
|
16
|
+
off<K extends keyof T>(event: K, handler: (payload: T[K]) => void): void;
|
|
17
|
+
/** Emit an event synchronously to all subscribers. */
|
|
18
|
+
emit<K extends keyof T>(event: K, payload?: T[K]): void;
|
|
19
|
+
/** Remove all listeners for all events. */
|
|
20
|
+
clear(): void;
|
|
21
|
+
/** Get the count of listeners for a specific event. */
|
|
22
|
+
listenerCount<K extends keyof T>(event: K): number;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bus.d.ts","sourceRoot":"","sources":["../src/bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,qBAAa,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACjD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuD;IAEjF,8DAA8D;IAC9D,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAmB7E,8CAA8C;IAC9C,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAUxE,sDAAsD;IACtD,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAQvD,2CAA2C;IAC3C,KAAK,IAAI,IAAI;IAIb,uDAAuD;IACvD,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM;CAGnD"}
|
package/dist/bus.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventBus — Strongly typed publish/subscribe event system.
|
|
3
|
+
*
|
|
4
|
+
* The backbone of AgentGuard. All modules communicate through events,
|
|
5
|
+
* never by direct coupling. Generic over an event map for full
|
|
6
|
+
* type safety at compile time.
|
|
7
|
+
*
|
|
8
|
+
* Pattern: synchronous dispatch, no middleware, no async.
|
|
9
|
+
* Returns an unsubscribe function from on().
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
export class EventBus {
|
|
13
|
+
listeners = new Map();
|
|
14
|
+
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
15
|
+
on(event, handler) {
|
|
16
|
+
let arr = this.listeners.get(event);
|
|
17
|
+
if (!arr) {
|
|
18
|
+
arr = [];
|
|
19
|
+
this.listeners.set(event, arr);
|
|
20
|
+
}
|
|
21
|
+
arr.push(handler);
|
|
22
|
+
return () => {
|
|
23
|
+
const list = this.listeners.get(event);
|
|
24
|
+
if (!list)
|
|
25
|
+
return;
|
|
26
|
+
const idx = list.indexOf(handler);
|
|
27
|
+
if (idx !== -1)
|
|
28
|
+
list.splice(idx, 1);
|
|
29
|
+
if (list.length === 0) {
|
|
30
|
+
this.listeners.delete(event);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Remove a specific handler for an event. */
|
|
35
|
+
off(event, handler) {
|
|
36
|
+
const list = this.listeners.get(event);
|
|
37
|
+
if (!list)
|
|
38
|
+
return;
|
|
39
|
+
const idx = list.indexOf(handler);
|
|
40
|
+
if (idx !== -1)
|
|
41
|
+
list.splice(idx, 1);
|
|
42
|
+
if (list.length === 0) {
|
|
43
|
+
this.listeners.delete(event);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Emit an event synchronously to all subscribers. */
|
|
47
|
+
emit(event, payload) {
|
|
48
|
+
const list = this.listeners.get(event);
|
|
49
|
+
if (!list)
|
|
50
|
+
return;
|
|
51
|
+
for (const handler of [...list]) {
|
|
52
|
+
handler(payload);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Remove all listeners for all events. */
|
|
56
|
+
clear() {
|
|
57
|
+
this.listeners.clear();
|
|
58
|
+
}
|
|
59
|
+
/** Get the count of listeners for a specific event. */
|
|
60
|
+
listenerCount(event) {
|
|
61
|
+
return this.listeners.get(event)?.length ?? 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=bus.js.map
|
package/dist/bus.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bus.js","sourceRoot":"","sources":["../src/bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8DAA8D;AAC9D,MAAM,OAAO,QAAQ;IACF,SAAS,GAAG,IAAI,GAAG,EAA4C,CAAC;IAEjF,8DAA8D;IAC9D,EAAE,CAAoB,KAAQ,EAAE,OAAgC;QAC9D,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,GAAG,GAAG,EAAE,CAAC;YACT,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACjC,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,OAAmC,CAAC,CAAC;QAE9C,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACvC,IAAI,CAAC,IAAI;gBAAE,OAAO;YAClB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAmC,CAAC,CAAC;YAC9D,IAAI,GAAG,KAAK,CAAC,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACpC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACtB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IAED,8CAA8C;IAC9C,GAAG,CAAoB,KAAQ,EAAE,OAAgC;QAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAmC,CAAC,CAAC;QAC9D,IAAI,GAAG,KAAK,CAAC,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACpC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,sDAAsD;IACtD,IAAI,CAAoB,KAAQ,EAAE,OAAc;QAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,KAAK,MAAM,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;YAC/B,OAAmC,CAAC,OAAe,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,2CAA2C;IAC3C,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,uDAAuD;IACvD,aAAa,CAAoB,KAAQ;QACvC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IAChD,CAAC;CACF"}
|
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,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { EventKind, DomainEvent, ValidationResult } from '@red-codes/core';
|
|
2
|
+
export declare const ERROR_OBSERVED: EventKind;
|
|
3
|
+
export declare const BUG_CLASSIFIED: EventKind;
|
|
4
|
+
export declare const ENCOUNTER_STARTED: EventKind;
|
|
5
|
+
export declare const MOVE_USED: EventKind;
|
|
6
|
+
export declare const DAMAGE_DEALT: EventKind;
|
|
7
|
+
export declare const HEALING_APPLIED: EventKind;
|
|
8
|
+
export declare const PASSIVE_ACTIVATED: EventKind;
|
|
9
|
+
export declare const BUGMON_FAINTED: EventKind;
|
|
10
|
+
export declare const CACHE_ATTEMPTED: EventKind;
|
|
11
|
+
export declare const CACHE_SUCCESS: EventKind;
|
|
12
|
+
export declare const BATTLE_ENDED: EventKind;
|
|
13
|
+
export declare const ACTIVITY_RECORDED: EventKind;
|
|
14
|
+
export declare const EVOLUTION_TRIGGERED: EventKind;
|
|
15
|
+
export declare const STATE_CHANGED: EventKind;
|
|
16
|
+
export declare const RUN_STARTED: EventKind;
|
|
17
|
+
export declare const RUN_ENDED: EventKind;
|
|
18
|
+
export declare const CHECKPOINT_REACHED: EventKind;
|
|
19
|
+
export declare const POLICY_DENIED: EventKind;
|
|
20
|
+
export declare const UNAUTHORIZED_ACTION: EventKind;
|
|
21
|
+
export declare const INVARIANT_VIOLATION: EventKind;
|
|
22
|
+
export declare const BLAST_RADIUS_EXCEEDED: EventKind;
|
|
23
|
+
export declare const MERGE_GUARD_FAILURE: EventKind;
|
|
24
|
+
export declare const EVIDENCE_PACK_GENERATED: EventKind;
|
|
25
|
+
export declare const ACTION_REQUESTED: EventKind;
|
|
26
|
+
export declare const ACTION_ALLOWED: EventKind;
|
|
27
|
+
export declare const ACTION_DENIED: EventKind;
|
|
28
|
+
export declare const ACTION_ESCALATED: EventKind;
|
|
29
|
+
export declare const ACTION_EXECUTED: EventKind;
|
|
30
|
+
export declare const ACTION_FAILED: EventKind;
|
|
31
|
+
export declare const DECISION_RECORDED: EventKind;
|
|
32
|
+
export declare const POLICY_COMPOSED: EventKind;
|
|
33
|
+
export declare const POLICY_TRACE_RECORDED: EventKind;
|
|
34
|
+
export declare const SIMULATION_COMPLETED: EventKind;
|
|
35
|
+
export declare const PIPELINE_STARTED: EventKind;
|
|
36
|
+
export declare const STAGE_COMPLETED: EventKind;
|
|
37
|
+
export declare const STAGE_FAILED: EventKind;
|
|
38
|
+
export declare const PIPELINE_COMPLETED: EventKind;
|
|
39
|
+
export declare const PIPELINE_FAILED: EventKind;
|
|
40
|
+
export declare const FILE_SCOPE_VIOLATION: EventKind;
|
|
41
|
+
export declare const FILE_SAVED: EventKind;
|
|
42
|
+
export declare const TEST_COMPLETED: EventKind;
|
|
43
|
+
export declare const BUILD_COMPLETED: EventKind;
|
|
44
|
+
export declare const COMMIT_CREATED: EventKind;
|
|
45
|
+
export declare const CODE_REVIEWED: EventKind;
|
|
46
|
+
export declare const DEPLOY_COMPLETED: EventKind;
|
|
47
|
+
export declare const LINT_COMPLETED: EventKind;
|
|
48
|
+
export declare const TOKEN_OPTIMIZATION_APPLIED: EventKind;
|
|
49
|
+
export declare const HEARTBEAT_EMITTED: EventKind;
|
|
50
|
+
export declare const HEARTBEAT_MISSED: EventKind;
|
|
51
|
+
export declare const AGENT_UNRESPONSIVE: EventKind;
|
|
52
|
+
export declare const HOOK_INTEGRITY_VERIFIED: EventKind;
|
|
53
|
+
export declare const HOOK_INTEGRITY_FAILED: EventKind;
|
|
54
|
+
export declare const POLICY_TRUST_VERIFIED: EventKind;
|
|
55
|
+
export declare const POLICY_TRUST_DENIED: EventKind;
|
|
56
|
+
export declare const ADOPTION_ANALYZED: EventKind;
|
|
57
|
+
export declare const ADOPTION_ANALYSIS_FAILED: EventKind;
|
|
58
|
+
export declare const DENIAL_PATTERN_DETECTED: EventKind;
|
|
59
|
+
export declare const ALL_EVENT_KINDS: Set<string>;
|
|
60
|
+
/** Reset the event counter. Exported for test determinism. */
|
|
61
|
+
export declare function resetEventCounter(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Validate an event object against its schema.
|
|
64
|
+
*/
|
|
65
|
+
export declare function validateEvent(event: Record<string, unknown>): ValidationResult;
|
|
66
|
+
/**
|
|
67
|
+
* Create a canonical domain event.
|
|
68
|
+
* Validates that the kind is known and required fields are present.
|
|
69
|
+
* Assigns a unique ID and content fingerprint.
|
|
70
|
+
*/
|
|
71
|
+
export declare function createEvent(kind: EventKind, data?: Record<string, unknown>): DomainEvent;
|
|
72
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAe,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAK7F,eAAO,MAAM,cAAc,EAAE,SAA2B,CAAC;AACzD,eAAO,MAAM,cAAc,EAAE,SAA2B,CAAC;AAGzD,eAAO,MAAM,iBAAiB,EAAE,SAA+B,CAAC;AAChE,eAAO,MAAM,SAAS,EAAE,SAAuB,CAAC;AAChD,eAAO,MAAM,YAAY,EAAE,SAA0B,CAAC;AACtD,eAAO,MAAM,eAAe,EAAE,SAA6B,CAAC;AAC5D,eAAO,MAAM,iBAAiB,EAAE,SAA+B,CAAC;AAChE,eAAO,MAAM,cAAc,EAAE,SAA4B,CAAC;AAC1D,eAAO,MAAM,eAAe,EAAE,SAA6B,CAAC;AAC5D,eAAO,MAAM,aAAa,EAAE,SAA2B,CAAC;AACxD,eAAO,MAAM,YAAY,EAAE,SAA0B,CAAC;AAGtD,eAAO,MAAM,iBAAiB,EAAE,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domain events for AgentGuard
|
|
2
|
+
// All systems emit and consume these event types.
|
|
3
|
+
// No DOM, no Node.js APIs — pure data definitions.
|
|
4
|
+
import { simpleHash } from '@red-codes/core';
|
|
5
|
+
// --- Event Kinds ---
|
|
6
|
+
// Ingestion pipeline
|
|
7
|
+
export const ERROR_OBSERVED = 'ErrorObserved';
|
|
8
|
+
export const BUG_CLASSIFIED = 'BugClassified';
|
|
9
|
+
// Battle lifecycle — values match existing battle-core.js event strings
|
|
10
|
+
export const ENCOUNTER_STARTED = 'ENCOUNTER_STARTED';
|
|
11
|
+
export const MOVE_USED = 'MOVE_USED';
|
|
12
|
+
export const DAMAGE_DEALT = 'DAMAGE_DEALT';
|
|
13
|
+
export const HEALING_APPLIED = 'HEALING_APPLIED';
|
|
14
|
+
export const PASSIVE_ACTIVATED = 'PASSIVE_ACTIVATED';
|
|
15
|
+
export const BUGMON_FAINTED = 'BUGMON_FAINTED';
|
|
16
|
+
export const CACHE_ATTEMPTED = 'CACHE_ATTEMPTED';
|
|
17
|
+
export const CACHE_SUCCESS = 'CACHE_SUCCESS';
|
|
18
|
+
export const BATTLE_ENDED = 'BATTLE_ENDED';
|
|
19
|
+
// Progression
|
|
20
|
+
export const ACTIVITY_RECORDED = 'ActivityRecorded';
|
|
21
|
+
export const EVOLUTION_TRIGGERED = 'EvolutionTriggered';
|
|
22
|
+
// Session
|
|
23
|
+
export const STATE_CHANGED = 'StateChanged';
|
|
24
|
+
export const RUN_STARTED = 'RunStarted';
|
|
25
|
+
export const RUN_ENDED = 'RunEnded';
|
|
26
|
+
export const CHECKPOINT_REACHED = 'CheckpointReached';
|
|
27
|
+
// Governance
|
|
28
|
+
export const POLICY_DENIED = 'PolicyDenied';
|
|
29
|
+
export const UNAUTHORIZED_ACTION = 'UnauthorizedAction';
|
|
30
|
+
export const INVARIANT_VIOLATION = 'InvariantViolation';
|
|
31
|
+
export const BLAST_RADIUS_EXCEEDED = 'BlastRadiusExceeded';
|
|
32
|
+
export const MERGE_GUARD_FAILURE = 'MergeGuardFailure';
|
|
33
|
+
export const EVIDENCE_PACK_GENERATED = 'EvidencePackGenerated';
|
|
34
|
+
// Reference Monitor (Agent Action Boundary)
|
|
35
|
+
export const ACTION_REQUESTED = 'ActionRequested';
|
|
36
|
+
export const ACTION_ALLOWED = 'ActionAllowed';
|
|
37
|
+
export const ACTION_DENIED = 'ActionDenied';
|
|
38
|
+
export const ACTION_ESCALATED = 'ActionEscalated';
|
|
39
|
+
export const ACTION_EXECUTED = 'ActionExecuted';
|
|
40
|
+
export const ACTION_FAILED = 'ActionFailed';
|
|
41
|
+
// Decision Records
|
|
42
|
+
export const DECISION_RECORDED = 'DecisionRecorded';
|
|
43
|
+
// Policy Composition
|
|
44
|
+
export const POLICY_COMPOSED = 'PolicyComposed';
|
|
45
|
+
// Policy Traces
|
|
46
|
+
export const POLICY_TRACE_RECORDED = 'PolicyTraceRecorded';
|
|
47
|
+
// Simulation
|
|
48
|
+
export const SIMULATION_COMPLETED = 'SimulationCompleted';
|
|
49
|
+
// Pipeline
|
|
50
|
+
export const PIPELINE_STARTED = 'PipelineStarted';
|
|
51
|
+
export const STAGE_COMPLETED = 'StageCompleted';
|
|
52
|
+
export const STAGE_FAILED = 'StageFailed';
|
|
53
|
+
export const PIPELINE_COMPLETED = 'PipelineCompleted';
|
|
54
|
+
export const PIPELINE_FAILED = 'PipelineFailed';
|
|
55
|
+
export const FILE_SCOPE_VIOLATION = 'FileScopeViolation';
|
|
56
|
+
// Developer Signals
|
|
57
|
+
export const FILE_SAVED = 'FileSaved';
|
|
58
|
+
export const TEST_COMPLETED = 'TestCompleted';
|
|
59
|
+
export const BUILD_COMPLETED = 'BuildCompleted';
|
|
60
|
+
export const COMMIT_CREATED = 'CommitCreated';
|
|
61
|
+
export const CODE_REVIEWED = 'CodeReviewed';
|
|
62
|
+
export const DEPLOY_COMPLETED = 'DeployCompleted';
|
|
63
|
+
export const LINT_COMPLETED = 'LintCompleted';
|
|
64
|
+
// Token Optimization
|
|
65
|
+
export const TOKEN_OPTIMIZATION_APPLIED = 'TokenOptimizationApplied';
|
|
66
|
+
// Agent Liveness
|
|
67
|
+
export const HEARTBEAT_EMITTED = 'HeartbeatEmitted';
|
|
68
|
+
export const HEARTBEAT_MISSED = 'HeartbeatMissed';
|
|
69
|
+
export const AGENT_UNRESPONSIVE = 'AgentUnresponsive';
|
|
70
|
+
// Integrity & Trust
|
|
71
|
+
export const HOOK_INTEGRITY_VERIFIED = 'HookIntegrityVerified';
|
|
72
|
+
export const HOOK_INTEGRITY_FAILED = 'HookIntegrityFailed';
|
|
73
|
+
export const POLICY_TRUST_VERIFIED = 'PolicyTrustVerified';
|
|
74
|
+
export const POLICY_TRUST_DENIED = 'PolicyTrustDenied';
|
|
75
|
+
// Adoption Analytics
|
|
76
|
+
export const ADOPTION_ANALYZED = 'AdoptionAnalyzed';
|
|
77
|
+
export const ADOPTION_ANALYSIS_FAILED = 'AdoptionAnalysisFailed';
|
|
78
|
+
// Denial Learning
|
|
79
|
+
export const DENIAL_PATTERN_DETECTED = 'DenialPatternDetected';
|
|
80
|
+
// --- Event Schemas ---
|
|
81
|
+
const EVENT_SCHEMAS = {
|
|
82
|
+
[ERROR_OBSERVED]: {
|
|
83
|
+
required: ['message'],
|
|
84
|
+
optional: ['source', 'errorType', 'file', 'line', 'severity', 'fingerprint', 'bugEvent'],
|
|
85
|
+
},
|
|
86
|
+
[BUG_CLASSIFIED]: {
|
|
87
|
+
required: ['severity', 'speciesId'],
|
|
88
|
+
optional: ['fingerprint', 'name'],
|
|
89
|
+
},
|
|
90
|
+
[ENCOUNTER_STARTED]: {
|
|
91
|
+
required: ['enemy'],
|
|
92
|
+
optional: ['playerLevel'],
|
|
93
|
+
},
|
|
94
|
+
[MOVE_USED]: {
|
|
95
|
+
required: ['move', 'attacker'],
|
|
96
|
+
optional: ['defender'],
|
|
97
|
+
},
|
|
98
|
+
[DAMAGE_DEALT]: {
|
|
99
|
+
required: ['amount', 'target'],
|
|
100
|
+
optional: ['effectiveness'],
|
|
101
|
+
},
|
|
102
|
+
[HEALING_APPLIED]: {
|
|
103
|
+
required: ['amount', 'target'],
|
|
104
|
+
optional: [],
|
|
105
|
+
},
|
|
106
|
+
[PASSIVE_ACTIVATED]: {
|
|
107
|
+
required: ['passive', 'owner'],
|
|
108
|
+
optional: [],
|
|
109
|
+
},
|
|
110
|
+
[BUGMON_FAINTED]: {
|
|
111
|
+
required: ['bugmon'],
|
|
112
|
+
optional: [],
|
|
113
|
+
},
|
|
114
|
+
[CACHE_ATTEMPTED]: {
|
|
115
|
+
required: ['target'],
|
|
116
|
+
optional: [],
|
|
117
|
+
},
|
|
118
|
+
[CACHE_SUCCESS]: {
|
|
119
|
+
required: ['target'],
|
|
120
|
+
optional: [],
|
|
121
|
+
},
|
|
122
|
+
[BATTLE_ENDED]: {
|
|
123
|
+
required: ['result'],
|
|
124
|
+
optional: [],
|
|
125
|
+
},
|
|
126
|
+
[ACTIVITY_RECORDED]: {
|
|
127
|
+
required: ['activity'],
|
|
128
|
+
optional: [],
|
|
129
|
+
},
|
|
130
|
+
[EVOLUTION_TRIGGERED]: {
|
|
131
|
+
required: ['from', 'to'],
|
|
132
|
+
optional: [],
|
|
133
|
+
},
|
|
134
|
+
[STATE_CHANGED]: {
|
|
135
|
+
required: ['from', 'to'],
|
|
136
|
+
optional: [
|
|
137
|
+
'trigger',
|
|
138
|
+
'totalDenials',
|
|
139
|
+
'totalViolations',
|
|
140
|
+
'denialThreshold',
|
|
141
|
+
'violationThreshold',
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
[RUN_STARTED]: {
|
|
145
|
+
required: ['runId'],
|
|
146
|
+
optional: ['seed', 'sessionStart', 'playerLevel'],
|
|
147
|
+
},
|
|
148
|
+
[RUN_ENDED]: {
|
|
149
|
+
required: ['runId', 'result'],
|
|
150
|
+
optional: ['score', 'encounterCount', 'duration', 'defeatedBosses'],
|
|
151
|
+
},
|
|
152
|
+
[CHECKPOINT_REACHED]: {
|
|
153
|
+
required: ['runId', 'checkpoint'],
|
|
154
|
+
optional: ['encounterCount', 'playerHp', 'score'],
|
|
155
|
+
},
|
|
156
|
+
[POLICY_DENIED]: {
|
|
157
|
+
required: ['policy', 'action', 'reason'],
|
|
158
|
+
optional: ['agentId', 'file', 'line', 'metadata'],
|
|
159
|
+
},
|
|
160
|
+
[UNAUTHORIZED_ACTION]: {
|
|
161
|
+
required: ['action', 'reason'],
|
|
162
|
+
optional: ['agentId', 'scope', 'file', 'line', 'metadata'],
|
|
163
|
+
},
|
|
164
|
+
[INVARIANT_VIOLATION]: {
|
|
165
|
+
required: ['invariant', 'expected', 'actual'],
|
|
166
|
+
optional: ['file', 'line', 'metadata'],
|
|
167
|
+
},
|
|
168
|
+
[BLAST_RADIUS_EXCEEDED]: {
|
|
169
|
+
required: ['filesAffected', 'limit'],
|
|
170
|
+
optional: ['files', 'action', 'metadata'],
|
|
171
|
+
},
|
|
172
|
+
[MERGE_GUARD_FAILURE]: {
|
|
173
|
+
required: ['branch', 'reason'],
|
|
174
|
+
optional: ['protectedBranches', 'metadata'],
|
|
175
|
+
},
|
|
176
|
+
[EVIDENCE_PACK_GENERATED]: {
|
|
177
|
+
required: ['packId', 'eventIds'],
|
|
178
|
+
optional: ['summary', 'metadata'],
|
|
179
|
+
},
|
|
180
|
+
[ACTION_REQUESTED]: {
|
|
181
|
+
required: ['actionType', 'target', 'justification'],
|
|
182
|
+
optional: ['actionId', 'agentId', 'metadata'],
|
|
183
|
+
},
|
|
184
|
+
[ACTION_ALLOWED]: {
|
|
185
|
+
required: ['actionType', 'target', 'capability'],
|
|
186
|
+
optional: ['actionId', 'reason', 'policyHash', 'metadata'],
|
|
187
|
+
},
|
|
188
|
+
[ACTION_DENIED]: {
|
|
189
|
+
required: ['actionType', 'target', 'reason'],
|
|
190
|
+
optional: ['actionId', 'policyHash', 'metadata'],
|
|
191
|
+
},
|
|
192
|
+
[ACTION_ESCALATED]: {
|
|
193
|
+
required: ['actionType', 'target', 'reason'],
|
|
194
|
+
optional: ['actionId', 'policyHash', 'metadata'],
|
|
195
|
+
},
|
|
196
|
+
[ACTION_EXECUTED]: {
|
|
197
|
+
required: ['actionType', 'target', 'result'],
|
|
198
|
+
optional: ['actionId', 'duration', 'metadata'],
|
|
199
|
+
},
|
|
200
|
+
[ACTION_FAILED]: {
|
|
201
|
+
required: ['actionType', 'target', 'error'],
|
|
202
|
+
optional: ['actionId', 'duration', 'metadata'],
|
|
203
|
+
},
|
|
204
|
+
[DECISION_RECORDED]: {
|
|
205
|
+
required: ['recordId', 'outcome', 'actionType'],
|
|
206
|
+
optional: ['target', 'reason', 'metadata'],
|
|
207
|
+
},
|
|
208
|
+
[POLICY_COMPOSED]: {
|
|
209
|
+
required: ['policyCount', 'totalRules', 'sources'],
|
|
210
|
+
optional: ['layers', 'metadata'],
|
|
211
|
+
},
|
|
212
|
+
[POLICY_TRACE_RECORDED]: {
|
|
213
|
+
required: ['actionType', 'decision', 'totalRulesChecked'],
|
|
214
|
+
optional: ['target', 'phaseThatMatched', 'rulesEvaluated', 'durationMs', 'metadata'],
|
|
215
|
+
},
|
|
216
|
+
[SIMULATION_COMPLETED]: {
|
|
217
|
+
required: ['simulatorId', 'riskLevel', 'blastRadius'],
|
|
218
|
+
optional: ['predictedChanges', 'durationMs', 'metadata'],
|
|
219
|
+
},
|
|
220
|
+
[PIPELINE_STARTED]: {
|
|
221
|
+
required: ['runId', 'task'],
|
|
222
|
+
optional: ['agentRoles', 'stageCount'],
|
|
223
|
+
},
|
|
224
|
+
[STAGE_COMPLETED]: {
|
|
225
|
+
required: ['runId', 'stageId', 'status'],
|
|
226
|
+
optional: ['duration', 'outputKeys', 'agentRole'],
|
|
227
|
+
},
|
|
228
|
+
[STAGE_FAILED]: {
|
|
229
|
+
required: ['runId', 'stageId', 'errors'],
|
|
230
|
+
optional: ['agentRole', 'duration'],
|
|
231
|
+
},
|
|
232
|
+
[PIPELINE_COMPLETED]: {
|
|
233
|
+
required: ['runId', 'result'],
|
|
234
|
+
optional: ['duration', 'stagesCompleted', 'task'],
|
|
235
|
+
},
|
|
236
|
+
[PIPELINE_FAILED]: {
|
|
237
|
+
required: ['runId', 'failedStage', 'errors'],
|
|
238
|
+
optional: ['duration', 'stagesCompleted', 'task'],
|
|
239
|
+
},
|
|
240
|
+
[FILE_SCOPE_VIOLATION]: {
|
|
241
|
+
required: ['runId', 'files'],
|
|
242
|
+
optional: ['allowedFiles', 'agentRole'],
|
|
243
|
+
},
|
|
244
|
+
[FILE_SAVED]: {
|
|
245
|
+
required: ['file'],
|
|
246
|
+
optional: ['language', 'linesChanged'],
|
|
247
|
+
},
|
|
248
|
+
[TEST_COMPLETED]: {
|
|
249
|
+
required: ['result'],
|
|
250
|
+
optional: ['suite', 'duration', 'passed', 'failed', 'total'],
|
|
251
|
+
},
|
|
252
|
+
[BUILD_COMPLETED]: {
|
|
253
|
+
required: ['result'],
|
|
254
|
+
optional: ['duration', 'tool', 'exitCode'],
|
|
255
|
+
},
|
|
256
|
+
[COMMIT_CREATED]: {
|
|
257
|
+
required: ['hash'],
|
|
258
|
+
optional: ['message', 'filesChanged', 'additions', 'deletions'],
|
|
259
|
+
},
|
|
260
|
+
[CODE_REVIEWED]: {
|
|
261
|
+
required: ['action'],
|
|
262
|
+
optional: ['prId', 'file', 'comment'],
|
|
263
|
+
},
|
|
264
|
+
[DEPLOY_COMPLETED]: {
|
|
265
|
+
required: ['result'],
|
|
266
|
+
optional: ['environment', 'duration', 'version'],
|
|
267
|
+
},
|
|
268
|
+
[LINT_COMPLETED]: {
|
|
269
|
+
required: ['result'],
|
|
270
|
+
optional: ['tool', 'errors', 'warnings', 'fixed'],
|
|
271
|
+
},
|
|
272
|
+
[TOKEN_OPTIMIZATION_APPLIED]: {
|
|
273
|
+
required: ['tool', 'command'],
|
|
274
|
+
optional: ['originalCommand', 'rewrittenCommand', 'optimizer', 'metadata'],
|
|
275
|
+
},
|
|
276
|
+
[HEARTBEAT_EMITTED]: {
|
|
277
|
+
required: ['agentId'],
|
|
278
|
+
optional: ['sequenceNumber', 'uptimeMs', 'metadata'],
|
|
279
|
+
},
|
|
280
|
+
[HEARTBEAT_MISSED]: {
|
|
281
|
+
required: ['agentId', 'missedCount'],
|
|
282
|
+
optional: ['lastHeartbeatAt', 'expectedIntervalMs', 'metadata'],
|
|
283
|
+
},
|
|
284
|
+
[AGENT_UNRESPONSIVE]: {
|
|
285
|
+
required: ['agentId', 'missedCount', 'threshold'],
|
|
286
|
+
optional: ['lastHeartbeatAt', 'metadata'],
|
|
287
|
+
},
|
|
288
|
+
[HOOK_INTEGRITY_VERIFIED]: {
|
|
289
|
+
required: ['settingsPath', 'hash'],
|
|
290
|
+
optional: [],
|
|
291
|
+
},
|
|
292
|
+
[HOOK_INTEGRITY_FAILED]: {
|
|
293
|
+
required: ['settingsPath', 'reason'],
|
|
294
|
+
optional: ['expectedHash', 'actualHash', 'command'],
|
|
295
|
+
},
|
|
296
|
+
[POLICY_TRUST_VERIFIED]: {
|
|
297
|
+
required: ['policyPath', 'status'],
|
|
298
|
+
optional: ['riskFlags'],
|
|
299
|
+
},
|
|
300
|
+
[POLICY_TRUST_DENIED]: {
|
|
301
|
+
required: ['policyPath', 'reason'],
|
|
302
|
+
optional: ['riskFlags'],
|
|
303
|
+
},
|
|
304
|
+
[ADOPTION_ANALYZED]: {
|
|
305
|
+
required: ['sessionId', 'adoptionPct', 'totalToolCalls', 'governedActions'],
|
|
306
|
+
optional: ['ungoverned', 'bypassAttempts'],
|
|
307
|
+
},
|
|
308
|
+
[ADOPTION_ANALYSIS_FAILED]: {
|
|
309
|
+
required: ['sessionId', 'error'],
|
|
310
|
+
optional: [],
|
|
311
|
+
},
|
|
312
|
+
[DENIAL_PATTERN_DETECTED]: {
|
|
313
|
+
required: ['actionType', 'occurrences', 'confidence'],
|
|
314
|
+
optional: ['invariant', 'policyRule', 'suggestion', 'resolution'],
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
export const ALL_EVENT_KINDS = new Set(Object.keys(EVENT_SCHEMAS));
|
|
318
|
+
// --- Event Factory ---
|
|
319
|
+
let eventCounter = 0;
|
|
320
|
+
/** Reset the event counter. Exported for test determinism. */
|
|
321
|
+
export function resetEventCounter() {
|
|
322
|
+
eventCounter = 0;
|
|
323
|
+
}
|
|
324
|
+
function generateEventId(timestamp) {
|
|
325
|
+
return `evt_${timestamp}_${++eventCounter}`;
|
|
326
|
+
}
|
|
327
|
+
function fingerprintEvent(kind, data) {
|
|
328
|
+
const keys = Object.keys(data).sort();
|
|
329
|
+
const parts = keys.map((k) => `${k}=${JSON.stringify(data[k])}`);
|
|
330
|
+
return simpleHash(`${kind}:${parts.join(',')}`);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Validate an event object against its schema.
|
|
334
|
+
*/
|
|
335
|
+
export function validateEvent(event) {
|
|
336
|
+
const errors = [];
|
|
337
|
+
if (!event || typeof event !== 'object') {
|
|
338
|
+
return { valid: false, errors: ['Event must be a non-null object'] };
|
|
339
|
+
}
|
|
340
|
+
if (!event.kind) {
|
|
341
|
+
errors.push('Event is missing required field: kind');
|
|
342
|
+
return { valid: false, errors };
|
|
343
|
+
}
|
|
344
|
+
const schema = EVENT_SCHEMAS[event.kind];
|
|
345
|
+
if (!schema) {
|
|
346
|
+
errors.push(`Unknown event kind: ${event.kind}`);
|
|
347
|
+
return { valid: false, errors };
|
|
348
|
+
}
|
|
349
|
+
for (const field of schema.required) {
|
|
350
|
+
if (event[field] === undefined) {
|
|
351
|
+
errors.push(`Event "${event.kind}" is missing required field: ${field}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return { valid: errors.length === 0, errors };
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Create a canonical domain event.
|
|
358
|
+
* Validates that the kind is known and required fields are present.
|
|
359
|
+
* Assigns a unique ID and content fingerprint.
|
|
360
|
+
*/
|
|
361
|
+
export function createEvent(kind, data = {}) {
|
|
362
|
+
const timestamp = Date.now();
|
|
363
|
+
const event = { kind, timestamp, ...data };
|
|
364
|
+
const { valid, errors } = validateEvent(event);
|
|
365
|
+
if (!valid) {
|
|
366
|
+
throw new Error(`Invalid event: ${errors.join('; ')}`);
|
|
367
|
+
}
|
|
368
|
+
event.id = generateEventId(timestamp);
|
|
369
|
+
if (event.fingerprint === undefined) {
|
|
370
|
+
event.fingerprint = fingerprintEvent(kind, data);
|
|
371
|
+
}
|
|
372
|
+
return event;
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,kDAAkD;AAClD,mDAAmD;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,sBAAsB;AACtB,qBAAqB;AACrB,MAAM,CAAC,MAAM,cAAc,GAAc,eAAe,CAAC;AACzD,MAAM,CAAC,MAAM,cAAc,GAAc,eAAe,CAAC;AAEzD,wEAAwE;AACxE,MAAM,CAAC,MAAM,iBAAiB,GAAc,mBAAmB,CAAC;AAChE,MAAM,CAAC,MAAM,SAAS,GAAc,WAAW,CAAC;AAChD,MAAM,CAAC,MAAM,YAAY,GAAc,cAAc,CAAC;AACtD,MAAM,CAAC,MAAM,eAAe,GAAc,iBAAiB,CAAC;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAc,mBAAmB,CAAC;AAChE,MAAM,CAAC,MAAM,cAAc,GAAc,gBAAgB,CAAC;AAC1D,MAAM,CAAC,MAAM,eAAe,GAAc,iBAAiB,CAAC;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAc,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,YAAY,GAAc,cAAc,CAAC;AAEtD,cAAc;AACd,MAAM,CAAC,MAAM,iBAAiB,GAAc,kBAAkB,CAAC;AAC/D,MAAM,CAAC,MAAM,mBAAmB,GAAc,oBAAoB,CAAC;AAEnE,U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IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAe,EAAE,OAAgC,EAAE;IAC7E,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,KAAK,GAA4B,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,CAAC;IACpE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,KAAK,CAAC,EAAE,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IACtC,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACpC,KAAK,CAAC,WAAW,GAAG,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,KAA+B,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { DomainEvent, EventStore } from '@red-codes/core';
|
|
2
|
+
/** Cumulative test state within a session */
|
|
3
|
+
export interface TestState {
|
|
4
|
+
readonly ran: boolean;
|
|
5
|
+
readonly lastResult: 'pass' | 'fail' | null;
|
|
6
|
+
readonly passed: number;
|
|
7
|
+
readonly failed: number;
|
|
8
|
+
readonly total: number;
|
|
9
|
+
readonly suites: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
/** Cumulative deploy state within a session */
|
|
12
|
+
export interface DeployState {
|
|
13
|
+
readonly triggered: boolean;
|
|
14
|
+
readonly lastResult: string | null;
|
|
15
|
+
readonly environment: string | null;
|
|
16
|
+
}
|
|
17
|
+
/** Cumulative git state within a session */
|
|
18
|
+
export interface GitState {
|
|
19
|
+
readonly commits: readonly string[];
|
|
20
|
+
readonly pushed: boolean;
|
|
21
|
+
readonly branchesCreated: readonly string[];
|
|
22
|
+
readonly branchesCheckedOut: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
/** Session-aware context — cumulative state projected from domain events */
|
|
25
|
+
export interface SessionContext {
|
|
26
|
+
readonly modifiedFiles: ReadonlySet<string>;
|
|
27
|
+
readonly deletedFiles: ReadonlySet<string>;
|
|
28
|
+
readonly testState: TestState;
|
|
29
|
+
readonly deployState: DeployState;
|
|
30
|
+
readonly gitState: GitState;
|
|
31
|
+
readonly actionCount: number;
|
|
32
|
+
readonly denialCount: number;
|
|
33
|
+
readonly violationCount: number;
|
|
34
|
+
readonly lastUpdated: number;
|
|
35
|
+
}
|
|
36
|
+
/** Incremental session context tracker */
|
|
37
|
+
export interface SessionContextTracker {
|
|
38
|
+
apply(event: DomainEvent): void;
|
|
39
|
+
snapshot(): SessionContext;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Project a SessionContext from an array of DomainEvents.
|
|
43
|
+
* Events are processed in order to build cumulative state.
|
|
44
|
+
*/
|
|
45
|
+
export declare const projectSessionContext: (events: readonly DomainEvent[]) => SessionContext;
|
|
46
|
+
/**
|
|
47
|
+
* Project a SessionContext from an EventStore.
|
|
48
|
+
* Replays all events in the store to build cumulative state.
|
|
49
|
+
*/
|
|
50
|
+
export declare const projectSessionContextFromStore: (store: EventStore) => SessionContext;
|
|
51
|
+
/**
|
|
52
|
+
* Create an incremental session context tracker.
|
|
53
|
+
* Call `apply(event)` for each new event, and `snapshot()` to get the current state.
|
|
54
|
+
* This is more efficient than re-projecting from the full event stream on every query.
|
|
55
|
+
*/
|
|
56
|
+
export declare const createSessionContextTracker: () => SessionContextTracker;
|
|
57
|
+
//# sourceMappingURL=session-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-context.d.ts","sourceRoot":"","sources":["../src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,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,QAAQ,IAAI,cAAc,CAAC;CAC5B;AAqKD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,WAAW,EAAE,KAAG,cAMtE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,GAAI,OAAO,UAAU,KAAG,cAElE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QAAO,qBAU9C,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Session-aware context tracking — cumulative state projected from the event stream.
|
|
2
|
+
// Enables policies like "deny push if no tests have been run this session"
|
|
3
|
+
// or "require review after modifying more than 10 files."
|
|
4
|
+
// No DOM, no Node.js APIs — pure domain logic.
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Factory & Helpers
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
const createMutableContext = () => ({
|
|
9
|
+
modifiedFiles: new Set(),
|
|
10
|
+
deletedFiles: new Set(),
|
|
11
|
+
testState: { ran: false, lastResult: null, passed: 0, failed: 0, total: 0, suites: [] },
|
|
12
|
+
deployState: { triggered: false, lastResult: null, environment: null },
|
|
13
|
+
gitState: { commits: [], pushed: false, branchesCreated: [], branchesCheckedOut: [] },
|
|
14
|
+
actionCount: 0,
|
|
15
|
+
denialCount: 0,
|
|
16
|
+
violationCount: 0,
|
|
17
|
+
lastUpdated: 0,
|
|
18
|
+
});
|
|
19
|
+
const freeze = (ctx) => ({
|
|
20
|
+
modifiedFiles: new Set(ctx.modifiedFiles),
|
|
21
|
+
deletedFiles: new Set(ctx.deletedFiles),
|
|
22
|
+
testState: { ...ctx.testState, suites: [...ctx.testState.suites] },
|
|
23
|
+
deployState: { ...ctx.deployState },
|
|
24
|
+
gitState: {
|
|
25
|
+
...ctx.gitState,
|
|
26
|
+
commits: [...ctx.gitState.commits],
|
|
27
|
+
branchesCreated: [...ctx.gitState.branchesCreated],
|
|
28
|
+
branchesCheckedOut: [...ctx.gitState.branchesCheckedOut],
|
|
29
|
+
},
|
|
30
|
+
actionCount: ctx.actionCount,
|
|
31
|
+
denialCount: ctx.denialCount,
|
|
32
|
+
violationCount: ctx.violationCount,
|
|
33
|
+
lastUpdated: ctx.lastUpdated,
|
|
34
|
+
});
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Event Application
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
const applyEventToContext = (ctx, event) => {
|
|
39
|
+
ctx.lastUpdated = event.timestamp;
|
|
40
|
+
switch (event.kind) {
|
|
41
|
+
case 'ActionExecuted': {
|
|
42
|
+
ctx.actionCount++;
|
|
43
|
+
const actionType = event.actionType;
|
|
44
|
+
const target = event.target;
|
|
45
|
+
if (actionType === 'file.write' && target) {
|
|
46
|
+
ctx.modifiedFiles.add(target);
|
|
47
|
+
ctx.deletedFiles.delete(target);
|
|
48
|
+
}
|
|
49
|
+
else if (actionType === 'file.delete' && target) {
|
|
50
|
+
ctx.deletedFiles.add(target);
|
|
51
|
+
ctx.modifiedFiles.delete(target);
|
|
52
|
+
}
|
|
53
|
+
else if (actionType === 'git.push') {
|
|
54
|
+
ctx.gitState.pushed = true;
|
|
55
|
+
}
|
|
56
|
+
else if (actionType === 'git.branch.create' && target) {
|
|
57
|
+
if (!ctx.gitState.branchesCreated.includes(target)) {
|
|
58
|
+
ctx.gitState.branchesCreated.push(target);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (actionType === 'git.checkout' && target) {
|
|
62
|
+
ctx.gitState.branchesCheckedOut.push(target);
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case 'ActionAllowed':
|
|
67
|
+
ctx.actionCount++;
|
|
68
|
+
break;
|
|
69
|
+
case 'ActionDenied':
|
|
70
|
+
ctx.denialCount++;
|
|
71
|
+
break;
|
|
72
|
+
case 'InvariantViolation':
|
|
73
|
+
ctx.violationCount++;
|
|
74
|
+
break;
|
|
75
|
+
case 'TestCompleted': {
|
|
76
|
+
ctx.testState.ran = true;
|
|
77
|
+
const result = event.result;
|
|
78
|
+
ctx.testState.lastResult = result === 'pass' ? 'pass' : 'fail';
|
|
79
|
+
const passed = event.passed;
|
|
80
|
+
const failed = event.failed;
|
|
81
|
+
const total = event.total;
|
|
82
|
+
if (passed !== undefined)
|
|
83
|
+
ctx.testState.passed += passed;
|
|
84
|
+
if (failed !== undefined)
|
|
85
|
+
ctx.testState.failed += failed;
|
|
86
|
+
if (total !== undefined)
|
|
87
|
+
ctx.testState.total += total;
|
|
88
|
+
const suite = event.suite;
|
|
89
|
+
if (suite && !ctx.testState.suites.includes(suite)) {
|
|
90
|
+
ctx.testState.suites.push(suite);
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case 'DeployCompleted': {
|
|
95
|
+
ctx.deployState.triggered = true;
|
|
96
|
+
ctx.deployState.lastResult = event.result ?? null;
|
|
97
|
+
ctx.deployState.environment = event.environment ?? null;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case 'CommitCreated': {
|
|
101
|
+
const hash = event.hash;
|
|
102
|
+
if (hash) {
|
|
103
|
+
ctx.gitState.commits.push(hash);
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case 'FileSaved': {
|
|
108
|
+
const file = event.file;
|
|
109
|
+
if (file) {
|
|
110
|
+
ctx.modifiedFiles.add(file);
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
default:
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Public API
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
/**
|
|
122
|
+
* Project a SessionContext from an array of DomainEvents.
|
|
123
|
+
* Events are processed in order to build cumulative state.
|
|
124
|
+
*/
|
|
125
|
+
export const projectSessionContext = (events) => {
|
|
126
|
+
const ctx = createMutableContext();
|
|
127
|
+
for (const event of events) {
|
|
128
|
+
applyEventToContext(ctx, event);
|
|
129
|
+
}
|
|
130
|
+
return freeze(ctx);
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Project a SessionContext from an EventStore.
|
|
134
|
+
* Replays all events in the store to build cumulative state.
|
|
135
|
+
*/
|
|
136
|
+
export const projectSessionContextFromStore = (store) => {
|
|
137
|
+
return projectSessionContext(store.replay());
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Create an incremental session context tracker.
|
|
141
|
+
* Call `apply(event)` for each new event, and `snapshot()` to get the current state.
|
|
142
|
+
* This is more efficient than re-projecting from the full event stream on every query.
|
|
143
|
+
*/
|
|
144
|
+
export const createSessionContextTracker = () => {
|
|
145
|
+
const ctx = createMutableContext();
|
|
146
|
+
return {
|
|
147
|
+
apply(event) {
|
|
148
|
+
applyEventToContext(ctx, event);
|
|
149
|
+
},
|
|
150
|
+
snapshot() {
|
|
151
|
+
return freeze(ctx);
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=session-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-context.js","sourceRoot":"","sources":["../src/session-context.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,2EAA2E;AAC3E,0DAA0D;AAC1D,+CAA+C;AA0F/C,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E,MAAM,oBAAoB,GAAG,GAA0B,EAAE,CAAC,CAAC;IACzD,aAAa,EAAE,IAAI,GAAG,EAAE;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K,CAAC,MAAM,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAA0B,EAAE;IACrE,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,OAAO;QACL,KAAK,CAAC,KAAkB;YACtB,mBAAmB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;QACD,QAAQ;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA4B,UAAU,EAAoB,MAAM,iBAAiB,CAAC;AAG9F;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,UAAU,CA6DhD"}
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Event store interface and in-memory reference implementation.
|
|
2
|
+
// No DOM, no Node.js APIs — pure domain logic.
|
|
3
|
+
// File-based persistence: see src/cli/file-event-store.ts
|
|
4
|
+
import { validateEvent } from './schema.js';
|
|
5
|
+
/**
|
|
6
|
+
* Create an in-memory event store.
|
|
7
|
+
* Serves as the reference implementation and test double.
|
|
8
|
+
*/
|
|
9
|
+
export function createInMemoryStore() {
|
|
10
|
+
let events = [];
|
|
11
|
+
return {
|
|
12
|
+
append(event) {
|
|
13
|
+
const { valid, errors } = validateEvent(event);
|
|
14
|
+
if (!valid) {
|
|
15
|
+
throw new Error(`Cannot append invalid event: ${errors.join('; ')}`);
|
|
16
|
+
}
|
|
17
|
+
events.push(event);
|
|
18
|
+
},
|
|
19
|
+
query(filter = {}) {
|
|
20
|
+
let result = events;
|
|
21
|
+
if (filter.kind) {
|
|
22
|
+
result = result.filter((e) => e.kind === filter.kind);
|
|
23
|
+
}
|
|
24
|
+
if (filter.since !== undefined) {
|
|
25
|
+
result = result.filter((e) => e.timestamp >= filter.since);
|
|
26
|
+
}
|
|
27
|
+
if (filter.until !== undefined) {
|
|
28
|
+
result = result.filter((e) => e.timestamp <= filter.until);
|
|
29
|
+
}
|
|
30
|
+
if (filter.fingerprint) {
|
|
31
|
+
result = result.filter((e) => e.fingerprint === filter.fingerprint);
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
},
|
|
35
|
+
replay(fromId) {
|
|
36
|
+
if (!fromId)
|
|
37
|
+
return [...events];
|
|
38
|
+
const idx = events.findIndex((e) => e.id === fromId);
|
|
39
|
+
if (idx === -1)
|
|
40
|
+
return [];
|
|
41
|
+
return events.slice(idx);
|
|
42
|
+
},
|
|
43
|
+
count() {
|
|
44
|
+
return events.length;
|
|
45
|
+
},
|
|
46
|
+
clear() {
|
|
47
|
+
events = [];
|
|
48
|
+
},
|
|
49
|
+
toNDJSON() {
|
|
50
|
+
return events.map((e) => JSON.stringify(e)).join('\n');
|
|
51
|
+
},
|
|
52
|
+
fromNDJSON(ndjson) {
|
|
53
|
+
const lines = ndjson.split('\n').filter((line) => line.trim().length > 0);
|
|
54
|
+
let loaded = 0;
|
|
55
|
+
for (const line of lines) {
|
|
56
|
+
const parsed = JSON.parse(line);
|
|
57
|
+
events.push(parsed);
|
|
58
|
+
loaded++;
|
|
59
|
+
}
|
|
60
|
+
return loaded;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,+CAA+C;AAC/C,0DAA0D;AAG1D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,MAAM,GAAkB,EAAE,CAAC;IAE/B,OAAO;QAC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,CAAC,CAAC;YAChC,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;YACrD,IAAI,GAAG,KAAK,CAAC,CAAC;gBAAE,OAAO,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAED,KAAK;YACH,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;QAED,KAAK;YACH,MAAM,GAAG,EAAE,CAAC;QACd,CAAC;QAED,QAAQ;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC;QAED,UAAU,CAAC,MAAc;YACvB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAC1E,IAAI,MAAM,GAAG,CAAC,CAAC;YACf,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAgB,CAAC;gBAC/C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACpB,MAAM,EAAE,CAAC;YACX,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@red-codes/events",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Canonical event model for AgentGuard",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"private": false,
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/AgentGuardHQ/agentguard",
|
|
24
|
+
"directory": "packages/events"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@red-codes/core": "1.0.0"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -b",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:coverage": "vitest run --coverage",
|
|
33
|
+
"lint": "eslint src/",
|
|
34
|
+
"ts:check": "tsc --noEmit",
|
|
35
|
+
"clean": "rm -rf dist"
|
|
36
|
+
}
|
|
37
|
+
}
|