mcp-event-intelligence 0.5.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 (61) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +31 -38
  3. package/SECURITY.md +4 -4
  4. package/bin/mcp-event-intelligence.mjs +2 -2
  5. package/dist/src/composite/engine.d.ts +11 -7
  6. package/dist/src/composite/engine.js +150 -414
  7. package/dist/src/composite/matching.d.ts +1 -5
  8. package/dist/src/composite/matching.js +0 -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 +36 -3
  14. package/dist/src/intelligenceProtocol/activationSchemas.js +4 -3
  15. package/dist/src/intelligenceProtocol/index.d.ts +8 -12
  16. package/dist/src/intelligenceProtocol/index.js +4 -7
  17. package/dist/src/intelligenceProtocol/lifecycle.js +2 -10
  18. package/dist/src/intelligenceProtocol/operatorRegistry.d.ts +3 -270
  19. package/dist/src/intelligenceProtocol/operatorRegistry.js +5 -144
  20. package/dist/src/intelligenceProtocol/schemas.d.ts +0 -189
  21. package/dist/src/intelligenceProtocol/schemas.js +1 -97
  22. package/dist/src/intelligenceProtocol/triggerPlanSchemas.d.ts +5 -102
  23. package/dist/src/intelligenceProtocol/triggerPlanSchemas.js +2 -26
  24. package/dist/src/intelligenceProtocol/triggerSchemas.d.ts +14 -215
  25. package/dist/src/intelligenceProtocol/triggerSchemas.js +18 -191
  26. package/dist/src/intelligenceProtocol/version.d.ts +2 -2
  27. package/dist/src/intelligenceProtocol/version.js +2 -2
  28. package/dist/src/patternV2/evaluator.d.ts +9 -1
  29. package/dist/src/patternV2/evaluator.js +63 -4
  30. package/dist/src/semantic/types.d.ts +6 -0
  31. package/dist/src/semantic/typesafeJevEvaluator.d.ts +1 -0
  32. package/dist/src/semantic/typesafeJevEvaluator.js +6 -0
  33. package/package.json +5 -2
  34. package/scripts/host-integration.d.mts +48 -5
  35. package/scripts/host-integration.mjs +16 -4
  36. package/scripts/lib/activation-hydrator.mjs +12 -12
  37. package/scripts/lib/composite-event-consumer.mjs +8 -28
  38. package/scripts/lib/composite-wake-coordinator.mjs +19 -19
  39. package/scripts/lib/derived-contract-registry.mjs +4 -4
  40. package/scripts/lib/derived-event-coordinator.mjs +11 -22
  41. package/scripts/lib/local-event-intelligence-runtime.mjs +35 -3
  42. package/scripts/lib/mcp-events-client.mjs +36 -32
  43. package/scripts/lib/persistent-event-store.mjs +228 -61
  44. package/scripts/lib/store-capabilities.mjs +88 -0
  45. package/scripts/lib/store-conformance.mjs +127 -0
  46. package/scripts/lib/temporal-deadline-scheduler.mjs +3 -3
  47. package/scripts/lib/trigger-control-plane.mjs +52 -57
  48. package/scripts/lib/trigger-inspector.mjs +48 -160
  49. package/scripts/lib/trigger-planner.mjs +37 -126
  50. package/scripts/lib/wake-retry-scheduler.mjs +2 -19
  51. package/scripts/mcp-stdio-server.mjs +8 -8
  52. package/scripts/service.mjs +19 -138
  53. package/server.json +3 -3
  54. package/dist/src/intelligenceProtocol/invariants.d.ts +0 -3
  55. package/dist/src/intelligenceProtocol/invariants.js +0 -36
  56. package/dist/src/intelligenceProtocol/mapper.d.ts +0 -14
  57. package/dist/src/intelligenceProtocol/mapper.js +0 -28
  58. package/dist/src/patternV2/legacyCompiler.d.ts +0 -3
  59. package/dist/src/patternV2/legacyCompiler.js +0 -184
  60. package/scripts/lib/event-processor.mjs +0 -624
  61. package/scripts/lib/http-wake-deliverer.mjs +0 -31
@@ -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) {
@@ -1,4 +1,4 @@
1
- export declare const TRIGGER_LANGUAGE_VERSION: "2";
1
+ export declare const TRIGGER_LANGUAGE_VERSION: "3";
2
2
  export declare const PREDICATE_OPERATOR: {
3
3
  readonly EQ: "eq";
4
4
  readonly NEQ: "neq";
@@ -17,26 +17,8 @@ export declare const PREDICATE_OPERATOR: {
17
17
  readonly LT: "lt";
18
18
  readonly LTE: "lte";
19
19
  };
20
- export declare const COMPOSITION_OPERATOR: {
21
- readonly ALL: "all";
22
- readonly ANY: "any";
23
- readonly SEQUENCE: "sequence";
24
- readonly COUNT: "count";
25
- };
26
- export declare const TEMPORAL_OPERATOR: {
27
- readonly CALENDAR: "calendar";
28
- readonly ABSENCE: "absence";
29
- readonly NOT: "not";
30
- readonly UNLESS: "unless";
31
- readonly AFTER: "after";
32
- readonly UNTIL: "until";
33
- readonly DEBOUNCE: "debounce";
34
- readonly THRESHOLD: "threshold";
35
- readonly RATE: "rate";
36
- readonly DISTINCT: "distinct";
37
- };
38
20
  export declare const TRIGGER_LANGUAGE_CATALOG: Readonly<{
39
- version: "2";
21
+ version: "3";
40
22
  predicates: readonly ({
41
23
  id: "eq";
42
24
  description: string;
@@ -214,250 +196,6 @@ export declare const TRIGGER_LANGUAGE_CATALOG: Readonly<{
214
196
  optionalFields?: undefined;
215
197
  values?: undefined;
216
198
  })[];
217
- composition: readonly ({
218
- id: "all";
219
- canonicalKind: string;
220
- description: string;
221
- example: {
222
- match: string;
223
- };
224
- } | {
225
- id: "any";
226
- canonicalKind: string;
227
- description: string;
228
- example: {
229
- match: string;
230
- };
231
- } | {
232
- id: "sequence";
233
- canonicalKind: string;
234
- description: string;
235
- example: {
236
- match: string;
237
- };
238
- } | {
239
- id: "count";
240
- canonicalKind: string;
241
- description: string;
242
- example: {
243
- match: {
244
- kind: string;
245
- eventId: string;
246
- atLeast: number;
247
- };
248
- };
249
- })[];
250
- temporal: readonly ({
251
- id: "calendar";
252
- description: string;
253
- fields: string[];
254
- optionalFields: string[];
255
- example: {
256
- id: string;
257
- kind: string;
258
- ref: string;
259
- timezone: string;
260
- after: string;
261
- before: string;
262
- weekdays: number[];
263
- afterRef?: undefined;
264
- forMs?: undefined;
265
- beforeRef?: undefined;
266
- atLeast?: undefined;
267
- perMs?: undefined;
268
- path?: undefined;
269
- };
270
- oneOf?: undefined;
271
- } | {
272
- id: "absence";
273
- description: string;
274
- fields: string[];
275
- oneOf: string[][];
276
- example: {
277
- id: string;
278
- kind: string;
279
- ref: string;
280
- afterRef: string;
281
- forMs: number;
282
- timezone?: undefined;
283
- after?: undefined;
284
- before?: undefined;
285
- weekdays?: undefined;
286
- beforeRef?: undefined;
287
- atLeast?: undefined;
288
- perMs?: undefined;
289
- path?: undefined;
290
- };
291
- optionalFields?: undefined;
292
- } | {
293
- id: "not";
294
- description: string;
295
- fields: string[];
296
- example: {
297
- id: string;
298
- kind: string;
299
- ref: string;
300
- timezone?: undefined;
301
- after?: undefined;
302
- before?: undefined;
303
- weekdays?: undefined;
304
- afterRef?: undefined;
305
- forMs?: undefined;
306
- beforeRef?: undefined;
307
- atLeast?: undefined;
308
- perMs?: undefined;
309
- path?: undefined;
310
- };
311
- optionalFields?: undefined;
312
- oneOf?: undefined;
313
- } | {
314
- id: "unless";
315
- description: string;
316
- fields: string[];
317
- example: {
318
- id: string;
319
- kind: string;
320
- ref: string;
321
- timezone?: undefined;
322
- after?: undefined;
323
- before?: undefined;
324
- weekdays?: undefined;
325
- afterRef?: undefined;
326
- forMs?: undefined;
327
- beforeRef?: undefined;
328
- atLeast?: undefined;
329
- perMs?: undefined;
330
- path?: undefined;
331
- };
332
- optionalFields?: undefined;
333
- oneOf?: undefined;
334
- } | {
335
- id: "after";
336
- description: string;
337
- fields: string[];
338
- example: {
339
- id: string;
340
- kind: string;
341
- ref: string;
342
- afterRef: string;
343
- timezone?: undefined;
344
- after?: undefined;
345
- before?: undefined;
346
- weekdays?: undefined;
347
- forMs?: undefined;
348
- beforeRef?: undefined;
349
- atLeast?: undefined;
350
- perMs?: undefined;
351
- path?: undefined;
352
- };
353
- optionalFields?: undefined;
354
- oneOf?: undefined;
355
- } | {
356
- id: "until";
357
- description: string;
358
- fields: string[];
359
- example: {
360
- id: string;
361
- kind: string;
362
- ref: string;
363
- beforeRef: string;
364
- timezone?: undefined;
365
- after?: undefined;
366
- before?: undefined;
367
- weekdays?: undefined;
368
- afterRef?: undefined;
369
- forMs?: undefined;
370
- atLeast?: undefined;
371
- perMs?: undefined;
372
- path?: undefined;
373
- };
374
- optionalFields?: undefined;
375
- oneOf?: undefined;
376
- } | {
377
- id: "debounce";
378
- description: string;
379
- fields: string[];
380
- example: {
381
- id: string;
382
- kind: string;
383
- ref: string;
384
- forMs: number;
385
- timezone?: undefined;
386
- after?: undefined;
387
- before?: undefined;
388
- weekdays?: undefined;
389
- afterRef?: undefined;
390
- beforeRef?: undefined;
391
- atLeast?: undefined;
392
- perMs?: undefined;
393
- path?: undefined;
394
- };
395
- optionalFields?: undefined;
396
- oneOf?: undefined;
397
- } | {
398
- id: "threshold";
399
- description: string;
400
- fields: string[];
401
- example: {
402
- id: string;
403
- kind: string;
404
- ref: string;
405
- atLeast: number;
406
- timezone?: undefined;
407
- after?: undefined;
408
- before?: undefined;
409
- weekdays?: undefined;
410
- afterRef?: undefined;
411
- forMs?: undefined;
412
- beforeRef?: undefined;
413
- perMs?: undefined;
414
- path?: undefined;
415
- };
416
- optionalFields?: undefined;
417
- oneOf?: undefined;
418
- } | {
419
- id: "rate";
420
- description: string;
421
- fields: string[];
422
- example: {
423
- id: string;
424
- kind: string;
425
- ref: string;
426
- atLeast: number;
427
- perMs: number;
428
- timezone?: undefined;
429
- after?: undefined;
430
- before?: undefined;
431
- weekdays?: undefined;
432
- afterRef?: undefined;
433
- forMs?: undefined;
434
- beforeRef?: undefined;
435
- path?: undefined;
436
- };
437
- optionalFields?: undefined;
438
- oneOf?: undefined;
439
- } | {
440
- id: "distinct";
441
- description: string;
442
- fields: string[];
443
- example: {
444
- id: string;
445
- kind: string;
446
- ref: string;
447
- path: string;
448
- atLeast: number;
449
- timezone?: undefined;
450
- after?: undefined;
451
- before?: undefined;
452
- weekdays?: undefined;
453
- afterRef?: undefined;
454
- forMs?: undefined;
455
- beforeRef?: undefined;
456
- perMs?: undefined;
457
- };
458
- optionalFields?: undefined;
459
- oneOf?: undefined;
460
- })[];
461
199
  pattern: readonly ({
462
200
  id: string;
463
201
  description: string;
@@ -537,11 +275,6 @@ export declare const TRIGGER_LANGUAGE_CATALOG: Readonly<{
537
275
  fields: string[];
538
276
  optionalFields: string[];
539
277
  }[];
540
- correlation: readonly {
541
- id: string;
542
- description: string;
543
- authoringField: string;
544
- }[];
545
278
  execution: readonly {
546
279
  id: string;
547
280
  description: string;
@@ -560,7 +293,7 @@ export declare const TRIGGER_LANGUAGE_CATALOG: Readonly<{
560
293
  description: string;
561
294
  }[];
562
295
  }>;
563
- export type TriggerLanguageCategory = 'predicates' | 'composition' | 'temporal' | 'pattern' | 'windows' | 'aggregates' | 'state' | 'selection' | 'semantic' | 'execution' | 'correlation' | 'timing' | 'lifecycle';
296
+ export type TriggerLanguageCategory = 'predicates' | 'pattern' | 'windows' | 'aggregates' | 'state' | 'selection' | 'semantic' | 'execution' | 'timing' | 'lifecycle';
564
297
  export declare function describeTriggerLanguage(input?: {
565
298
  category?: TriggerLanguageCategory;
566
299
  operator?: string;
@@ -1,4 +1,4 @@
1
- export const TRIGGER_LANGUAGE_VERSION = '2';
1
+ export const TRIGGER_LANGUAGE_VERSION = '3';
2
2
  export const PREDICATE_OPERATOR = {
3
3
  EQ: 'eq',
4
4
  NEQ: 'neq',
@@ -17,24 +17,6 @@ export const PREDICATE_OPERATOR = {
17
17
  LT: 'lt',
18
18
  LTE: 'lte',
19
19
  };
20
- export const COMPOSITION_OPERATOR = {
21
- ALL: 'all',
22
- ANY: 'any',
23
- SEQUENCE: 'sequence',
24
- COUNT: 'count',
25
- };
26
- export const TEMPORAL_OPERATOR = {
27
- CALENDAR: 'calendar',
28
- ABSENCE: 'absence',
29
- NOT: 'not',
30
- UNLESS: 'unless',
31
- AFTER: 'after',
32
- UNTIL: 'until',
33
- DEBOUNCE: 'debounce',
34
- THRESHOLD: 'threshold',
35
- RATE: 'rate',
36
- DISTINCT: 'distinct',
37
- };
38
20
  export const TRIGGER_LANGUAGE_CATALOG = Object.freeze({
39
21
  version: TRIGGER_LANGUAGE_VERSION,
40
22
  predicates: Object.freeze([
@@ -137,110 +119,6 @@ export const TRIGGER_LANGUAGE_CATALOG = Object.freeze({
137
119
  example: { path: 'stock', op: 'lte', value: 10 },
138
120
  },
139
121
  ]),
140
- composition: Object.freeze([
141
- {
142
- id: COMPOSITION_OPERATOR.ALL,
143
- canonicalKind: 'allOf',
144
- description: 'All referenced events must satisfy the legacy trigger.',
145
- example: { match: 'all' },
146
- },
147
- {
148
- id: COMPOSITION_OPERATOR.ANY,
149
- canonicalKind: 'anyOf',
150
- description: 'Any referenced event may satisfy the legacy trigger.',
151
- example: { match: 'any' },
152
- },
153
- {
154
- id: COMPOSITION_OPERATOR.SEQUENCE,
155
- canonicalKind: 'sequence',
156
- description: 'Referenced events must occur in event-time order.',
157
- example: { match: 'sequence' },
158
- },
159
- {
160
- id: COMPOSITION_OPERATOR.COUNT,
161
- canonicalKind: 'count',
162
- description: 'One referenced event must occur at least N times.',
163
- example: { match: { kind: 'count', eventId: 'comment', atLeast: 3 } },
164
- },
165
- ]),
166
- temporal: Object.freeze([
167
- {
168
- id: TEMPORAL_OPERATOR.CALENDAR,
169
- description: 'Calendar/timezone constraint.',
170
- fields: ['id', 'kind', 'ref', 'timezone'],
171
- optionalFields: ['before', 'after', 'weekdays', 'dates', 'dateRange', 'dayOfMonth'],
172
- example: {
173
- id: 'business-hours',
174
- kind: 'calendar',
175
- ref: 'order',
176
- timezone: 'Europe/Rome',
177
- after: '09:00',
178
- before: '18:00',
179
- weekdays: [1, 2, 3, 4, 5],
180
- },
181
- },
182
- {
183
- id: TEMPORAL_OPERATOR.ABSENCE,
184
- description: 'Referenced event must remain absent after an anchor for a durable period.',
185
- fields: ['id', 'kind', 'ref', 'afterRef'],
186
- oneOf: [['forMs'], ['untilLocalTime', 'timezone']],
187
- example: {
188
- id: 'no-errors',
189
- kind: 'absence',
190
- ref: 'error',
191
- afterRef: 'deploy',
192
- forMs: 600000,
193
- },
194
- },
195
- {
196
- id: TEMPORAL_OPERATOR.NOT,
197
- description: 'Referenced event must not be present.',
198
- fields: ['id', 'kind', 'ref'],
199
- example: { id: 'not-cancelled', kind: 'not', ref: 'cancelled' },
200
- },
201
- {
202
- id: TEMPORAL_OPERATOR.UNLESS,
203
- description: 'Condition remains valid unless the referenced event occurs.',
204
- fields: ['id', 'kind', 'ref'],
205
- example: { id: 'unless-blocked', kind: 'unless', ref: 'blocked' },
206
- },
207
- {
208
- id: TEMPORAL_OPERATOR.AFTER,
209
- description: 'ref must occur after afterRef.',
210
- fields: ['id', 'kind', 'ref', 'afterRef'],
211
- example: { id: 'deploy-after-merge', kind: 'after', ref: 'deploy', afterRef: 'merge' },
212
- },
213
- {
214
- id: TEMPORAL_OPERATOR.UNTIL,
215
- description: 'ref must occur no later than beforeRef.',
216
- fields: ['id', 'kind', 'ref', 'beforeRef'],
217
- example: { id: 'approve-before-expiry', kind: 'until', ref: 'approval', beforeRef: 'expiry' },
218
- },
219
- {
220
- id: TEMPORAL_OPERATOR.DEBOUNCE,
221
- description: 'Wait for a quiet period after the latest referenced event.',
222
- fields: ['id', 'kind', 'ref', 'forMs'],
223
- example: { id: 'quiet', kind: 'debounce', ref: 'change', forMs: 300000 },
224
- },
225
- {
226
- id: TEMPORAL_OPERATOR.THRESHOLD,
227
- description: 'At least N occurrences are required.',
228
- fields: ['id', 'kind', 'ref', 'atLeast'],
229
- example: { id: 'three-comments', kind: 'threshold', ref: 'comment', atLeast: 3 },
230
- },
231
- {
232
- id: TEMPORAL_OPERATOR.RATE,
233
- description: 'At least N occurrences are required within a duration.',
234
- fields: ['id', 'kind', 'ref', 'atLeast', 'perMs'],
235
- example: { id: 'order-spike', kind: 'rate', ref: 'order', atLeast: 5, perMs: 600000 },
236
- },
237
- {
238
- id: TEMPORAL_OPERATOR.DISTINCT,
239
- description: 'At least N distinct values are required.',
240
- fields: ['id', 'kind', 'ref', 'path', 'atLeast'],
241
- example: { id: 'three-customers', kind: 'distinct', ref: 'order', path: 'customer', atLeast: 3 },
242
- },
243
- ]),
244
122
  pattern: Object.freeze([
245
123
  {
246
124
  id: 'event',
@@ -304,11 +182,11 @@ export const TRIGGER_LANGUAGE_CATALOG = Object.freeze({
304
182
  },
305
183
  {
306
184
  id: 'calendar',
307
- description: 'Calendar/timezone filter as a v2 wrapper node.',
185
+ description: 'Calendar/timezone filter as a Pattern AST wrapper node.',
308
186
  },
309
187
  {
310
188
  id: 'absence',
311
- description: 'Durable absence condition as a v2 wrapper node.',
189
+ description: 'Durable absence condition as a Pattern AST wrapper node.',
312
190
  },
313
191
  {
314
192
  id: 'notPresent',
@@ -402,23 +280,6 @@ export const TRIGGER_LANGUAGE_CATALOG = Object.freeze({
402
280
  optionalFields: ['uncertain', 'execution.cache', 'execution.timeoutMs', 'execution.onUnavailable'],
403
281
  },
404
282
  ]),
405
- correlation: Object.freeze([
406
- {
407
- id: 'same_value',
408
- description: 'Legacy deterministic same-value correlation.',
409
- authoringField: 'correlateBy',
410
- },
411
- {
412
- id: 'semantic',
413
- description: 'Legacy semantic-correlation compatibility field.',
414
- authoringField: 'semanticCorrelation',
415
- },
416
- {
417
- id: 'partitionBy',
418
- description: 'Pattern AST v2 partitions stream state by one or more named dimensions.',
419
- authoringField: 'patternV2.partitionBy',
420
- },
421
- ]),
422
283
  execution: Object.freeze([
423
284
  {
424
285
  id: 'maxCandidates',
@@ -463,8 +324,8 @@ export function describeTriggerLanguage(input = {}) {
463
324
  version: TRIGGER_LANGUAGE_VERSION,
464
325
  authoringSurface: 'TriggerPlanInput',
465
326
  planner: 'trigger_plan',
466
- preferredAuthoring: 'TriggerPlanInput.patternV2',
467
- canonicalRepresentation: 'CompositeTriggerDefinition + PatternAstV2',
327
+ preferredAuthoring: 'TriggerPlanInput.pattern',
328
+ canonicalRepresentation: 'CompositeTriggerDefinition.pattern',
468
329
  };
469
330
  for (const key of categories) {
470
331
  const entries = TRIGGER_LANGUAGE_CATALOG[key];