mcp-event-intelligence 0.5.0 → 0.6.1
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/CHANGELOG.md +53 -0
- package/README.md +31 -38
- package/SECURITY.md +4 -4
- package/bin/mcp-event-intelligence.mjs +2 -2
- package/dist/src/composite/engine.d.ts +11 -7
- package/dist/src/composite/engine.js +152 -414
- package/dist/src/composite/matching.d.ts +1 -5
- package/dist/src/composite/matching.js +0 -54
- package/dist/src/composite/runtimeSupport.js +10 -6
- package/dist/src/composite/store.d.ts +38 -4
- package/dist/src/composite/temporal.d.ts +0 -17
- package/dist/src/composite/temporal.js +0 -266
- package/dist/src/intelligenceProtocol/activationSchemas.d.ts +36 -3
- package/dist/src/intelligenceProtocol/activationSchemas.js +4 -3
- package/dist/src/intelligenceProtocol/index.d.ts +8 -12
- package/dist/src/intelligenceProtocol/index.js +4 -7
- package/dist/src/intelligenceProtocol/lifecycle.js +2 -10
- package/dist/src/intelligenceProtocol/operatorRegistry.d.ts +3 -270
- package/dist/src/intelligenceProtocol/operatorRegistry.js +5 -144
- package/dist/src/intelligenceProtocol/schemas.d.ts +0 -189
- package/dist/src/intelligenceProtocol/schemas.js +1 -97
- package/dist/src/intelligenceProtocol/triggerPlanSchemas.d.ts +5 -102
- package/dist/src/intelligenceProtocol/triggerPlanSchemas.js +2 -26
- package/dist/src/intelligenceProtocol/triggerSchemas.d.ts +14 -215
- package/dist/src/intelligenceProtocol/triggerSchemas.js +18 -191
- package/dist/src/intelligenceProtocol/version.d.ts +2 -2
- package/dist/src/intelligenceProtocol/version.js +2 -2
- package/dist/src/patternV2/evaluator.d.ts +9 -1
- package/dist/src/patternV2/evaluator.js +63 -4
- package/dist/src/semantic/types.d.ts +6 -0
- package/dist/src/semantic/typesafeJevEvaluator.d.ts +1 -0
- package/dist/src/semantic/typesafeJevEvaluator.js +6 -0
- package/package.json +5 -2
- package/scripts/host-integration.d.mts +48 -5
- package/scripts/host-integration.mjs +16 -4
- package/scripts/lib/activation-hydrator.mjs +12 -12
- package/scripts/lib/composite-event-consumer.mjs +8 -28
- package/scripts/lib/composite-wake-coordinator.mjs +19 -19
- package/scripts/lib/derived-contract-registry.mjs +4 -4
- package/scripts/lib/derived-event-coordinator.mjs +11 -22
- package/scripts/lib/local-event-intelligence-runtime.mjs +35 -3
- package/scripts/lib/mcp-events-client.mjs +36 -32
- package/scripts/lib/persistent-event-store.mjs +228 -61
- package/scripts/lib/store-capabilities.mjs +88 -0
- package/scripts/lib/store-conformance.mjs +152 -0
- package/scripts/lib/temporal-deadline-scheduler.mjs +3 -3
- package/scripts/lib/trigger-control-plane.mjs +52 -57
- package/scripts/lib/trigger-inspector.mjs +48 -160
- package/scripts/lib/trigger-planner.mjs +37 -126
- package/scripts/lib/wake-retry-scheduler.mjs +2 -19
- package/scripts/mcp-stdio-server.mjs +8 -8
- package/scripts/service.mjs +19 -138
- package/server.json +3 -3
- package/dist/src/intelligenceProtocol/invariants.d.ts +0 -3
- package/dist/src/intelligenceProtocol/invariants.js +0 -36
- package/dist/src/intelligenceProtocol/mapper.d.ts +0 -14
- package/dist/src/intelligenceProtocol/mapper.js +0 -28
- package/dist/src/patternV2/legacyCompiler.d.ts +0 -3
- package/dist/src/patternV2/legacyCompiler.js +0 -184
- package/scripts/lib/event-processor.mjs +0 -624
- package/scripts/lib/http-wake-deliverer.mjs +0 -31
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export function assertDecisionLineage(event, decision) {
|
|
2
|
-
if (decision.traceId !== event.traceId) {
|
|
3
|
-
throw new Error('Decision traceId does not match source event');
|
|
4
|
-
}
|
|
5
|
-
if (decision.subscriptionId !== event.subscriptionId) {
|
|
6
|
-
throw new Error('Decision subscriptionId does not match source event');
|
|
7
|
-
}
|
|
8
|
-
if (decision.sourceEventId !== event.sourceEventId) {
|
|
9
|
-
throw new Error('Decision sourceEventId does not match source event');
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export function assertWakeLineage(event, decision, wake) {
|
|
13
|
-
if (wake.traceId !== event.traceId) {
|
|
14
|
-
throw new Error('Wake traceId does not match source event');
|
|
15
|
-
}
|
|
16
|
-
if (wake.subscriptionId !== event.subscriptionId) {
|
|
17
|
-
throw new Error('Wake subscriptionId does not match source event');
|
|
18
|
-
}
|
|
19
|
-
if (wake.sourceEventId !== event.sourceEventId) {
|
|
20
|
-
throw new Error('Wake sourceEventId does not match source event');
|
|
21
|
-
}
|
|
22
|
-
if (decision) {
|
|
23
|
-
assertDecisionLineage(event, decision);
|
|
24
|
-
if (wake.decisionId !== decision.decisionId) {
|
|
25
|
-
throw new Error('Wake decisionId does not match semantic decision');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else if (wake.decisionId !== null) {
|
|
29
|
-
throw new Error('Wake has decisionId but no decision record was supplied');
|
|
30
|
-
}
|
|
31
|
-
if (wake.target.runtime !== event.target.runtime ||
|
|
32
|
-
wake.target.kind !== event.target.kind ||
|
|
33
|
-
wake.target.id !== event.target.id) {
|
|
34
|
-
throw new Error('Wake target does not match source event target');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { EventOccurrence } from '../protocol/types.js';
|
|
2
|
-
import { type EventLineage, type RuntimeTarget } from './schemas.js';
|
|
3
|
-
export interface MapMcpEventInput {
|
|
4
|
-
event: EventOccurrence;
|
|
5
|
-
traceId: string;
|
|
6
|
-
environmentId: string;
|
|
7
|
-
subscriptionId: string;
|
|
8
|
-
serverId: string;
|
|
9
|
-
transport: 'stdio' | 'streamable_http' | 'webhook' | 'poll' | 'internal';
|
|
10
|
-
provider?: string;
|
|
11
|
-
target: RuntimeTarget;
|
|
12
|
-
observedAt: string;
|
|
13
|
-
}
|
|
14
|
-
export declare function mapMcpEventToLineage(input: MapMcpEventInput): Promise<EventLineage>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { sha256Hex } from './canonical.js';
|
|
2
|
-
import { EventLineageSchema, } from './schemas.js';
|
|
3
|
-
import { EVENT_INTELLIGENCE_PROTOCOL, EVENT_INTELLIGENCE_PROTOCOL_VERSION, EVENT_INTELLIGENCE_SCHEMA_VERSION, } from './version.js';
|
|
4
|
-
export async function mapMcpEventToLineage(input) {
|
|
5
|
-
const payloadHash = await sha256Hex(input.event.data);
|
|
6
|
-
return EventLineageSchema.parse({
|
|
7
|
-
protocol: EVENT_INTELLIGENCE_PROTOCOL,
|
|
8
|
-
protocolVersion: EVENT_INTELLIGENCE_PROTOCOL_VERSION,
|
|
9
|
-
schemaVersion: EVENT_INTELLIGENCE_SCHEMA_VERSION,
|
|
10
|
-
traceId: input.traceId,
|
|
11
|
-
environmentId: input.environmentId,
|
|
12
|
-
subscriptionId: input.subscriptionId,
|
|
13
|
-
sourceEventId: input.event.eventId,
|
|
14
|
-
observedAt: input.observedAt,
|
|
15
|
-
source: {
|
|
16
|
-
serverId: input.serverId,
|
|
17
|
-
transport: input.transport,
|
|
18
|
-
...(input.provider ? { provider: input.provider } : {}),
|
|
19
|
-
cursor: input.event.cursor ?? null,
|
|
20
|
-
},
|
|
21
|
-
target: input.target,
|
|
22
|
-
event: {
|
|
23
|
-
name: input.event.name,
|
|
24
|
-
occurredAt: input.event.timestamp,
|
|
25
|
-
payloadHash,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { CompositeTriggerDefinition } from '../intelligenceProtocol/triggerSchemas.js';
|
|
2
|
-
import { type PatternAstV2Definition } from '../intelligenceProtocol/patternV2Schemas.js';
|
|
3
|
-
export declare function compileLegacyTriggerToPatternV2(definition: CompositeTriggerDefinition): PatternAstV2Definition;
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { PatternAstV2DefinitionSchema, } from '../intelligenceProtocol/patternV2Schemas.js';
|
|
2
|
-
function eventNode(ref) {
|
|
3
|
-
return { kind: 'event', ref };
|
|
4
|
-
}
|
|
5
|
-
function expressionNode(definition) {
|
|
6
|
-
const expression = definition.expression;
|
|
7
|
-
if (expression.kind === 'allOf') {
|
|
8
|
-
return {
|
|
9
|
-
kind: 'allOf',
|
|
10
|
-
children: expression.refs.map(eventNode),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
if (expression.kind === 'anyOf') {
|
|
14
|
-
return {
|
|
15
|
-
kind: 'anyOf',
|
|
16
|
-
children: expression.refs.map(eventNode),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
if (expression.kind === 'sequence') {
|
|
20
|
-
return {
|
|
21
|
-
kind: 'sequence',
|
|
22
|
-
children: expression.refs.map(eventNode),
|
|
23
|
-
contiguity: 'followedBy',
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
kind: 'repeat',
|
|
28
|
-
child: eventNode(expression.ref),
|
|
29
|
-
min: expression.atLeast,
|
|
30
|
-
mode: 'greedy',
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function wrapTemporal(root, condition) {
|
|
34
|
-
if (condition.kind === 'calendar') {
|
|
35
|
-
return {
|
|
36
|
-
kind: 'calendar',
|
|
37
|
-
child: root,
|
|
38
|
-
ref: condition.ref,
|
|
39
|
-
timezone: condition.timezone,
|
|
40
|
-
...(condition.before ? { before: condition.before } : {}),
|
|
41
|
-
...(condition.after ? { after: condition.after } : {}),
|
|
42
|
-
...(condition.weekdays ? { weekdays: condition.weekdays } : {}),
|
|
43
|
-
...(condition.dates ? { dates: condition.dates } : {}),
|
|
44
|
-
...(condition.dateRange ? { dateRange: condition.dateRange } : {}),
|
|
45
|
-
...(condition.dayOfMonth ? { dayOfMonth: condition.dayOfMonth } : {}),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
if (condition.kind === 'absence') {
|
|
49
|
-
return {
|
|
50
|
-
kind: 'absence',
|
|
51
|
-
id: condition.id,
|
|
52
|
-
child: root,
|
|
53
|
-
ref: condition.ref,
|
|
54
|
-
afterRef: condition.afterRef,
|
|
55
|
-
...(condition.forMs ? { forMs: condition.forMs } : {}),
|
|
56
|
-
...(condition.untilLocalTime
|
|
57
|
-
? { untilLocalTime: condition.untilLocalTime }
|
|
58
|
-
: {}),
|
|
59
|
-
...(condition.timezone ? { timezone: condition.timezone } : {}),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
if (condition.kind === 'not' || condition.kind === 'unless') {
|
|
63
|
-
return {
|
|
64
|
-
kind: 'notPresent',
|
|
65
|
-
child: root,
|
|
66
|
-
ref: condition.ref,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
if (condition.kind === 'after') {
|
|
70
|
-
return {
|
|
71
|
-
kind: 'after',
|
|
72
|
-
child: root,
|
|
73
|
-
ref: condition.ref,
|
|
74
|
-
afterRef: condition.afterRef,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (condition.kind === 'until') {
|
|
78
|
-
return {
|
|
79
|
-
kind: 'until',
|
|
80
|
-
child: root,
|
|
81
|
-
ref: condition.ref,
|
|
82
|
-
beforeRef: condition.beforeRef,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
if (condition.kind === 'debounce') {
|
|
86
|
-
return {
|
|
87
|
-
kind: 'debounce',
|
|
88
|
-
id: condition.id,
|
|
89
|
-
child: root,
|
|
90
|
-
ref: condition.ref,
|
|
91
|
-
forMs: condition.forMs,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
if (condition.kind === 'threshold') {
|
|
95
|
-
return {
|
|
96
|
-
kind: 'threshold',
|
|
97
|
-
child: root,
|
|
98
|
-
ref: condition.ref,
|
|
99
|
-
atLeast: condition.atLeast,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
if (condition.kind === 'rate') {
|
|
103
|
-
return {
|
|
104
|
-
kind: 'rate',
|
|
105
|
-
child: root,
|
|
106
|
-
ref: condition.ref,
|
|
107
|
-
atLeast: condition.atLeast,
|
|
108
|
-
perMs: condition.perMs,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
kind: 'distinct',
|
|
113
|
-
child: root,
|
|
114
|
-
ref: condition.ref,
|
|
115
|
-
path: condition.path,
|
|
116
|
-
atLeast: condition.atLeast,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
export function compileLegacyTriggerToPatternV2(definition) {
|
|
120
|
-
let root = expressionNode(definition);
|
|
121
|
-
const deterministic = definition.correlation?.deterministic;
|
|
122
|
-
if (deterministic?.fields?.length) {
|
|
123
|
-
const [anchorField, ...otherFields] = deterministic.fields;
|
|
124
|
-
if (!anchorField) {
|
|
125
|
-
throw new Error('Deterministic correlation requires at least one field');
|
|
126
|
-
}
|
|
127
|
-
for (const field of otherFields) {
|
|
128
|
-
root = {
|
|
129
|
-
kind: 'compare',
|
|
130
|
-
child: root,
|
|
131
|
-
left: {
|
|
132
|
-
kind: 'field',
|
|
133
|
-
ref: anchorField.ref,
|
|
134
|
-
path: anchorField.path,
|
|
135
|
-
select: 'last',
|
|
136
|
-
},
|
|
137
|
-
op: 'eq',
|
|
138
|
-
right: {
|
|
139
|
-
kind: 'field',
|
|
140
|
-
ref: field.ref,
|
|
141
|
-
path: field.path,
|
|
142
|
-
select: 'last',
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
for (const condition of definition.temporal ?? []) {
|
|
148
|
-
root = wrapTemporal(root, condition);
|
|
149
|
-
}
|
|
150
|
-
if (definition.correlation?.semantic) {
|
|
151
|
-
const semantic = definition.correlation.semantic;
|
|
152
|
-
root = {
|
|
153
|
-
kind: 'semantic',
|
|
154
|
-
id: 'legacy-semantic-correlation',
|
|
155
|
-
child: root,
|
|
156
|
-
refs: [...new Set(semantic.input
|
|
157
|
-
.map((path) => path.split('.')[0])
|
|
158
|
-
.filter(Boolean))],
|
|
159
|
-
instruction: semantic.instruction,
|
|
160
|
-
input: semantic.input,
|
|
161
|
-
matchThreshold: semantic.matchThreshold,
|
|
162
|
-
rejectThreshold: semantic.rejectThreshold,
|
|
163
|
-
uncertain: semantic.uncertain,
|
|
164
|
-
execution: {
|
|
165
|
-
cache: true,
|
|
166
|
-
timeoutMs: 5000,
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
return PatternAstV2DefinitionSchema.parse({
|
|
171
|
-
version: '2',
|
|
172
|
-
root,
|
|
173
|
-
partitionBy: [],
|
|
174
|
-
selection: {
|
|
175
|
-
overlap: 'disallow',
|
|
176
|
-
afterMatch: 'skipPastLast',
|
|
177
|
-
maxMatchesPerEvent: 10,
|
|
178
|
-
},
|
|
179
|
-
execution: {
|
|
180
|
-
maxCandidates: 512,
|
|
181
|
-
maxSemanticEvaluations: 16,
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
}
|