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.
- package/CHANGELOG.md +41 -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 +150 -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 +127 -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
|
@@ -10,91 +10,6 @@ export declare const RuntimeTargetSchema: z.ZodObject<{
|
|
|
10
10
|
}>;
|
|
11
11
|
id: z.ZodString;
|
|
12
12
|
}, z.core.$strip>;
|
|
13
|
-
export declare const EventSourceSchema: z.ZodObject<{
|
|
14
|
-
serverId: z.ZodString;
|
|
15
|
-
transport: z.ZodEnum<{
|
|
16
|
-
stdio: "stdio";
|
|
17
|
-
streamable_http: "streamable_http";
|
|
18
|
-
webhook: "webhook";
|
|
19
|
-
poll: "poll";
|
|
20
|
-
internal: "internal";
|
|
21
|
-
}>;
|
|
22
|
-
provider: z.ZodOptional<z.ZodString>;
|
|
23
|
-
cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
24
|
-
}, z.core.$strip>;
|
|
25
|
-
export declare const EventLineageSchema: z.ZodObject<{
|
|
26
|
-
protocol: z.ZodLiteral<"mcp-event-intelligence">;
|
|
27
|
-
protocolVersion: z.ZodLiteral<"0.1.0">;
|
|
28
|
-
schemaVersion: z.ZodLiteral<"ei.v0.1">;
|
|
29
|
-
traceId: z.ZodString;
|
|
30
|
-
environmentId: z.ZodString;
|
|
31
|
-
subscriptionId: z.ZodString;
|
|
32
|
-
sourceEventId: z.ZodString;
|
|
33
|
-
observedAt: z.ZodString;
|
|
34
|
-
source: z.ZodObject<{
|
|
35
|
-
serverId: z.ZodString;
|
|
36
|
-
transport: z.ZodEnum<{
|
|
37
|
-
stdio: "stdio";
|
|
38
|
-
streamable_http: "streamable_http";
|
|
39
|
-
webhook: "webhook";
|
|
40
|
-
poll: "poll";
|
|
41
|
-
internal: "internal";
|
|
42
|
-
}>;
|
|
43
|
-
provider: z.ZodOptional<z.ZodString>;
|
|
44
|
-
cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
45
|
-
}, z.core.$strip>;
|
|
46
|
-
target: z.ZodObject<{
|
|
47
|
-
runtime: z.ZodString;
|
|
48
|
-
kind: z.ZodEnum<{
|
|
49
|
-
goal: "goal";
|
|
50
|
-
session: "session";
|
|
51
|
-
conversation: "conversation";
|
|
52
|
-
task: "task";
|
|
53
|
-
spawn_template: "spawn_template";
|
|
54
|
-
}>;
|
|
55
|
-
id: z.ZodString;
|
|
56
|
-
}, z.core.$strip>;
|
|
57
|
-
event: z.ZodObject<{
|
|
58
|
-
name: z.ZodString;
|
|
59
|
-
occurredAt: z.ZodString;
|
|
60
|
-
payloadHash: z.ZodString;
|
|
61
|
-
}, z.core.$strip>;
|
|
62
|
-
}, z.core.$strip>;
|
|
63
|
-
export declare const SemanticDecisionRecordSchema: z.ZodObject<{
|
|
64
|
-
decisionId: z.ZodString;
|
|
65
|
-
traceId: z.ZodString;
|
|
66
|
-
subscriptionId: z.ZodString;
|
|
67
|
-
sourceEventId: z.ZodString;
|
|
68
|
-
createdAt: z.ZodString;
|
|
69
|
-
evaluator: z.ZodString;
|
|
70
|
-
outcome: z.ZodEnum<{
|
|
71
|
-
match: "match";
|
|
72
|
-
reject: "reject";
|
|
73
|
-
uncertain: "uncertain";
|
|
74
|
-
}>;
|
|
75
|
-
probability: z.ZodNumber;
|
|
76
|
-
matched: z.ZodBoolean;
|
|
77
|
-
shouldEscalate: z.ZodBoolean;
|
|
78
|
-
policy: z.ZodObject<{
|
|
79
|
-
matchThreshold: z.ZodNumber;
|
|
80
|
-
rejectThreshold: z.ZodNumber;
|
|
81
|
-
uncertain: z.ZodEnum<{
|
|
82
|
-
match: "match";
|
|
83
|
-
reject: "reject";
|
|
84
|
-
escalate: "escalate";
|
|
85
|
-
}>;
|
|
86
|
-
}, z.core.$strip>;
|
|
87
|
-
inputFields: z.ZodArray<z.ZodString>;
|
|
88
|
-
providerEvidence: z.ZodOptional<z.ZodObject<{
|
|
89
|
-
requestedModel: z.ZodOptional<z.ZodString>;
|
|
90
|
-
resolvedModel: z.ZodOptional<z.ZodString>;
|
|
91
|
-
requestId: z.ZodOptional<z.ZodString>;
|
|
92
|
-
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
93
|
-
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
94
|
-
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
95
|
-
providerReportedCost: z.ZodOptional<z.ZodNumber>;
|
|
96
|
-
}, z.core.$strip>>;
|
|
97
|
-
}, z.core.$strip>;
|
|
98
13
|
export declare const WakeRecordSchema: z.ZodObject<{
|
|
99
14
|
wakeId: z.ZodString;
|
|
100
15
|
traceId: z.ZodString;
|
|
@@ -116,8 +31,6 @@ export declare const WakeRecordSchema: z.ZodObject<{
|
|
|
116
31
|
status: z.ZodEnum<{
|
|
117
32
|
queued: "queued";
|
|
118
33
|
delivered: "delivered";
|
|
119
|
-
handled: "handled";
|
|
120
|
-
duplicate: "duplicate";
|
|
121
34
|
dead_letter: "dead_letter";
|
|
122
35
|
}>;
|
|
123
36
|
runtimeReceiptId: z.ZodOptional<z.ZodString>;
|
|
@@ -130,91 +43,18 @@ export declare const McpEventOccurrenceSchema: z.ZodObject<{
|
|
|
130
43
|
cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
44
|
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
132
45
|
}, z.core.$strip>;
|
|
133
|
-
export declare const SemanticConditionWireSchema: z.ZodObject<{
|
|
134
|
-
type: z.ZodLiteral<"semantic_boolean">;
|
|
135
|
-
instruction: z.ZodString;
|
|
136
|
-
input: z.ZodArray<z.ZodString>;
|
|
137
|
-
matchThreshold: z.ZodNumber;
|
|
138
|
-
rejectThreshold: z.ZodNumber;
|
|
139
|
-
uncertain: z.ZodEnum<{
|
|
140
|
-
match: "match";
|
|
141
|
-
reject: "reject";
|
|
142
|
-
escalate: "escalate";
|
|
143
|
-
}>;
|
|
144
|
-
}, z.core.$strip>;
|
|
145
|
-
export declare const EventIngestRequestSchema: z.ZodObject<{
|
|
146
|
-
event: z.ZodObject<{
|
|
147
|
-
eventId: z.ZodString;
|
|
148
|
-
name: z.ZodString;
|
|
149
|
-
timestamp: z.ZodString;
|
|
150
|
-
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
151
|
-
cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
152
|
-
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
153
|
-
}, z.core.$strip>;
|
|
154
|
-
context: z.ZodObject<{
|
|
155
|
-
traceId: z.ZodOptional<z.ZodString>;
|
|
156
|
-
environmentId: z.ZodString;
|
|
157
|
-
subscriptionId: z.ZodString;
|
|
158
|
-
serverId: z.ZodString;
|
|
159
|
-
transport: z.ZodEnum<{
|
|
160
|
-
stdio: "stdio";
|
|
161
|
-
streamable_http: "streamable_http";
|
|
162
|
-
webhook: "webhook";
|
|
163
|
-
poll: "poll";
|
|
164
|
-
internal: "internal";
|
|
165
|
-
}>;
|
|
166
|
-
provider: z.ZodOptional<z.ZodString>;
|
|
167
|
-
target: z.ZodObject<{
|
|
168
|
-
runtime: z.ZodString;
|
|
169
|
-
kind: z.ZodEnum<{
|
|
170
|
-
goal: "goal";
|
|
171
|
-
session: "session";
|
|
172
|
-
conversation: "conversation";
|
|
173
|
-
task: "task";
|
|
174
|
-
spawn_template: "spawn_template";
|
|
175
|
-
}>;
|
|
176
|
-
id: z.ZodString;
|
|
177
|
-
}, z.core.$strip>;
|
|
178
|
-
}, z.core.$strip>;
|
|
179
|
-
semanticCondition: z.ZodOptional<z.ZodObject<{
|
|
180
|
-
type: z.ZodLiteral<"semantic_boolean">;
|
|
181
|
-
instruction: z.ZodString;
|
|
182
|
-
input: z.ZodArray<z.ZodString>;
|
|
183
|
-
matchThreshold: z.ZodNumber;
|
|
184
|
-
rejectThreshold: z.ZodNumber;
|
|
185
|
-
uncertain: z.ZodEnum<{
|
|
186
|
-
match: "match";
|
|
187
|
-
reject: "reject";
|
|
188
|
-
escalate: "escalate";
|
|
189
|
-
}>;
|
|
190
|
-
}, z.core.$strip>>;
|
|
191
|
-
wakeOnEscalation: z.ZodDefault<z.ZodBoolean>;
|
|
192
|
-
}, z.core.$strip>;
|
|
193
46
|
export declare const LifecycleStateSchema: z.ZodEnum<{
|
|
194
|
-
matched: "matched";
|
|
195
|
-
handled: "handled";
|
|
196
|
-
duplicate: "duplicate";
|
|
197
47
|
dead_letter: "dead_letter";
|
|
198
|
-
received: "received";
|
|
199
|
-
evaluating: "evaluating";
|
|
200
|
-
rejected: "rejected";
|
|
201
|
-
escalated: "escalated";
|
|
202
48
|
wake_queued: "wake_queued";
|
|
203
49
|
wake_delivered: "wake_delivered";
|
|
204
|
-
failed: "failed";
|
|
205
50
|
}>;
|
|
206
51
|
export declare const AuditKindSchema: z.ZodEnum<{
|
|
207
52
|
error: "error";
|
|
208
|
-
"event.received": "event.received";
|
|
209
|
-
"event.duplicate": "event.duplicate";
|
|
210
53
|
"event.late_dropped": "event.late_dropped";
|
|
211
54
|
"event.buffer_overflow": "event.buffer_overflow";
|
|
212
|
-
"decision.evaluated": "decision.evaluated";
|
|
213
|
-
"lifecycle.transition": "lifecycle.transition";
|
|
214
55
|
"wake.queued": "wake.queued";
|
|
215
56
|
"wake.delivered": "wake.delivered";
|
|
216
57
|
"wake.retry_scheduled": "wake.retry_scheduled";
|
|
217
|
-
"wake.handled": "wake.handled";
|
|
218
58
|
"wake.dead_letter": "wake.dead_letter";
|
|
219
59
|
"trigger.partial": "trigger.partial";
|
|
220
60
|
"trigger.correlation": "trigger.correlation";
|
|
@@ -243,16 +83,11 @@ export declare const AuditRecordSchema: z.ZodObject<{
|
|
|
243
83
|
timestamp: z.ZodString;
|
|
244
84
|
kind: z.ZodEnum<{
|
|
245
85
|
error: "error";
|
|
246
|
-
"event.received": "event.received";
|
|
247
|
-
"event.duplicate": "event.duplicate";
|
|
248
86
|
"event.late_dropped": "event.late_dropped";
|
|
249
87
|
"event.buffer_overflow": "event.buffer_overflow";
|
|
250
|
-
"decision.evaluated": "decision.evaluated";
|
|
251
|
-
"lifecycle.transition": "lifecycle.transition";
|
|
252
88
|
"wake.queued": "wake.queued";
|
|
253
89
|
"wake.delivered": "wake.delivered";
|
|
254
90
|
"wake.retry_scheduled": "wake.retry_scheduled";
|
|
255
|
-
"wake.handled": "wake.handled";
|
|
256
91
|
"wake.dead_letter": "wake.dead_letter";
|
|
257
92
|
"trigger.partial": "trigger.partial";
|
|
258
93
|
"trigger.correlation": "trigger.correlation";
|
|
@@ -277,7 +112,6 @@ export declare const AuditRecordSchema: z.ZodObject<{
|
|
|
277
112
|
entityType: z.ZodEnum<{
|
|
278
113
|
runtime: "runtime";
|
|
279
114
|
event: "event";
|
|
280
|
-
decision: "decision";
|
|
281
115
|
wake: "wake";
|
|
282
116
|
subscription: "subscription";
|
|
283
117
|
trigger_match: "trigger_match";
|
|
@@ -288,30 +122,14 @@ export declare const AuditRecordSchema: z.ZodObject<{
|
|
|
288
122
|
}>;
|
|
289
123
|
entityId: z.ZodString;
|
|
290
124
|
fromState: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
291
|
-
matched: "matched";
|
|
292
|
-
handled: "handled";
|
|
293
|
-
duplicate: "duplicate";
|
|
294
125
|
dead_letter: "dead_letter";
|
|
295
|
-
received: "received";
|
|
296
|
-
evaluating: "evaluating";
|
|
297
|
-
rejected: "rejected";
|
|
298
|
-
escalated: "escalated";
|
|
299
126
|
wake_queued: "wake_queued";
|
|
300
127
|
wake_delivered: "wake_delivered";
|
|
301
|
-
failed: "failed";
|
|
302
128
|
}>>>;
|
|
303
129
|
toState: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
304
|
-
matched: "matched";
|
|
305
|
-
handled: "handled";
|
|
306
|
-
duplicate: "duplicate";
|
|
307
130
|
dead_letter: "dead_letter";
|
|
308
|
-
received: "received";
|
|
309
|
-
evaluating: "evaluating";
|
|
310
|
-
rejected: "rejected";
|
|
311
|
-
escalated: "escalated";
|
|
312
131
|
wake_queued: "wake_queued";
|
|
313
132
|
wake_delivered: "wake_delivered";
|
|
314
|
-
failed: "failed";
|
|
315
133
|
}>>>;
|
|
316
134
|
details: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
317
135
|
previousHash: z.ZodNullable<z.ZodString>;
|
|
@@ -319,15 +137,8 @@ export declare const AuditRecordSchema: z.ZodObject<{
|
|
|
319
137
|
}, z.core.$strip>;
|
|
320
138
|
export type RuntimeTarget = z.infer<typeof RuntimeTargetSchema>;
|
|
321
139
|
export type McpEventOccurrence = z.infer<typeof McpEventOccurrenceSchema>;
|
|
322
|
-
export type SemanticConditionWire = z.infer<typeof SemanticConditionWireSchema>;
|
|
323
|
-
export type EventIngestRequest = z.infer<typeof EventIngestRequestSchema>;
|
|
324
|
-
export type EventLineage = z.infer<typeof EventLineageSchema>;
|
|
325
|
-
export type SemanticDecisionRecord = z.infer<typeof SemanticDecisionRecordSchema>;
|
|
326
140
|
export type WakeRecord = z.infer<typeof WakeRecordSchema>;
|
|
327
141
|
export type LifecycleState = z.infer<typeof LifecycleStateSchema>;
|
|
328
142
|
export type AuditRecord = z.infer<typeof AuditRecordSchema>;
|
|
329
|
-
export declare function parseEventIngestRequest(value: unknown): EventIngestRequest;
|
|
330
|
-
export declare function parseEventLineage(value: unknown): EventLineage;
|
|
331
|
-
export declare function parseSemanticDecisionRecord(value: unknown): SemanticDecisionRecord;
|
|
332
143
|
export declare function parseWakeRecord(value: unknown): WakeRecord;
|
|
333
144
|
export declare function parseAuditRecord(value: unknown): AuditRecord;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { EVENT_INTELLIGENCE_PROTOCOL, EVENT_INTELLIGENCE_PROTOCOL_VERSION, EVENT_INTELLIGENCE_SCHEMA_VERSION, } from './version.js';
|
|
3
2
|
const Id = z.string().min(1).max(200);
|
|
4
3
|
const Timestamp = z.string().datetime({ offset: true });
|
|
5
4
|
export const RuntimeTargetSchema = z.object({
|
|
@@ -7,56 +6,6 @@ export const RuntimeTargetSchema = z.object({
|
|
|
7
6
|
kind: z.enum(['goal', 'session', 'conversation', 'task', 'spawn_template']),
|
|
8
7
|
id: Id,
|
|
9
8
|
});
|
|
10
|
-
export const EventSourceSchema = z.object({
|
|
11
|
-
serverId: Id,
|
|
12
|
-
transport: z.enum(['stdio', 'streamable_http', 'webhook', 'poll', 'internal']),
|
|
13
|
-
provider: z.string().min(1).optional(),
|
|
14
|
-
cursor: z.string().nullable().optional(),
|
|
15
|
-
});
|
|
16
|
-
export const EventLineageSchema = z.object({
|
|
17
|
-
protocol: z.literal(EVENT_INTELLIGENCE_PROTOCOL),
|
|
18
|
-
protocolVersion: z.literal(EVENT_INTELLIGENCE_PROTOCOL_VERSION),
|
|
19
|
-
schemaVersion: z.literal(EVENT_INTELLIGENCE_SCHEMA_VERSION),
|
|
20
|
-
traceId: Id,
|
|
21
|
-
environmentId: Id,
|
|
22
|
-
subscriptionId: Id,
|
|
23
|
-
sourceEventId: Id,
|
|
24
|
-
observedAt: Timestamp,
|
|
25
|
-
source: EventSourceSchema,
|
|
26
|
-
target: RuntimeTargetSchema,
|
|
27
|
-
event: z.object({
|
|
28
|
-
name: z.string().min(1),
|
|
29
|
-
occurredAt: Timestamp,
|
|
30
|
-
payloadHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
31
|
-
}),
|
|
32
|
-
});
|
|
33
|
-
export const SemanticDecisionRecordSchema = z.object({
|
|
34
|
-
decisionId: Id,
|
|
35
|
-
traceId: Id,
|
|
36
|
-
subscriptionId: Id,
|
|
37
|
-
sourceEventId: Id,
|
|
38
|
-
createdAt: Timestamp,
|
|
39
|
-
evaluator: z.string().min(1),
|
|
40
|
-
outcome: z.enum(['match', 'reject', 'uncertain']),
|
|
41
|
-
probability: z.number().min(0).max(1),
|
|
42
|
-
matched: z.boolean(),
|
|
43
|
-
shouldEscalate: z.boolean(),
|
|
44
|
-
policy: z.object({
|
|
45
|
-
matchThreshold: z.number().min(0).max(1),
|
|
46
|
-
rejectThreshold: z.number().min(0).max(1),
|
|
47
|
-
uncertain: z.enum(['escalate', 'reject', 'match']),
|
|
48
|
-
}),
|
|
49
|
-
inputFields: z.array(z.string().min(1)),
|
|
50
|
-
providerEvidence: z.object({
|
|
51
|
-
requestedModel: z.string().min(1).optional(),
|
|
52
|
-
resolvedModel: z.string().min(1).optional(),
|
|
53
|
-
requestId: z.string().min(1).optional(),
|
|
54
|
-
httpStatus: z.number().int().min(100).max(599).optional(),
|
|
55
|
-
inputTokens: z.number().int().nonnegative().optional(),
|
|
56
|
-
outputTokens: z.number().int().nonnegative().optional(),
|
|
57
|
-
providerReportedCost: z.number().nonnegative().optional(),
|
|
58
|
-
}).optional(),
|
|
59
|
-
});
|
|
60
9
|
export const WakeRecordSchema = z.object({
|
|
61
10
|
wakeId: Id,
|
|
62
11
|
traceId: Id,
|
|
@@ -65,7 +14,7 @@ export const WakeRecordSchema = z.object({
|
|
|
65
14
|
sourceEventId: Id,
|
|
66
15
|
createdAt: Timestamp,
|
|
67
16
|
target: RuntimeTargetSchema,
|
|
68
|
-
status: z.enum(['queued', 'delivered', '
|
|
17
|
+
status: z.enum(['queued', 'delivered', 'dead_letter']),
|
|
69
18
|
runtimeReceiptId: Id.optional(),
|
|
70
19
|
});
|
|
71
20
|
export const McpEventOccurrenceSchema = z.object({
|
|
@@ -76,52 +25,17 @@ export const McpEventOccurrenceSchema = z.object({
|
|
|
76
25
|
cursor: z.string().nullable().optional(),
|
|
77
26
|
_meta: z.record(z.string(), z.unknown()).optional(),
|
|
78
27
|
});
|
|
79
|
-
export const SemanticConditionWireSchema = z.object({
|
|
80
|
-
type: z.literal('semantic_boolean'),
|
|
81
|
-
instruction: z.string().min(1),
|
|
82
|
-
input: z.array(z.string().min(1)).min(1),
|
|
83
|
-
matchThreshold: z.number().min(0).max(1),
|
|
84
|
-
rejectThreshold: z.number().min(0).max(1),
|
|
85
|
-
uncertain: z.enum(['escalate', 'reject', 'match']),
|
|
86
|
-
});
|
|
87
|
-
export const EventIngestRequestSchema = z.object({
|
|
88
|
-
event: McpEventOccurrenceSchema,
|
|
89
|
-
context: z.object({
|
|
90
|
-
traceId: Id.optional(),
|
|
91
|
-
environmentId: Id,
|
|
92
|
-
subscriptionId: Id,
|
|
93
|
-
serverId: Id,
|
|
94
|
-
transport: z.enum(['stdio', 'streamable_http', 'webhook', 'poll', 'internal']),
|
|
95
|
-
provider: z.string().min(1).optional(),
|
|
96
|
-
target: RuntimeTargetSchema,
|
|
97
|
-
}),
|
|
98
|
-
semanticCondition: SemanticConditionWireSchema.optional(),
|
|
99
|
-
wakeOnEscalation: z.boolean().default(false),
|
|
100
|
-
});
|
|
101
28
|
export const LifecycleStateSchema = z.enum([
|
|
102
|
-
'received',
|
|
103
|
-
'duplicate',
|
|
104
|
-
'evaluating',
|
|
105
|
-
'matched',
|
|
106
|
-
'rejected',
|
|
107
|
-
'escalated',
|
|
108
29
|
'wake_queued',
|
|
109
30
|
'wake_delivered',
|
|
110
|
-
'handled',
|
|
111
|
-
'failed',
|
|
112
31
|
'dead_letter',
|
|
113
32
|
]);
|
|
114
33
|
export const AuditKindSchema = z.enum([
|
|
115
|
-
'event.received',
|
|
116
|
-
'event.duplicate',
|
|
117
34
|
'event.late_dropped',
|
|
118
35
|
'event.buffer_overflow',
|
|
119
|
-
'decision.evaluated',
|
|
120
|
-
'lifecycle.transition',
|
|
121
36
|
'wake.queued',
|
|
122
37
|
'wake.delivered',
|
|
123
38
|
'wake.retry_scheduled',
|
|
124
|
-
'wake.handled',
|
|
125
39
|
'wake.dead_letter',
|
|
126
40
|
'trigger.partial',
|
|
127
41
|
'trigger.correlation',
|
|
@@ -152,7 +66,6 @@ export const AuditRecordSchema = z.object({
|
|
|
152
66
|
kind: AuditKindSchema,
|
|
153
67
|
entityType: z.enum([
|
|
154
68
|
'event',
|
|
155
|
-
'decision',
|
|
156
69
|
'wake',
|
|
157
70
|
'subscription',
|
|
158
71
|
'runtime',
|
|
@@ -169,15 +82,6 @@ export const AuditRecordSchema = z.object({
|
|
|
169
82
|
previousHash: z.string().regex(/^[a-f0-9]{64}$/).nullable(),
|
|
170
83
|
hash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
171
84
|
});
|
|
172
|
-
export function parseEventIngestRequest(value) {
|
|
173
|
-
return EventIngestRequestSchema.parse(value);
|
|
174
|
-
}
|
|
175
|
-
export function parseEventLineage(value) {
|
|
176
|
-
return EventLineageSchema.parse(value);
|
|
177
|
-
}
|
|
178
|
-
export function parseSemanticDecisionRecord(value) {
|
|
179
|
-
return SemanticDecisionRecordSchema.parse(value);
|
|
180
|
-
}
|
|
181
85
|
export function parseWakeRecord(value) {
|
|
182
86
|
return WakeRecordSchema.parse(value);
|
|
183
87
|
}
|
|
@@ -78,15 +78,6 @@ export declare const TriggerPlanEventSchema: z.ZodObject<{
|
|
|
78
78
|
value: z.ZodNumber;
|
|
79
79
|
}, z.core.$strip>], "op">>>;
|
|
80
80
|
}, z.core.$strict>;
|
|
81
|
-
export declare const TriggerPlanMatchSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
82
|
-
any: "any";
|
|
83
|
-
sequence: "sequence";
|
|
84
|
-
all: "all";
|
|
85
|
-
}>, z.ZodObject<{
|
|
86
|
-
kind: z.ZodLiteral<"count">;
|
|
87
|
-
eventId: z.ZodString;
|
|
88
|
-
atLeast: z.ZodNumber;
|
|
89
|
-
}, z.core.$strict>]>;
|
|
90
81
|
export declare const TriggerPlanInputSchema: z.ZodObject<{
|
|
91
82
|
triggerId: z.ZodOptional<z.ZodString>;
|
|
92
83
|
version: z.ZodDefault<z.ZodString>;
|
|
@@ -170,83 +161,7 @@ export declare const TriggerPlanInputSchema: z.ZodObject<{
|
|
|
170
161
|
value: z.ZodNumber;
|
|
171
162
|
}, z.core.$strip>], "op">>>;
|
|
172
163
|
}, z.core.$strict>>;
|
|
173
|
-
|
|
174
|
-
any: "any";
|
|
175
|
-
sequence: "sequence";
|
|
176
|
-
all: "all";
|
|
177
|
-
}>, z.ZodObject<{
|
|
178
|
-
kind: z.ZodLiteral<"count">;
|
|
179
|
-
eventId: z.ZodString;
|
|
180
|
-
atLeast: z.ZodNumber;
|
|
181
|
-
}, z.core.$strict>]>>;
|
|
182
|
-
withinMs: z.ZodDefault<z.ZodNumber>;
|
|
183
|
-
eventTime: z.ZodOptional<z.ZodObject<{
|
|
184
|
-
allowedLatenessMs: z.ZodNumber;
|
|
185
|
-
}, z.core.$strict>>;
|
|
186
|
-
temporal: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
187
|
-
id: z.ZodString;
|
|
188
|
-
kind: z.ZodLiteral<"calendar">;
|
|
189
|
-
ref: z.ZodString;
|
|
190
|
-
timezone: z.ZodString;
|
|
191
|
-
before: z.ZodOptional<z.ZodString>;
|
|
192
|
-
after: z.ZodOptional<z.ZodString>;
|
|
193
|
-
weekdays: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
194
|
-
dates: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
195
|
-
dateRange: z.ZodOptional<z.ZodObject<{
|
|
196
|
-
start: z.ZodString;
|
|
197
|
-
end: z.ZodString;
|
|
198
|
-
}, z.core.$strip>>;
|
|
199
|
-
dayOfMonth: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
200
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
201
|
-
id: z.ZodString;
|
|
202
|
-
kind: z.ZodLiteral<"absence">;
|
|
203
|
-
ref: z.ZodString;
|
|
204
|
-
afterRef: z.ZodString;
|
|
205
|
-
forMs: z.ZodOptional<z.ZodNumber>;
|
|
206
|
-
untilLocalTime: z.ZodOptional<z.ZodString>;
|
|
207
|
-
timezone: z.ZodOptional<z.ZodString>;
|
|
208
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
209
|
-
id: z.ZodString;
|
|
210
|
-
kind: z.ZodLiteral<"not">;
|
|
211
|
-
ref: z.ZodString;
|
|
212
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
213
|
-
id: z.ZodString;
|
|
214
|
-
kind: z.ZodLiteral<"unless">;
|
|
215
|
-
ref: z.ZodString;
|
|
216
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
217
|
-
id: z.ZodString;
|
|
218
|
-
kind: z.ZodLiteral<"after">;
|
|
219
|
-
ref: z.ZodString;
|
|
220
|
-
afterRef: z.ZodString;
|
|
221
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
222
|
-
id: z.ZodString;
|
|
223
|
-
kind: z.ZodLiteral<"until">;
|
|
224
|
-
ref: z.ZodString;
|
|
225
|
-
beforeRef: z.ZodString;
|
|
226
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
227
|
-
id: z.ZodString;
|
|
228
|
-
kind: z.ZodLiteral<"debounce">;
|
|
229
|
-
ref: z.ZodString;
|
|
230
|
-
forMs: z.ZodNumber;
|
|
231
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
232
|
-
id: z.ZodString;
|
|
233
|
-
kind: z.ZodLiteral<"threshold">;
|
|
234
|
-
ref: z.ZodString;
|
|
235
|
-
atLeast: z.ZodNumber;
|
|
236
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
237
|
-
id: z.ZodString;
|
|
238
|
-
kind: z.ZodLiteral<"rate">;
|
|
239
|
-
ref: z.ZodString;
|
|
240
|
-
atLeast: z.ZodNumber;
|
|
241
|
-
perMs: z.ZodNumber;
|
|
242
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
243
|
-
id: z.ZodString;
|
|
244
|
-
kind: z.ZodLiteral<"distinct">;
|
|
245
|
-
ref: z.ZodString;
|
|
246
|
-
path: z.ZodString;
|
|
247
|
-
atLeast: z.ZodNumber;
|
|
248
|
-
}, z.core.$strip>], "kind">>>;
|
|
249
|
-
patternV2: z.ZodOptional<z.ZodObject<{
|
|
164
|
+
pattern: z.ZodOptional<z.ZodObject<{
|
|
250
165
|
version: z.ZodDefault<z.ZodLiteral<"2">>;
|
|
251
166
|
root: z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>;
|
|
252
167
|
partitionBy: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -280,6 +195,10 @@ export declare const TriggerPlanInputSchema: z.ZodObject<{
|
|
|
280
195
|
maxBufferedEvents: z.ZodDefault<z.ZodNumber>;
|
|
281
196
|
}, z.core.$strict>>;
|
|
282
197
|
}, z.core.$strict>>;
|
|
198
|
+
withinMs: z.ZodDefault<z.ZodNumber>;
|
|
199
|
+
eventTime: z.ZodOptional<z.ZodObject<{
|
|
200
|
+
allowedLatenessMs: z.ZodNumber;
|
|
201
|
+
}, z.core.$strict>>;
|
|
283
202
|
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
284
203
|
oneShot: z.ZodOptional<z.ZodBoolean>;
|
|
285
204
|
maxFirings: z.ZodOptional<z.ZodNumber>;
|
|
@@ -311,23 +230,7 @@ export declare const TriggerPlanInputSchema: z.ZodObject<{
|
|
|
311
230
|
includeData: z.ZodDefault<z.ZodBoolean>;
|
|
312
231
|
}, z.core.$strict>>;
|
|
313
232
|
}, z.core.$strict>>;
|
|
314
|
-
correlateBy: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
315
|
-
eventId: z.ZodString;
|
|
316
|
-
path: z.ZodString;
|
|
317
|
-
}, z.core.$strict>>>;
|
|
318
|
-
semanticCorrelation: z.ZodOptional<z.ZodObject<{
|
|
319
|
-
instruction: z.ZodString;
|
|
320
|
-
input: z.ZodArray<z.ZodString>;
|
|
321
|
-
matchThreshold: z.ZodNumber;
|
|
322
|
-
rejectThreshold: z.ZodNumber;
|
|
323
|
-
uncertain: z.ZodDefault<z.ZodEnum<{
|
|
324
|
-
match: "match";
|
|
325
|
-
reject: "reject";
|
|
326
|
-
escalate: "escalate";
|
|
327
|
-
}>>;
|
|
328
|
-
}, z.core.$strip>>;
|
|
329
233
|
}, z.core.$strict>;
|
|
330
234
|
export type TriggerPlanEvent = z.infer<typeof TriggerPlanEventSchema>;
|
|
331
|
-
export type TriggerPlanMatch = z.infer<typeof TriggerPlanMatchSchema>;
|
|
332
235
|
export type TriggerPlanInput = z.infer<typeof TriggerPlanInputSchema>;
|
|
333
236
|
export declare function parseTriggerPlanInput(value: unknown): TriggerPlanInput;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { RuntimeTargetSchema } from './schemas.js';
|
|
3
3
|
import { PatternAstV2DefinitionSchema, } from './patternV2Schemas.js';
|
|
4
|
-
import { ContinuationContractSchema,
|
|
4
|
+
import { ContinuationContractSchema, StructuredPredicateSchema, } from './triggerSchemas.js';
|
|
5
5
|
const Id = z.string().min(1).max(200);
|
|
6
6
|
export const TriggerPlanEventSchema = z.object({
|
|
7
7
|
id: Id.optional(),
|
|
@@ -10,28 +10,18 @@ export const TriggerPlanEventSchema = z.object({
|
|
|
10
10
|
arguments: z.record(z.string(), z.unknown()).default({}),
|
|
11
11
|
where: z.array(StructuredPredicateSchema).default([]),
|
|
12
12
|
}).strict();
|
|
13
|
-
export const TriggerPlanMatchSchema = z.union([
|
|
14
|
-
z.enum(['all', 'any', 'sequence']),
|
|
15
|
-
z.object({
|
|
16
|
-
kind: z.literal('count'),
|
|
17
|
-
eventId: Id,
|
|
18
|
-
atLeast: z.number().int().min(1),
|
|
19
|
-
}).strict(),
|
|
20
|
-
]);
|
|
21
13
|
export const TriggerPlanInputSchema = z.object({
|
|
22
14
|
triggerId: Id.optional(),
|
|
23
15
|
version: z.string().min(1).default('1'),
|
|
24
16
|
description: z.string().max(500).optional(),
|
|
25
17
|
events: z.array(TriggerPlanEventSchema).min(1),
|
|
26
|
-
|
|
18
|
+
pattern: PatternAstV2DefinitionSchema.optional(),
|
|
27
19
|
withinMs: z.number().int().positive().max(1000 * 60 * 60 * 24 * 30)
|
|
28
20
|
.default(60 * 60 * 1000),
|
|
29
21
|
eventTime: z.object({
|
|
30
22
|
allowedLatenessMs: z.number().int().nonnegative()
|
|
31
23
|
.max(1000 * 60 * 60 * 24 * 30),
|
|
32
24
|
}).strict().optional(),
|
|
33
|
-
temporal: z.array(TemporalConditionSchema).default([]),
|
|
34
|
-
patternV2: PatternAstV2DefinitionSchema.optional(),
|
|
35
25
|
lifecycle: z.object({
|
|
36
26
|
oneShot: z.boolean().optional(),
|
|
37
27
|
maxFirings: z.number().int().min(1).optional(),
|
|
@@ -43,21 +33,7 @@ export const TriggerPlanInputSchema = z.object({
|
|
|
43
33
|
conditionOnly: z.boolean().default(false),
|
|
44
34
|
target: RuntimeTargetSchema.optional(),
|
|
45
35
|
continuation: ContinuationContractSchema.optional(),
|
|
46
|
-
correlateBy: z.array(z.object({
|
|
47
|
-
eventId: Id,
|
|
48
|
-
path: z.string().min(1),
|
|
49
|
-
}).strict()).min(2).optional(),
|
|
50
|
-
semanticCorrelation: SemanticCorrelationSchema.optional(),
|
|
51
36
|
}).strict().superRefine((value, ctx) => {
|
|
52
|
-
if (value.patternV2 &&
|
|
53
|
-
(value.temporal.length > 0 ||
|
|
54
|
-
value.correlateBy ||
|
|
55
|
-
value.semanticCorrelation)) {
|
|
56
|
-
ctx.addIssue({
|
|
57
|
-
code: 'custom',
|
|
58
|
-
message: 'patternV2 cannot be combined with legacy temporal/correlation fields',
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
37
|
if (value.conditionOnly) {
|
|
62
38
|
if (value.target || value.continuation) {
|
|
63
39
|
ctx.addIssue({
|