mcp-event-intelligence 0.2.1 → 0.3.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 +46 -0
- package/README.md +64 -11
- package/bin/mcp-event-intelligence.mjs +1 -1
- package/dist/src/composite/matching.js +8 -0
- package/dist/src/intelligenceProtocol/activationSchemas.d.ts +67 -0
- package/dist/src/intelligenceProtocol/activationSchemas.js +51 -0
- package/dist/src/intelligenceProtocol/index.d.ts +6 -2
- package/dist/src/intelligenceProtocol/index.js +3 -1
- package/dist/src/intelligenceProtocol/triggerPlanSchemas.d.ts +158 -0
- package/dist/src/intelligenceProtocol/triggerPlanSchemas.js +45 -0
- package/dist/src/intelligenceProtocol/triggerSchemas.d.ts +80 -0
- package/dist/src/intelligenceProtocol/triggerSchemas.js +24 -0
- package/package.json +1 -1
- package/scripts/host-integration.d.mts +17 -0
- package/scripts/host-integration.mjs +20 -0
- package/scripts/lib/activation-hydrator.mjs +140 -0
- package/scripts/lib/local-event-intelligence-runtime.mjs +16 -2
- package/scripts/lib/trigger-inspector.mjs +1 -0
- package/scripts/lib/trigger-planner.mjs +247 -0
- package/scripts/mcp-stdio-server.mjs +123 -13
- package/server.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
All notable public changes are documented here.
|
|
4
4
|
|
|
5
|
+
## [0.3.0] - 2026-09-20
|
|
6
|
+
|
|
7
|
+
Agent-integration release focused on making Event Intelligence usable as a plug-and-play future-condition primitive.
|
|
8
|
+
|
|
9
|
+
### Agent-friendly trigger planning
|
|
10
|
+
|
|
11
|
+
- added deterministic `TriggerPlanInput` contracts;
|
|
12
|
+
- added `host.planTrigger()` / scoped `planTrigger()`;
|
|
13
|
+
- planner resolves live event sources and server IDs;
|
|
14
|
+
- planner validates predicate paths against advertised payload schemas;
|
|
15
|
+
- planner compiles `all`, `any`, `sequence` and `count` into the canonical trigger DSL;
|
|
16
|
+
- added numeric predicates `gt`, `gte`, `lt` and `lte`.
|
|
17
|
+
|
|
18
|
+
### Continuations and activation
|
|
19
|
+
|
|
20
|
+
- trigger definitions may now persist a first-class `continuation` contract;
|
|
21
|
+
- continuation instructions are separated from the condition that wakes the runtime;
|
|
22
|
+
- added Activation Envelope contracts;
|
|
23
|
+
- added `host.hydrateWake(wakeId)` / scoped `hydrateWake(wakeId)`;
|
|
24
|
+
- hydrated evidence can include matched event payloads according to the trigger context policy;
|
|
25
|
+
- activation evidence is explicitly labeled as untrusted external signal data;
|
|
26
|
+
- the wire wake remains reference-only by default.
|
|
27
|
+
|
|
28
|
+
### Embedded host ergonomics
|
|
29
|
+
|
|
30
|
+
- embedded wake callbacks may now receive `(packet, activation)`;
|
|
31
|
+
- existing one-argument callbacks remain compatible;
|
|
32
|
+
- trigger inspection now includes the persisted continuation contract.
|
|
33
|
+
|
|
34
|
+
### MCP control plane
|
|
35
|
+
|
|
36
|
+
- added non-mutating `trigger_plan`;
|
|
37
|
+
- added non-mutating `wake_hydrate`;
|
|
38
|
+
- `trigger_create` now accepts either a raw canonical definition or an agent-friendly plan;
|
|
39
|
+
- plan-based creation still uses the same confirmation, source-scope, owner and version checks.
|
|
40
|
+
|
|
41
|
+
### Verification
|
|
42
|
+
|
|
43
|
+
- end-to-end coverage verifies plan -> canonical trigger -> numeric predicate match -> reference-only wake -> hydrated activation -> runtime receipt;
|
|
44
|
+
- context-policy coverage verifies refs-only activation evidence;
|
|
45
|
+
- clean-room smoke now installs the candidate packed artifact rather than an old hard-coded npm version.
|
|
46
|
+
|
|
47
|
+
### Compatibility
|
|
48
|
+
|
|
49
|
+
Persisted protocol and trigger schema version identifiers remain at the v0.1 compatibility line. The new continuation field is optional, so existing stored triggers remain readable. Existing wake packets remain reference-only and unchanged on the wire.
|
|
50
|
+
|
|
5
51
|
## [0.2.1] - 2026-09-20
|
|
6
52
|
|
|
7
53
|
Patch hardening for shutdown determinism and multi-tenant verification.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://github.com/sarooo17/event-intelligence/actions/workflows/ci.yml)
|
|
6
6
|
[](https://www.npmjs.com/package/mcp-event-intelligence)
|
|
7
|
-
[](https://registry.modelcontextprotocol.io/?q=io.github.sarooo17%2Fevent-intelligence)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
|
|
10
10
|
MCP Event Intelligence is an experimental event runtime for agents that need to react to **future conditions over multiple event sources** without keeping an LLM or agent loop alive.
|
|
@@ -45,8 +45,11 @@ const ei = await createEventIntelligenceHost({
|
|
|
45
45
|
listConnections: () => host.mcp.listConnections(),
|
|
46
46
|
subscribe: (refresh) => host.mcp.onConnectionsChanged(refresh),
|
|
47
47
|
}),
|
|
48
|
-
wake: async (packet) => {
|
|
49
|
-
const receipt = await host.resume(packet.target,
|
|
48
|
+
wake: async (packet, activation) => {
|
|
49
|
+
const receipt = await host.resume(packet.target, {
|
|
50
|
+
packet,
|
|
51
|
+
activation,
|
|
52
|
+
});
|
|
50
53
|
return { runtimeReceiptId: receipt.id };
|
|
51
54
|
},
|
|
52
55
|
});
|
|
@@ -54,6 +57,52 @@ const ei = await createEventIntelligenceHost({
|
|
|
54
57
|
|
|
55
58
|
Event Intelligence enumerates the host registry automatically. GitHub, Gmail, private/company MCPs and future connections do not need to be configured again inside EI. Tools-only MCPs remain available to the agent and are ignored by the Events layer; Events-capable MCPs are attached automatically.
|
|
56
59
|
|
|
60
|
+
### Agent-first trigger flow
|
|
61
|
+
|
|
62
|
+
Agents no longer need to construct the low-level trigger DSL directly for common cases. Ask EI to compile an agent-friendly plan against the event sources that are actually available:
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
const plan = await ei.planTrigger({
|
|
66
|
+
events: [{
|
|
67
|
+
id: 'invoice',
|
|
68
|
+
event: 'erpnext.sales_invoice.submitted',
|
|
69
|
+
where: [
|
|
70
|
+
{ path: 'grand_total', op: 'gt', value: 10000 },
|
|
71
|
+
],
|
|
72
|
+
}],
|
|
73
|
+
match: 'all',
|
|
74
|
+
withinMs: 60 * 60 * 1000,
|
|
75
|
+
target: {
|
|
76
|
+
runtime: 'agent',
|
|
77
|
+
kind: 'conversation',
|
|
78
|
+
id: 'chat-42',
|
|
79
|
+
},
|
|
80
|
+
continuation: {
|
|
81
|
+
instruction:
|
|
82
|
+
'Check the submitted invoice for anomalies and report back in this conversation.',
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
await ei.triggerControl.createTrigger({
|
|
87
|
+
definition: plan.definition,
|
|
88
|
+
connectionIds: plan.connectionIds,
|
|
89
|
+
actor,
|
|
90
|
+
owner,
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`planTrigger()` is deterministic. It does not call a model. It resolves event names to live source/server IDs, validates predicate paths against advertised payload schemas, compiles `all` / `any` / `sequence` / `count`, and returns the canonical trigger definition plus the required connection IDs.
|
|
95
|
+
|
|
96
|
+
The persisted `continuation` answers a separate question from the trigger condition: **what should the agent do after the future condition becomes true?**
|
|
97
|
+
|
|
98
|
+
The wire wake remains deliberately small and reference-only. Embedded hosts also receive an Activation Envelope as the second wake argument. The same envelope can be reconstructed later:
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
const activation = ei.hydrateWake(wakeId);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The envelope contains the configured continuation, trigger/match state, and matched evidence. Event payloads are labeled as untrusted external signals and are included only according to the trigger's `continuation.contextPolicy`.
|
|
105
|
+
|
|
57
106
|
|
|
58
107
|
### Shared hosts, tenant isolation and storage
|
|
59
108
|
|
|
@@ -154,7 +203,7 @@ timezone normalization and deterministic occurrence IDs. The local factory in
|
|
|
154
203
|
this package should therefore be read as a typed convenience API, not as the
|
|
155
204
|
production ERP connector itself.
|
|
156
205
|
|
|
157
|
-
## What v0.
|
|
206
|
+
## What v0.3 implements
|
|
158
207
|
|
|
159
208
|
### Host-owned event sources
|
|
160
209
|
|
|
@@ -182,7 +231,11 @@ production ERP connector itself.
|
|
|
182
231
|
### Agent-authored continuations
|
|
183
232
|
|
|
184
233
|
- event-source discovery;
|
|
185
|
-
- agent-
|
|
234
|
+
- agent-friendly deterministic trigger planning/compilation;
|
|
235
|
+
- `eq`, `neq`, `contains`, `in`, `exists`, `gt`, `gte`, `lt`, `lte` predicates;
|
|
236
|
+
- persisted continuation contracts separated from trigger conditions;
|
|
237
|
+
- Activation Envelope hydration with matched event evidence;
|
|
238
|
+
- embedded wake callbacks receive `(packet, activation)`;
|
|
186
239
|
- deterministic validation against real source schemas and advertised fields;
|
|
187
240
|
- approval-gated persistent mutations;
|
|
188
241
|
- one-shot, cooldown, max-firings, expiry, leases, update and delete.
|
|
@@ -251,7 +304,7 @@ The agent/harness is already responsible for reasoning and can author a structur
|
|
|
251
304
|
|
|
252
305
|
## Full-system acceptance
|
|
253
306
|
|
|
254
|
-
The v0.
|
|
307
|
+
The v0.3 acceptance suite verifies:
|
|
255
308
|
|
|
256
309
|
- host-owned MCP client → event discovery/poll → composite match → in-process wake;
|
|
257
310
|
- provider-neutral events → composite match → derived event → derived composition → signed runtime wake;
|
|
@@ -297,13 +350,13 @@ The standalone service supports manual/provider-native event ingress. It does no
|
|
|
297
350
|
### Docker
|
|
298
351
|
|
|
299
352
|
```bash
|
|
300
|
-
docker build -t mcp-event-intelligence:0.
|
|
353
|
+
docker build -t mcp-event-intelligence:0.3.0 .
|
|
301
354
|
|
|
302
355
|
docker run --rm \
|
|
303
356
|
-p 3000:3000 \
|
|
304
357
|
-v mcp-event-intelligence-data:/data \
|
|
305
358
|
-e SERVICE_AUTH_TOKEN="$(openssl rand -hex 32)" \
|
|
306
|
-
mcp-event-intelligence:0.
|
|
359
|
+
mcp-event-intelligence:0.3.0
|
|
307
360
|
```
|
|
308
361
|
|
|
309
362
|
## Optional MCP control plane
|
|
@@ -314,7 +367,7 @@ The package also exposes a standard **MCP stdio** control plane through the offi
|
|
|
314
367
|
npx mcp-event-intelligence mcp
|
|
315
368
|
```
|
|
316
369
|
|
|
317
|
-
Read/non-mutating tools are exposed by default, including `event_sources_list`, inspection, simulation, contracts and runtime status.
|
|
370
|
+
Read/non-mutating tools are exposed by default, including `event_sources_list`, `trigger_plan`, inspection, simulation, `wake_hydrate`, contracts and runtime status. `trigger_create` accepts either a raw canonical definition or the same agent-friendly plan shape; EI compiles the latter before applying the normal mutation controls.
|
|
318
371
|
|
|
319
372
|
Persistent trigger mutations are only registered when the operator explicitly enables `MCP_WRITE_ENABLED=true`, and each mutation still requires a `confirmationId`. The MCP server is a control-plane adapter; it is **not** a gateway through which the host's other MCP servers must be reconnected.
|
|
320
373
|
|
|
@@ -367,7 +420,7 @@ It uses stable wake IDs, persisted delivery state, atomic claim leases, bounded
|
|
|
367
420
|
|
|
368
421
|
A derived event says **what became true at a point in history**.
|
|
369
422
|
|
|
370
|
-
v0.
|
|
423
|
+
v0.3 intentionally does not implement a mutable current-state/facts database.
|
|
371
424
|
|
|
372
425
|
## Security
|
|
373
426
|
|
|
@@ -392,7 +445,7 @@ io.github.sarooo17/event-intelligence
|
|
|
392
445
|
|
|
393
446
|
## Project status
|
|
394
447
|
|
|
395
|
-
**v0.
|
|
448
|
+
**v0.3 reference implementation / experimental.**
|
|
396
449
|
|
|
397
450
|
The architecture is implemented and exercised end-to-end. Storage is now injectable and scoped, while the bundled JSONL backend remains a single-process reference implementation. Remaining work is primarily production database adapters/HA validation, scale benchmarks and upstream feedback.
|
|
398
451
|
|
|
@@ -33,6 +33,14 @@ function predicateMatches(event, predicate) {
|
|
|
33
33
|
return predicate.value.includes(value);
|
|
34
34
|
case 'exists':
|
|
35
35
|
return predicate.value ? value !== undefined : value === undefined;
|
|
36
|
+
case 'gt':
|
|
37
|
+
return typeof value === 'number' && value > predicate.value;
|
|
38
|
+
case 'gte':
|
|
39
|
+
return typeof value === 'number' && value >= predicate.value;
|
|
40
|
+
case 'lt':
|
|
41
|
+
return typeof value === 'number' && value < predicate.value;
|
|
42
|
+
case 'lte':
|
|
43
|
+
return typeof value === 'number' && value <= predicate.value;
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
46
|
export function clauseMatches(clause, event) {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ActivationEvidenceSchema: z.ZodObject<{
|
|
3
|
+
clauseId: z.ZodString;
|
|
4
|
+
serverId: z.ZodNullable<z.ZodString>;
|
|
5
|
+
eventId: z.ZodString;
|
|
6
|
+
eventName: z.ZodString;
|
|
7
|
+
traceId: z.ZodString;
|
|
8
|
+
occurredAt: z.ZodString;
|
|
9
|
+
payloadHash: z.ZodNullable<z.ZodString>;
|
|
10
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export declare const ActivationEnvelopeSchema: z.ZodObject<{
|
|
13
|
+
activationVersion: z.ZodLiteral<"1">;
|
|
14
|
+
wake: z.ZodObject<{
|
|
15
|
+
wakeId: z.ZodString;
|
|
16
|
+
status: z.ZodString;
|
|
17
|
+
runtimeReceiptId: z.ZodNullable<z.ZodString>;
|
|
18
|
+
matchedAt: z.ZodString;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
target: z.ZodObject<{
|
|
21
|
+
runtime: z.ZodString;
|
|
22
|
+
kind: z.ZodString;
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
trigger: z.ZodObject<{
|
|
26
|
+
triggerId: z.ZodString;
|
|
27
|
+
version: z.ZodString;
|
|
28
|
+
description: z.ZodNullable<z.ZodString>;
|
|
29
|
+
expression: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
30
|
+
lifecycle: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
continuation: z.ZodNullable<z.ZodObject<{
|
|
33
|
+
instruction: z.ZodString;
|
|
34
|
+
contextPolicy: z.ZodDefault<z.ZodObject<{
|
|
35
|
+
evidence: z.ZodDefault<z.ZodEnum<{
|
|
36
|
+
matched_events: "matched_events";
|
|
37
|
+
refs_only: "refs_only";
|
|
38
|
+
}>>;
|
|
39
|
+
maxEvents: z.ZodDefault<z.ZodNumber>;
|
|
40
|
+
includeData: z.ZodDefault<z.ZodBoolean>;
|
|
41
|
+
}, z.core.$strict>>;
|
|
42
|
+
}, z.core.$strict>>;
|
|
43
|
+
match: z.ZodObject<{
|
|
44
|
+
matchId: z.ZodString;
|
|
45
|
+
status: z.ZodString;
|
|
46
|
+
correlationKey: z.ZodNullable<z.ZodString>;
|
|
47
|
+
openedAt: z.ZodString;
|
|
48
|
+
updatedAt: z.ZodString;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
evidence: z.ZodArray<z.ZodObject<{
|
|
51
|
+
clauseId: z.ZodString;
|
|
52
|
+
serverId: z.ZodNullable<z.ZodString>;
|
|
53
|
+
eventId: z.ZodString;
|
|
54
|
+
eventName: z.ZodString;
|
|
55
|
+
traceId: z.ZodString;
|
|
56
|
+
occurredAt: z.ZodString;
|
|
57
|
+
payloadHash: z.ZodNullable<z.ZodString>;
|
|
58
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
59
|
+
}, z.core.$strict>>;
|
|
60
|
+
trust: z.ZodObject<{
|
|
61
|
+
continuation: z.ZodLiteral<"configured_trigger_instruction">;
|
|
62
|
+
evidence: z.ZodLiteral<"untrusted_external_signal">;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
}, z.core.$strict>;
|
|
65
|
+
export type ActivationEvidence = z.infer<typeof ActivationEvidenceSchema>;
|
|
66
|
+
export type ActivationEnvelope = z.infer<typeof ActivationEnvelopeSchema>;
|
|
67
|
+
export declare function parseActivationEnvelope(value: unknown): ActivationEnvelope;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ContinuationContractSchema } from './triggerSchemas.js';
|
|
3
|
+
const Id = z.string().min(1).max(200);
|
|
4
|
+
const Timestamp = z.string().datetime({ offset: true });
|
|
5
|
+
export const ActivationEvidenceSchema = z.object({
|
|
6
|
+
clauseId: Id,
|
|
7
|
+
serverId: Id.nullable(),
|
|
8
|
+
eventId: Id,
|
|
9
|
+
eventName: z.string().min(1),
|
|
10
|
+
traceId: Id,
|
|
11
|
+
occurredAt: Timestamp,
|
|
12
|
+
payloadHash: z.string().regex(/^[a-f0-9]{64}$/).nullable(),
|
|
13
|
+
data: z.record(z.string(), z.unknown()).optional(),
|
|
14
|
+
}).strict();
|
|
15
|
+
export const ActivationEnvelopeSchema = z.object({
|
|
16
|
+
activationVersion: z.literal('1'),
|
|
17
|
+
wake: z.object({
|
|
18
|
+
wakeId: Id,
|
|
19
|
+
status: z.string().min(1),
|
|
20
|
+
runtimeReceiptId: Id.nullable(),
|
|
21
|
+
matchedAt: Timestamp,
|
|
22
|
+
}).strict(),
|
|
23
|
+
target: z.object({
|
|
24
|
+
runtime: z.string().min(1),
|
|
25
|
+
kind: z.string().min(1),
|
|
26
|
+
id: Id,
|
|
27
|
+
}).strict(),
|
|
28
|
+
trigger: z.object({
|
|
29
|
+
triggerId: Id,
|
|
30
|
+
version: z.string().min(1),
|
|
31
|
+
description: z.string().nullable(),
|
|
32
|
+
expression: z.record(z.string(), z.unknown()),
|
|
33
|
+
lifecycle: z.record(z.string(), z.unknown()),
|
|
34
|
+
}).strict(),
|
|
35
|
+
continuation: ContinuationContractSchema.nullable(),
|
|
36
|
+
match: z.object({
|
|
37
|
+
matchId: Id,
|
|
38
|
+
status: z.string().min(1),
|
|
39
|
+
correlationKey: z.string().nullable(),
|
|
40
|
+
openedAt: Timestamp,
|
|
41
|
+
updatedAt: Timestamp,
|
|
42
|
+
}).strict(),
|
|
43
|
+
evidence: z.array(ActivationEvidenceSchema),
|
|
44
|
+
trust: z.object({
|
|
45
|
+
continuation: z.literal('configured_trigger_instruction'),
|
|
46
|
+
evidence: z.literal('untrusted_external_signal'),
|
|
47
|
+
}).strict(),
|
|
48
|
+
}).strict();
|
|
49
|
+
export function parseActivationEnvelope(value) {
|
|
50
|
+
return ActivationEnvelopeSchema.parse(value);
|
|
51
|
+
}
|
|
@@ -8,5 +8,9 @@ export type { AppendAuditInput, } from './audit.js';
|
|
|
8
8
|
export { mapMcpEventToLineage, } from './mapper.js';
|
|
9
9
|
export type { MapMcpEventInput, } from './mapper.js';
|
|
10
10
|
export { assertDecisionLineage, assertWakeLineage, } from './invariants.js';
|
|
11
|
-
export { COMPOSITE_TRIGGER_PROTOCOL_VERSION, COMPOSITE_TRIGGER_SCHEMA_VERSION, StructuredPredicateSchema, TriggerClauseSchema, DerivedEventProjectionSchema, DerivedEventDefinitionSchema, DerivedEventEvidenceRefSchema, DerivedEventRecordSchema, DeterministicCorrelationSchema, SemanticCorrelationSchema, CompositeTriggerDefinitionSchema, CorrelatableEventSchema, TriggerSourceEventSchema, CompositeCorrelationDecisionSchema, TriggerMatchStatusSchema, TriggerMatchRecordSchema, parseCompositeTriggerDefinition, parseCorrelatableEvent, parseTriggerMatchRecord, parseDerivedEventRecord, } from './triggerSchemas.js';
|
|
12
|
-
export type { StructuredPredicate, TriggerClause, DerivedEventDefinition, DerivedEventRecord, CompositeTriggerDefinition, CorrelatableEvent, TriggerSourceEvent, TriggerMatchRecord, CompositeCorrelationDecision, } from './triggerSchemas.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';
|
|
15
|
+
export { ActivationEvidenceSchema, ActivationEnvelopeSchema, parseActivationEnvelope, } from './activationSchemas.js';
|
|
16
|
+
export type { ActivationEvidence, ActivationEnvelope, } from './activationSchemas.js';
|
|
@@ -5,4 +5,6 @@ export { canonicalJson, sha256Hex, } from './canonical.js';
|
|
|
5
5
|
export { AuditChain, } from './audit.js';
|
|
6
6
|
export { mapMcpEventToLineage, } from './mapper.js';
|
|
7
7
|
export { assertDecisionLineage, assertWakeLineage, } from './invariants.js';
|
|
8
|
-
export { COMPOSITE_TRIGGER_PROTOCOL_VERSION, COMPOSITE_TRIGGER_SCHEMA_VERSION, StructuredPredicateSchema, TriggerClauseSchema, DerivedEventProjectionSchema, DerivedEventDefinitionSchema, DerivedEventEvidenceRefSchema, DerivedEventRecordSchema, DeterministicCorrelationSchema, SemanticCorrelationSchema, CompositeTriggerDefinitionSchema, CorrelatableEventSchema, TriggerSourceEventSchema, CompositeCorrelationDecisionSchema, TriggerMatchStatusSchema, TriggerMatchRecordSchema, parseCompositeTriggerDefinition, parseCorrelatableEvent, parseTriggerMatchRecord, parseDerivedEventRecord, } from './triggerSchemas.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';
|
|
10
|
+
export { ActivationEvidenceSchema, ActivationEnvelopeSchema, parseActivationEnvelope, } from './activationSchemas.js';
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const TriggerPlanEventSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodOptional<z.ZodString>;
|
|
4
|
+
event: z.ZodString;
|
|
5
|
+
serverId: z.ZodOptional<z.ZodString>;
|
|
6
|
+
where: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
7
|
+
path: z.ZodString;
|
|
8
|
+
op: z.ZodLiteral<"eq">;
|
|
9
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
path: z.ZodString;
|
|
12
|
+
op: z.ZodLiteral<"neq">;
|
|
13
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
14
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
15
|
+
path: z.ZodString;
|
|
16
|
+
op: z.ZodLiteral<"contains">;
|
|
17
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
18
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
19
|
+
path: z.ZodString;
|
|
20
|
+
op: z.ZodLiteral<"in">;
|
|
21
|
+
value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
22
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
23
|
+
path: z.ZodString;
|
|
24
|
+
op: z.ZodLiteral<"exists">;
|
|
25
|
+
value: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
path: z.ZodString;
|
|
28
|
+
op: z.ZodLiteral<"gt">;
|
|
29
|
+
value: z.ZodNumber;
|
|
30
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
path: z.ZodString;
|
|
32
|
+
op: z.ZodLiteral<"gte">;
|
|
33
|
+
value: z.ZodNumber;
|
|
34
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
35
|
+
path: z.ZodString;
|
|
36
|
+
op: z.ZodLiteral<"lt">;
|
|
37
|
+
value: z.ZodNumber;
|
|
38
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
+
path: z.ZodString;
|
|
40
|
+
op: z.ZodLiteral<"lte">;
|
|
41
|
+
value: z.ZodNumber;
|
|
42
|
+
}, z.core.$strip>], "op">>>;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
export declare const TriggerPlanMatchSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
45
|
+
any: "any";
|
|
46
|
+
sequence: "sequence";
|
|
47
|
+
all: "all";
|
|
48
|
+
}>, z.ZodObject<{
|
|
49
|
+
kind: z.ZodLiteral<"count">;
|
|
50
|
+
eventId: z.ZodString;
|
|
51
|
+
atLeast: z.ZodNumber;
|
|
52
|
+
}, z.core.$strict>]>;
|
|
53
|
+
export declare const TriggerPlanInputSchema: z.ZodObject<{
|
|
54
|
+
triggerId: z.ZodOptional<z.ZodString>;
|
|
55
|
+
version: z.ZodDefault<z.ZodString>;
|
|
56
|
+
description: z.ZodOptional<z.ZodString>;
|
|
57
|
+
events: z.ZodArray<z.ZodObject<{
|
|
58
|
+
id: z.ZodOptional<z.ZodString>;
|
|
59
|
+
event: z.ZodString;
|
|
60
|
+
serverId: z.ZodOptional<z.ZodString>;
|
|
61
|
+
where: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
62
|
+
path: z.ZodString;
|
|
63
|
+
op: z.ZodLiteral<"eq">;
|
|
64
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
65
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
+
path: z.ZodString;
|
|
67
|
+
op: z.ZodLiteral<"neq">;
|
|
68
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
69
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
70
|
+
path: z.ZodString;
|
|
71
|
+
op: z.ZodLiteral<"contains">;
|
|
72
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
73
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
74
|
+
path: z.ZodString;
|
|
75
|
+
op: z.ZodLiteral<"in">;
|
|
76
|
+
value: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
77
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
78
|
+
path: z.ZodString;
|
|
79
|
+
op: z.ZodLiteral<"exists">;
|
|
80
|
+
value: z.ZodDefault<z.ZodBoolean>;
|
|
81
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
82
|
+
path: z.ZodString;
|
|
83
|
+
op: z.ZodLiteral<"gt">;
|
|
84
|
+
value: z.ZodNumber;
|
|
85
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
86
|
+
path: z.ZodString;
|
|
87
|
+
op: z.ZodLiteral<"gte">;
|
|
88
|
+
value: z.ZodNumber;
|
|
89
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
90
|
+
path: z.ZodString;
|
|
91
|
+
op: z.ZodLiteral<"lt">;
|
|
92
|
+
value: z.ZodNumber;
|
|
93
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
94
|
+
path: z.ZodString;
|
|
95
|
+
op: z.ZodLiteral<"lte">;
|
|
96
|
+
value: z.ZodNumber;
|
|
97
|
+
}, z.core.$strip>], "op">>>;
|
|
98
|
+
}, z.core.$strict>>;
|
|
99
|
+
match: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
100
|
+
any: "any";
|
|
101
|
+
sequence: "sequence";
|
|
102
|
+
all: "all";
|
|
103
|
+
}>, z.ZodObject<{
|
|
104
|
+
kind: z.ZodLiteral<"count">;
|
|
105
|
+
eventId: z.ZodString;
|
|
106
|
+
atLeast: z.ZodNumber;
|
|
107
|
+
}, z.core.$strict>]>>;
|
|
108
|
+
withinMs: z.ZodDefault<z.ZodNumber>;
|
|
109
|
+
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
110
|
+
oneShot: z.ZodOptional<z.ZodBoolean>;
|
|
111
|
+
maxFirings: z.ZodOptional<z.ZodNumber>;
|
|
112
|
+
cooldownMs: z.ZodOptional<z.ZodNumber>;
|
|
113
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
114
|
+
leaseUntil: z.ZodOptional<z.ZodString>;
|
|
115
|
+
completeOnGoal: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
}, z.core.$strict>>;
|
|
117
|
+
target: z.ZodObject<{
|
|
118
|
+
runtime: z.ZodString;
|
|
119
|
+
kind: z.ZodEnum<{
|
|
120
|
+
goal: "goal";
|
|
121
|
+
session: "session";
|
|
122
|
+
conversation: "conversation";
|
|
123
|
+
task: "task";
|
|
124
|
+
spawn_template: "spawn_template";
|
|
125
|
+
}>;
|
|
126
|
+
id: z.ZodString;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
continuation: z.ZodObject<{
|
|
129
|
+
instruction: z.ZodString;
|
|
130
|
+
contextPolicy: z.ZodDefault<z.ZodObject<{
|
|
131
|
+
evidence: z.ZodDefault<z.ZodEnum<{
|
|
132
|
+
matched_events: "matched_events";
|
|
133
|
+
refs_only: "refs_only";
|
|
134
|
+
}>>;
|
|
135
|
+
maxEvents: z.ZodDefault<z.ZodNumber>;
|
|
136
|
+
includeData: z.ZodDefault<z.ZodBoolean>;
|
|
137
|
+
}, z.core.$strict>>;
|
|
138
|
+
}, z.core.$strict>;
|
|
139
|
+
correlateBy: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
140
|
+
eventId: z.ZodString;
|
|
141
|
+
path: z.ZodString;
|
|
142
|
+
}, z.core.$strict>>>;
|
|
143
|
+
semanticCorrelation: z.ZodOptional<z.ZodObject<{
|
|
144
|
+
instruction: z.ZodString;
|
|
145
|
+
input: z.ZodArray<z.ZodString>;
|
|
146
|
+
matchThreshold: z.ZodNumber;
|
|
147
|
+
rejectThreshold: z.ZodNumber;
|
|
148
|
+
uncertain: z.ZodDefault<z.ZodEnum<{
|
|
149
|
+
match: "match";
|
|
150
|
+
reject: "reject";
|
|
151
|
+
escalate: "escalate";
|
|
152
|
+
}>>;
|
|
153
|
+
}, z.core.$strip>>;
|
|
154
|
+
}, z.core.$strict>;
|
|
155
|
+
export type TriggerPlanEvent = z.infer<typeof TriggerPlanEventSchema>;
|
|
156
|
+
export type TriggerPlanMatch = z.infer<typeof TriggerPlanMatchSchema>;
|
|
157
|
+
export type TriggerPlanInput = z.infer<typeof TriggerPlanInputSchema>;
|
|
158
|
+
export declare function parseTriggerPlanInput(value: unknown): TriggerPlanInput;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { RuntimeTargetSchema } from './schemas.js';
|
|
3
|
+
import { ContinuationContractSchema, SemanticCorrelationSchema, StructuredPredicateSchema, } from './triggerSchemas.js';
|
|
4
|
+
const Id = z.string().min(1).max(200);
|
|
5
|
+
export const TriggerPlanEventSchema = z.object({
|
|
6
|
+
id: Id.optional(),
|
|
7
|
+
event: z.string().min(1),
|
|
8
|
+
serverId: Id.optional(),
|
|
9
|
+
where: z.array(StructuredPredicateSchema).default([]),
|
|
10
|
+
}).strict();
|
|
11
|
+
export const TriggerPlanMatchSchema = z.union([
|
|
12
|
+
z.enum(['all', 'any', 'sequence']),
|
|
13
|
+
z.object({
|
|
14
|
+
kind: z.literal('count'),
|
|
15
|
+
eventId: Id,
|
|
16
|
+
atLeast: z.number().int().min(1),
|
|
17
|
+
}).strict(),
|
|
18
|
+
]);
|
|
19
|
+
export const TriggerPlanInputSchema = z.object({
|
|
20
|
+
triggerId: Id.optional(),
|
|
21
|
+
version: z.string().min(1).default('1'),
|
|
22
|
+
description: z.string().max(500).optional(),
|
|
23
|
+
events: z.array(TriggerPlanEventSchema).min(1),
|
|
24
|
+
match: TriggerPlanMatchSchema.default('all'),
|
|
25
|
+
withinMs: z.number().int().positive().max(1000 * 60 * 60 * 24 * 30)
|
|
26
|
+
.default(60 * 60 * 1000),
|
|
27
|
+
lifecycle: z.object({
|
|
28
|
+
oneShot: z.boolean().optional(),
|
|
29
|
+
maxFirings: z.number().int().min(1).optional(),
|
|
30
|
+
cooldownMs: z.number().int().nonnegative().optional(),
|
|
31
|
+
expiresAt: z.string().datetime({ offset: true }).optional(),
|
|
32
|
+
leaseUntil: z.string().datetime({ offset: true }).optional(),
|
|
33
|
+
completeOnGoal: z.boolean().optional(),
|
|
34
|
+
}).strict().optional(),
|
|
35
|
+
target: RuntimeTargetSchema,
|
|
36
|
+
continuation: ContinuationContractSchema,
|
|
37
|
+
correlateBy: z.array(z.object({
|
|
38
|
+
eventId: Id,
|
|
39
|
+
path: z.string().min(1),
|
|
40
|
+
}).strict()).min(2).optional(),
|
|
41
|
+
semanticCorrelation: SemanticCorrelationSchema.optional(),
|
|
42
|
+
}).strict();
|
|
43
|
+
export function parseTriggerPlanInput(value) {
|
|
44
|
+
return TriggerPlanInputSchema.parse(value);
|
|
45
|
+
}
|