mcp-event-intelligence 0.4.0 → 0.6.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/README.md +107 -26
  3. package/SECURITY.md +4 -4
  4. package/bin/mcp-event-intelligence.mjs +3 -3
  5. package/dist/src/composite/engine.d.ts +14 -4
  6. package/dist/src/composite/engine.js +533 -208
  7. package/dist/src/composite/matching.d.ts +1 -5
  8. package/dist/src/composite/matching.js +45 -54
  9. package/dist/src/composite/runtimeSupport.js +10 -6
  10. package/dist/src/composite/store.d.ts +38 -4
  11. package/dist/src/composite/temporal.d.ts +0 -17
  12. package/dist/src/composite/temporal.js +0 -266
  13. package/dist/src/intelligenceProtocol/activationSchemas.d.ts +38 -3
  14. package/dist/src/intelligenceProtocol/activationSchemas.js +5 -3
  15. package/dist/src/intelligenceProtocol/index.d.ts +12 -9
  16. package/dist/src/intelligenceProtocol/index.js +6 -5
  17. package/dist/src/intelligenceProtocol/lifecycle.js +2 -10
  18. package/dist/src/intelligenceProtocol/operatorRegistry.d.ts +300 -0
  19. package/dist/src/intelligenceProtocol/operatorRegistry.js +338 -0
  20. package/dist/src/intelligenceProtocol/patternV2Schemas.d.ts +188 -0
  21. package/dist/src/intelligenceProtocol/patternV2Schemas.js +801 -0
  22. package/dist/src/intelligenceProtocol/schemas.d.ts +4 -189
  23. package/dist/src/intelligenceProtocol/schemas.js +3 -97
  24. package/dist/src/intelligenceProtocol/triggerPlanSchemas.d.ts +114 -38
  25. package/dist/src/intelligenceProtocol/triggerPlanSchemas.js +27 -18
  26. package/dist/src/intelligenceProtocol/triggerSchemas.d.ts +268 -213
  27. package/dist/src/intelligenceProtocol/triggerSchemas.js +155 -169
  28. package/dist/src/intelligenceProtocol/version.d.ts +2 -2
  29. package/dist/src/intelligenceProtocol/version.js +2 -2
  30. package/dist/src/mcpEvents/consumer.d.ts +1 -0
  31. package/dist/src/mcpEvents/consumer.js +1 -0
  32. package/dist/src/patternV2/evaluator.d.ts +51 -0
  33. package/dist/src/patternV2/evaluator.js +986 -0
  34. package/dist/src/semantic/types.d.ts +6 -0
  35. package/dist/src/semantic/typesafeJevEvaluator.d.ts +1 -0
  36. package/dist/src/semantic/typesafeJevEvaluator.js +6 -0
  37. package/package.json +9 -3
  38. package/scripts/host-integration.d.mts +54 -4
  39. package/scripts/host-integration.mjs +25 -4
  40. package/scripts/lib/activation-hydrator.mjs +13 -12
  41. package/scripts/lib/composite-event-consumer.mjs +10 -28
  42. package/scripts/lib/composite-wake-coordinator.mjs +19 -19
  43. package/scripts/lib/derived-contract-registry.mjs +4 -4
  44. package/scripts/lib/derived-event-coordinator.mjs +69 -6
  45. package/scripts/lib/local-event-intelligence-runtime.mjs +35 -3
  46. package/scripts/lib/mcp-events-client.mjs +97 -55
  47. package/scripts/lib/mcp-events-compatibility.mjs +54 -0
  48. package/scripts/lib/persistent-event-store.mjs +228 -61
  49. package/scripts/lib/store-capabilities.mjs +88 -0
  50. package/scripts/lib/store-conformance.mjs +127 -0
  51. package/scripts/lib/temporal-deadline-scheduler.mjs +3 -3
  52. package/scripts/lib/trigger-control-plane.mjs +202 -53
  53. package/scripts/lib/trigger-inspector.mjs +50 -147
  54. package/scripts/lib/trigger-planner.mjs +141 -52
  55. package/scripts/lib/wake-retry-scheduler.mjs +2 -19
  56. package/scripts/mcp-stdio-server.mjs +46 -61
  57. package/scripts/service.mjs +19 -138
  58. package/server.json +4 -4
  59. package/dist/src/intelligenceProtocol/invariants.d.ts +0 -3
  60. package/dist/src/intelligenceProtocol/invariants.js +0 -36
  61. package/dist/src/intelligenceProtocol/mapper.d.ts +0 -14
  62. package/dist/src/intelligenceProtocol/mapper.js +0 -28
  63. package/scripts/lib/event-processor.mjs +0 -624
  64. package/scripts/lib/http-wake-deliverer.mjs +0 -31
@@ -1,16 +1,19 @@
1
+ export { PATTERN_AST_VERSION, PatternValueSelectorSchema, PatternArithmeticValueSchema, PatternCompareOperatorSchema, AggregateFunctionSchema, PatternWindowSchema, PatternNodeV2Schema, PatternPartitionDimensionSchema, PatternAfterMatchSchema, PatternSelectionSchema, PatternExecutionPolicySchema, PatternMeasureSchema, PatternAstV2DefinitionSchema, collectPatternDurationsMs, collectGuaranteedPatternBindings, collectPatternMeasureRefs, collectPatternRefs, } from './patternV2Schemas.js';
2
+ export type { PatternValueSelector, PatternArithmeticValue, PatternWindow, PatternNodeV2, PatternAfterMatch, PatternAstV2Definition, PatternMeasure, } from './patternV2Schemas.js';
3
+ export { evaluatePatternV2, evaluatePatternAggregate, evaluatePatternMeasure, patternV2CandidateSignature, } from '../patternV2/evaluator.js';
4
+ export type { PatternV2Candidate, PatternV2Evaluation, PatternV2SemanticCache, PatternV2SemanticDecision, PatternV2SemanticTrace, } from '../patternV2/evaluator.js';
5
+ export { TRIGGER_LANGUAGE_VERSION, PREDICATE_OPERATOR, TRIGGER_LANGUAGE_CATALOG, describeTriggerLanguage, } from './operatorRegistry.js';
6
+ export type { TriggerLanguageCategory, } from './operatorRegistry.js';
1
7
  export { EVENT_INTELLIGENCE_PROTOCOL, EVENT_INTELLIGENCE_PROTOCOL_VERSION, EVENT_INTELLIGENCE_SCHEMA_VERSION, EVENT_INTELLIGENCE_COMPATIBILITY, } from './version.js';
2
- export { RuntimeTargetSchema, EventSourceSchema, EventLineageSchema, McpEventOccurrenceSchema, SemanticConditionWireSchema, EventIngestRequestSchema, SemanticDecisionRecordSchema, WakeRecordSchema, LifecycleStateSchema, AuditKindSchema, AuditRecordSchema, parseEventIngestRequest, parseEventLineage, parseSemanticDecisionRecord, parseWakeRecord, parseAuditRecord, } from './schemas.js';
3
- export type { RuntimeTarget, McpEventOccurrence, SemanticConditionWire, EventIngestRequest, EventLineage, SemanticDecisionRecord, WakeRecord, LifecycleState, AuditRecord, } from './schemas.js';
8
+ export { RuntimeTargetSchema, McpEventOccurrenceSchema, WakeRecordSchema, LifecycleStateSchema, AuditKindSchema, AuditRecordSchema, parseWakeRecord, parseAuditRecord, } from './schemas.js';
9
+ export type { RuntimeTarget, McpEventOccurrence, WakeRecord, LifecycleState, AuditRecord, } from './schemas.js';
4
10
  export { canTransition, assertTransition, allowedTransitions, } from './lifecycle.js';
5
11
  export { canonicalJson, sha256Hex, } from './canonical.js';
6
12
  export { AuditChain, } from './audit.js';
7
13
  export type { AppendAuditInput, } from './audit.js';
8
- export { mapMcpEventToLineage, } from './mapper.js';
9
- export type { MapMcpEventInput, } from './mapper.js';
10
- export { assertDecisionLineage, assertWakeLineage, } from './invariants.js';
11
- export { COMPOSITE_TRIGGER_PROTOCOL_VERSION, COMPOSITE_TRIGGER_SCHEMA_VERSION, StructuredPredicateSchema, TriggerClauseSchema, ContinuationContextPolicySchema, ContinuationContractSchema, DerivedEventProjectionSchema, DerivedEventDefinitionSchema, DerivedEventEvidenceRefSchema, DerivedEventRecordSchema, DeterministicCorrelationSchema, SemanticCorrelationSchema, CompositeTriggerDefinitionSchema, CorrelatableEventSchema, TriggerSourceEventSchema, CompositeCorrelationDecisionSchema, TriggerMatchStatusSchema, TriggerMatchRecordSchema, parseCompositeTriggerDefinition, parseCorrelatableEvent, parseTriggerMatchRecord, parseDerivedEventRecord, } from './triggerSchemas.js';
12
- export type { StructuredPredicate, TriggerClause, ContinuationContextPolicy, ContinuationContract, DerivedEventDefinition, DerivedEventRecord, CompositeTriggerDefinition, CorrelatableEvent, TriggerSourceEvent, TriggerMatchRecord, CompositeCorrelationDecision, } from './triggerSchemas.js';
13
- export { TriggerPlanEventSchema, TriggerPlanMatchSchema, TriggerPlanInputSchema, parseTriggerPlanInput, } from './triggerPlanSchemas.js';
14
- export type { TriggerPlanEvent, TriggerPlanMatch, TriggerPlanInput, } from './triggerPlanSchemas.js';
14
+ export { COMPOSITE_TRIGGER_PROTOCOL_VERSION, COMPOSITE_TRIGGER_SCHEMA_VERSION, StructuredPredicateSchema, TriggerClauseSchema, ContinuationContextPolicySchema, ContinuationContractSchema, EventTimePolicySchema, DerivedEventProjectionSchema, DerivedEventDefinitionSchema, DerivedEventEvidenceRefSchema, DerivedEventRecordSchema, CompositeTriggerDefinitionSchema, CorrelatableEventSchema, TriggerSourceEventSchema, PatternSemanticDecisionSchema, TriggerMatchStatusSchema, PatternMatchStateSchema, TriggerMatchRecordSchema, parseCompositeTriggerDefinition, parseCorrelatableEvent, parseTriggerMatchRecord, parseDerivedEventRecord, } from './triggerSchemas.js';
15
+ export type { StructuredPredicate, TriggerClause, ContinuationContextPolicy, ContinuationContract, EventTimePolicy, DerivedEventDefinition, DerivedEventRecord, CompositeTriggerDefinition, CorrelatableEvent, TriggerSourceEvent, PatternMatchState, TriggerMatchRecord, PatternSemanticDecision, } from './triggerSchemas.js';
16
+ export { TriggerPlanEventSchema, TriggerPlanInputSchema, parseTriggerPlanInput, } from './triggerPlanSchemas.js';
17
+ export type { TriggerPlanEvent, TriggerPlanInput, } from './triggerPlanSchemas.js';
15
18
  export { ActivationEvidenceSchema, ActivationEnvelopeSchema, parseActivationEnvelope, } from './activationSchemas.js';
16
19
  export type { ActivationEvidence, ActivationEnvelope, } from './activationSchemas.js';
@@ -1,10 +1,11 @@
1
+ export { PATTERN_AST_VERSION, PatternValueSelectorSchema, PatternArithmeticValueSchema, PatternCompareOperatorSchema, AggregateFunctionSchema, PatternWindowSchema, PatternNodeV2Schema, PatternPartitionDimensionSchema, PatternAfterMatchSchema, PatternSelectionSchema, PatternExecutionPolicySchema, PatternMeasureSchema, PatternAstV2DefinitionSchema, collectPatternDurationsMs, collectGuaranteedPatternBindings, collectPatternMeasureRefs, collectPatternRefs, } from './patternV2Schemas.js';
2
+ export { evaluatePatternV2, evaluatePatternAggregate, evaluatePatternMeasure, patternV2CandidateSignature, } from '../patternV2/evaluator.js';
3
+ export { TRIGGER_LANGUAGE_VERSION, PREDICATE_OPERATOR, TRIGGER_LANGUAGE_CATALOG, describeTriggerLanguage, } from './operatorRegistry.js';
1
4
  export { EVENT_INTELLIGENCE_PROTOCOL, EVENT_INTELLIGENCE_PROTOCOL_VERSION, EVENT_INTELLIGENCE_SCHEMA_VERSION, EVENT_INTELLIGENCE_COMPATIBILITY, } from './version.js';
2
- export { RuntimeTargetSchema, EventSourceSchema, EventLineageSchema, McpEventOccurrenceSchema, SemanticConditionWireSchema, EventIngestRequestSchema, SemanticDecisionRecordSchema, WakeRecordSchema, LifecycleStateSchema, AuditKindSchema, AuditRecordSchema, parseEventIngestRequest, parseEventLineage, parseSemanticDecisionRecord, parseWakeRecord, parseAuditRecord, } from './schemas.js';
5
+ export { RuntimeTargetSchema, McpEventOccurrenceSchema, WakeRecordSchema, LifecycleStateSchema, AuditKindSchema, AuditRecordSchema, parseWakeRecord, parseAuditRecord, } from './schemas.js';
3
6
  export { canTransition, assertTransition, allowedTransitions, } from './lifecycle.js';
4
7
  export { canonicalJson, sha256Hex, } from './canonical.js';
5
8
  export { AuditChain, } from './audit.js';
6
- export { mapMcpEventToLineage, } from './mapper.js';
7
- export { assertDecisionLineage, assertWakeLineage, } from './invariants.js';
8
- export { COMPOSITE_TRIGGER_PROTOCOL_VERSION, COMPOSITE_TRIGGER_SCHEMA_VERSION, StructuredPredicateSchema, TriggerClauseSchema, ContinuationContextPolicySchema, ContinuationContractSchema, DerivedEventProjectionSchema, DerivedEventDefinitionSchema, DerivedEventEvidenceRefSchema, DerivedEventRecordSchema, DeterministicCorrelationSchema, SemanticCorrelationSchema, CompositeTriggerDefinitionSchema, CorrelatableEventSchema, TriggerSourceEventSchema, CompositeCorrelationDecisionSchema, TriggerMatchStatusSchema, TriggerMatchRecordSchema, parseCompositeTriggerDefinition, parseCorrelatableEvent, parseTriggerMatchRecord, parseDerivedEventRecord, } from './triggerSchemas.js';
9
- export { TriggerPlanEventSchema, TriggerPlanMatchSchema, TriggerPlanInputSchema, parseTriggerPlanInput, } from './triggerPlanSchemas.js';
9
+ export { COMPOSITE_TRIGGER_PROTOCOL_VERSION, COMPOSITE_TRIGGER_SCHEMA_VERSION, StructuredPredicateSchema, TriggerClauseSchema, ContinuationContextPolicySchema, ContinuationContractSchema, EventTimePolicySchema, DerivedEventProjectionSchema, DerivedEventDefinitionSchema, DerivedEventEvidenceRefSchema, DerivedEventRecordSchema, CompositeTriggerDefinitionSchema, CorrelatableEventSchema, TriggerSourceEventSchema, PatternSemanticDecisionSchema, TriggerMatchStatusSchema, PatternMatchStateSchema, TriggerMatchRecordSchema, parseCompositeTriggerDefinition, parseCorrelatableEvent, parseTriggerMatchRecord, parseDerivedEventRecord, } from './triggerSchemas.js';
10
+ export { TriggerPlanEventSchema, TriggerPlanInputSchema, parseTriggerPlanInput, } from './triggerPlanSchemas.js';
10
11
  export { ActivationEvidenceSchema, ActivationEnvelopeSchema, parseActivationEnvelope, } from './activationSchemas.js';
@@ -1,14 +1,6 @@
1
1
  const ALLOWED = {
2
- received: new Set(['duplicate', 'evaluating', 'matched', 'failed']),
3
- duplicate: new Set(),
4
- evaluating: new Set(['matched', 'rejected', 'escalated', 'failed']),
5
- matched: new Set(['wake_queued', 'failed']),
6
- rejected: new Set(),
7
- escalated: new Set(['wake_queued', 'rejected', 'failed']),
8
- wake_queued: new Set(['wake_delivered', 'dead_letter', 'failed']),
9
- wake_delivered: new Set(['handled', 'dead_letter', 'failed']),
10
- handled: new Set(),
11
- failed: new Set(['dead_letter']),
2
+ wake_queued: new Set(['wake_delivered', 'dead_letter']),
3
+ wake_delivered: new Set(),
12
4
  dead_letter: new Set(),
13
5
  };
14
6
  export function canTransition(from, to) {
@@ -0,0 +1,300 @@
1
+ export declare const TRIGGER_LANGUAGE_VERSION: "3";
2
+ export declare const PREDICATE_OPERATOR: {
3
+ readonly EQ: "eq";
4
+ readonly NEQ: "neq";
5
+ readonly CONTAINS: "contains";
6
+ readonly STARTS_WITH: "startsWith";
7
+ readonly ENDS_WITH: "endsWith";
8
+ readonly REGEX: "regex";
9
+ readonly IN: "in";
10
+ readonly NOT_IN: "notIn";
11
+ readonly BETWEEN: "between";
12
+ readonly EXISTS: "exists";
13
+ readonly IS_NULL: "isNull";
14
+ readonly TYPE: "type";
15
+ readonly GT: "gt";
16
+ readonly GTE: "gte";
17
+ readonly LT: "lt";
18
+ readonly LTE: "lte";
19
+ };
20
+ export declare const TRIGGER_LANGUAGE_CATALOG: Readonly<{
21
+ version: "3";
22
+ predicates: readonly ({
23
+ id: "eq";
24
+ description: string;
25
+ fields: string[];
26
+ example: {
27
+ path: string;
28
+ op: string;
29
+ value: string;
30
+ };
31
+ optionalFields?: undefined;
32
+ values?: undefined;
33
+ } | {
34
+ id: "neq";
35
+ description: string;
36
+ fields: string[];
37
+ example: {
38
+ path: string;
39
+ op: string;
40
+ value: string;
41
+ };
42
+ optionalFields?: undefined;
43
+ values?: undefined;
44
+ } | {
45
+ id: "contains";
46
+ description: string;
47
+ fields: string[];
48
+ example: {
49
+ path: string;
50
+ op: string;
51
+ value: string;
52
+ };
53
+ optionalFields?: undefined;
54
+ values?: undefined;
55
+ } | {
56
+ id: "startsWith";
57
+ description: string;
58
+ fields: string[];
59
+ example: {
60
+ path: string;
61
+ op: string;
62
+ value: string;
63
+ };
64
+ optionalFields?: undefined;
65
+ values?: undefined;
66
+ } | {
67
+ id: "endsWith";
68
+ description: string;
69
+ fields: string[];
70
+ example: {
71
+ path: string;
72
+ op: string;
73
+ value: string;
74
+ };
75
+ optionalFields?: undefined;
76
+ values?: undefined;
77
+ } | {
78
+ id: "regex";
79
+ description: string;
80
+ fields: string[];
81
+ optionalFields: string[];
82
+ example: {
83
+ path: string;
84
+ op: string;
85
+ value: string;
86
+ };
87
+ values?: undefined;
88
+ } | {
89
+ id: "in";
90
+ description: string;
91
+ fields: string[];
92
+ example: {
93
+ path: string;
94
+ op: string;
95
+ value: string[];
96
+ };
97
+ optionalFields?: undefined;
98
+ values?: undefined;
99
+ } | {
100
+ id: "notIn";
101
+ description: string;
102
+ fields: string[];
103
+ example: {
104
+ path: string;
105
+ op: string;
106
+ value: string[];
107
+ };
108
+ optionalFields?: undefined;
109
+ values?: undefined;
110
+ } | {
111
+ id: "between";
112
+ description: string;
113
+ fields: string[];
114
+ example: {
115
+ path: string;
116
+ op: string;
117
+ value: number[];
118
+ };
119
+ optionalFields?: undefined;
120
+ values?: undefined;
121
+ } | {
122
+ id: "exists";
123
+ description: string;
124
+ fields: string[];
125
+ example: {
126
+ path: string;
127
+ op: string;
128
+ value: boolean;
129
+ };
130
+ optionalFields?: undefined;
131
+ values?: undefined;
132
+ } | {
133
+ id: "isNull";
134
+ description: string;
135
+ fields: string[];
136
+ example: {
137
+ path: string;
138
+ op: string;
139
+ value: boolean;
140
+ };
141
+ optionalFields?: undefined;
142
+ values?: undefined;
143
+ } | {
144
+ id: "type";
145
+ description: string;
146
+ fields: string[];
147
+ values: string[];
148
+ example: {
149
+ path: string;
150
+ op: string;
151
+ value: string;
152
+ };
153
+ optionalFields?: undefined;
154
+ } | {
155
+ id: "gt";
156
+ description: string;
157
+ fields: string[];
158
+ example: {
159
+ path: string;
160
+ op: string;
161
+ value: number;
162
+ };
163
+ optionalFields?: undefined;
164
+ values?: undefined;
165
+ } | {
166
+ id: "gte";
167
+ description: string;
168
+ fields: string[];
169
+ example: {
170
+ path: string;
171
+ op: string;
172
+ value: number;
173
+ };
174
+ optionalFields?: undefined;
175
+ values?: undefined;
176
+ } | {
177
+ id: "lt";
178
+ description: string;
179
+ fields: string[];
180
+ example: {
181
+ path: string;
182
+ op: string;
183
+ value: number;
184
+ };
185
+ optionalFields?: undefined;
186
+ values?: undefined;
187
+ } | {
188
+ id: "lte";
189
+ description: string;
190
+ fields: string[];
191
+ example: {
192
+ path: string;
193
+ op: string;
194
+ value: number;
195
+ };
196
+ optionalFields?: undefined;
197
+ values?: undefined;
198
+ })[];
199
+ pattern: readonly ({
200
+ id: string;
201
+ description: string;
202
+ example: {
203
+ kind: string;
204
+ ref: string;
205
+ };
206
+ contiguity?: undefined;
207
+ fields?: undefined;
208
+ optionalFields?: undefined;
209
+ } | {
210
+ id: string;
211
+ description: string;
212
+ example?: undefined;
213
+ contiguity?: undefined;
214
+ fields?: undefined;
215
+ optionalFields?: undefined;
216
+ } | {
217
+ id: string;
218
+ description: string;
219
+ contiguity: string[];
220
+ example?: undefined;
221
+ fields?: undefined;
222
+ optionalFields?: undefined;
223
+ } | {
224
+ id: string;
225
+ description: string;
226
+ fields: string[];
227
+ optionalFields: string[];
228
+ contiguity: string[];
229
+ example?: undefined;
230
+ } | {
231
+ id: string;
232
+ description: string;
233
+ fields: string[];
234
+ optionalFields: string[];
235
+ example?: undefined;
236
+ contiguity?: undefined;
237
+ } | {
238
+ id: string;
239
+ description: string;
240
+ fields: string[];
241
+ example?: undefined;
242
+ contiguity?: undefined;
243
+ optionalFields?: undefined;
244
+ })[];
245
+ windows: readonly ({
246
+ id: string;
247
+ description: string;
248
+ fields: string[];
249
+ optionalFields?: undefined;
250
+ } | {
251
+ id: string;
252
+ description: string;
253
+ fields: string[];
254
+ optionalFields: string[];
255
+ })[];
256
+ aggregates: readonly {
257
+ id: string;
258
+ description: string;
259
+ }[];
260
+ state: readonly {
261
+ id: string;
262
+ description: string;
263
+ }[];
264
+ selection: readonly {
265
+ id: string;
266
+ values: (string | {
267
+ kind: string;
268
+ ref: string;
269
+ })[];
270
+ description: string;
271
+ }[];
272
+ semantic: readonly {
273
+ id: string;
274
+ description: string;
275
+ fields: string[];
276
+ optionalFields: string[];
277
+ }[];
278
+ execution: readonly {
279
+ id: string;
280
+ description: string;
281
+ }[];
282
+ timing: readonly ({
283
+ id: string;
284
+ description: string;
285
+ authoringPath?: undefined;
286
+ } | {
287
+ id: string;
288
+ description: string;
289
+ authoringPath: string;
290
+ })[];
291
+ lifecycle: readonly {
292
+ id: string;
293
+ description: string;
294
+ }[];
295
+ }>;
296
+ export type TriggerLanguageCategory = 'predicates' | 'pattern' | 'windows' | 'aggregates' | 'state' | 'selection' | 'semantic' | 'execution' | 'timing' | 'lifecycle';
297
+ export declare function describeTriggerLanguage(input?: {
298
+ category?: TriggerLanguageCategory;
299
+ operator?: string;
300
+ }): Record<string, unknown>;