mcp-event-intelligence 0.2.1 → 0.3.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 CHANGED
@@ -2,6 +2,70 @@
2
2
 
3
3
  All notable public changes are documented here.
4
4
 
5
+ ## [0.3.1] - 2026-09-20
6
+
7
+ Public-polish and reliability patch before wider distribution.
8
+
9
+ ### Reliability
10
+
11
+ - fixed the lease-claim test cleanup race that could surface intermittent `ENOTEMPTY` errors while an in-flight worker was still writing;
12
+ - added repeated direct lease-claim contention coverage and full coordinator contention stress coverage.
13
+
14
+ ### Documentation and public surface
15
+
16
+ - refreshed Security Policy and Security Model for scoped multi-tenant hosts, Activation Envelopes and the v0.3 agent-friendly planning flow;
17
+ - clarified the distinction between package version 0.3.x and the intentionally compatible internal protocol/schema v0.1 identifiers;
18
+ - refreshed Architecture and Protocol docs for `planTrigger()`, continuation contracts and wake hydration;
19
+ - updated MCP Registry docs to reflect the package and Registry as live, not deferred;
20
+ - updated the CLI help banner;
21
+ - removed the obsolete one-shot v0.1.0 release workflow.
22
+
23
+ ## [0.3.0] - 2026-09-20
24
+
25
+ Agent-integration release focused on making Event Intelligence usable as a plug-and-play future-condition primitive.
26
+
27
+ ### Agent-friendly trigger planning
28
+
29
+ - added deterministic `TriggerPlanInput` contracts;
30
+ - added `host.planTrigger()` / scoped `planTrigger()`;
31
+ - planner resolves live event sources and server IDs;
32
+ - planner validates predicate paths against advertised payload schemas;
33
+ - planner compiles `all`, `any`, `sequence` and `count` into the canonical trigger DSL;
34
+ - added numeric predicates `gt`, `gte`, `lt` and `lte`.
35
+
36
+ ### Continuations and activation
37
+
38
+ - trigger definitions may now persist a first-class `continuation` contract;
39
+ - continuation instructions are separated from the condition that wakes the runtime;
40
+ - added Activation Envelope contracts;
41
+ - added `host.hydrateWake(wakeId)` / scoped `hydrateWake(wakeId)`;
42
+ - hydrated evidence can include matched event payloads according to the trigger context policy;
43
+ - activation evidence is explicitly labeled as untrusted external signal data;
44
+ - the wire wake remains reference-only by default.
45
+
46
+ ### Embedded host ergonomics
47
+
48
+ - embedded wake callbacks may now receive `(packet, activation)`;
49
+ - existing one-argument callbacks remain compatible;
50
+ - trigger inspection now includes the persisted continuation contract.
51
+
52
+ ### MCP control plane
53
+
54
+ - added non-mutating `trigger_plan`;
55
+ - added non-mutating `wake_hydrate`;
56
+ - `trigger_create` now accepts either a raw canonical definition or an agent-friendly plan;
57
+ - plan-based creation still uses the same confirmation, source-scope, owner and version checks.
58
+
59
+ ### Verification
60
+
61
+ - end-to-end coverage verifies plan -> canonical trigger -> numeric predicate match -> reference-only wake -> hydrated activation -> runtime receipt;
62
+ - context-policy coverage verifies refs-only activation evidence;
63
+ - clean-room smoke now installs the candidate packed artifact rather than an old hard-coded npm version.
64
+
65
+ ### Compatibility
66
+
67
+ 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.
68
+
5
69
  ## [0.2.1] - 2026-09-20
6
70
 
7
71
  Patch hardening for shutdown determinism and multi-tenant verification.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![CI](https://github.com/sarooo17/event-intelligence/actions/workflows/ci.yml/badge.svg)](https://github.com/sarooo17/event-intelligence/actions/workflows/ci.yml)
6
6
  [![npm](https://img.shields.io/npm/v/mcp-event-intelligence.svg)](https://www.npmjs.com/package/mcp-event-intelligence)
7
- [![MCP Registry](https://img.shields.io/badge/MCP%20Registry-v0.2.1-5b5bd6)](https://registry.modelcontextprotocol.io/?q=io.github.sarooo17%2Fevent-intelligence)
7
+ [![MCP Registry](https://img.shields.io/badge/MCP%20Registry-v0.3.1-5b5bd6)](https://registry.modelcontextprotocol.io/?q=io.github.sarooo17%2Fevent-intelligence)
8
8
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](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, packet);
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.1 implements
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-authored structured trigger definitions;
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.
@@ -247,11 +300,11 @@ Event Intelligence has one optional AI boundary: **semantic correlation**.
247
300
  - embedded hosts may inject a compatible `semanticEvaluator` instead.
248
301
  - there is no bundled OpenAI planner and no OpenAI API dependency.
249
302
 
250
- The agent/harness is already responsible for reasoning and can author a structured trigger directly from `event_sources_list` / the discovered schemas. Deterministic correlation, temporal logic, persistence, derived events and wake delivery require no model API.
303
+ The agent/harness is already responsible for natural-language reasoning. It can use `trigger_plan` / `planTrigger()` to compile common requests deterministically against discovered source schemas, or submit a canonical trigger definition directly for advanced cases. Deterministic correlation, temporal logic, persistence, derived events and wake delivery require no model API.
251
304
 
252
305
  ## Full-system acceptance
253
306
 
254
- The v0.1 acceptance suite verifies:
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.1.0 .
353
+ docker build -t mcp-event-intelligence:0.3.1 .
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.1.0
359
+ mcp-event-intelligence:0.3.1
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. An agent uses those discovered source schemas to author the structured definition passed to `trigger_create`.
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.1 intentionally does not implement a mutable current-state/facts database.
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.1 reference implementation / experimental.**
448
+ **v0.3.x 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
 
package/SECURITY.md CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  ## Supported versions
4
4
 
5
- The public reference implementation is currently pre-1.0.
5
+ The public package is pre-1.0. Security fixes are supported on the current 0.3.x line.
6
6
 
7
7
  | Version | Supported |
8
8
  | --- | --- |
9
- | 0.1.x | Yes |
10
- | < 0.1 | No |
9
+ | 0.3.x | Yes |
10
+ | < 0.3 | No |
11
11
 
12
12
  ## Reporting a vulnerability
13
13
 
@@ -26,17 +26,21 @@ Useful reports include:
26
26
 
27
27
  ## Security boundaries
28
28
 
29
- Event Intelligence v0.1 is a reference implementation, not a hardened multi-tenant hosted service.
29
+ Event Intelligence 0.3.x is an experimental reference implementation with scoped multi-tenant host support. It is not a turnkey hardened hosted service.
30
30
 
31
31
  Important defaults and constraints:
32
32
 
33
- - protected control-plane endpoints require `SERVICE_AUTH_TOKEN`;
33
+ - tenant/workspace isolation is implemented through scoped store partitions; tenant-facing code should receive only the corresponding scoped host view;
34
+ - protected standalone control-plane endpoints require `SERVICE_AUTH_TOKEN`;
34
35
  - GitHub ingress verifies provider HMAC when configured;
35
- - runtime wake packets are HMAC-signed and runtime targets are operator-configured;
36
+ - standalone runtime wake packets are HMAC-signed and runtime targets are operator-configured;
37
+ - embedded wakes preserve the configured continuation separately from untrusted matched-event evidence;
38
+ - event receipt never grants new downstream authorization;
36
39
  - arbitrary public HTTP wake targets are rejected;
37
40
  - derived-event lineage is refs-only by default;
38
41
  - audit records are hash-linked and tamper-evident, not tamper-proof;
39
- - the JSONL store is single-writer and not safe for horizontal multi-replica deployment;
42
+ - the bundled JSONL store is single-process reference infrastructure and is not safe as a shared multi-replica backend;
43
+ - horizontally scaled custom stores must preserve scope isolation and implement wake claim/lease operations atomically;
40
44
  - secrets belong in environment variables / secret managers, never committed files.
41
45
 
42
46
  See `docs/SECURITY-MODEL.md` for the architectural model.
@@ -4,12 +4,12 @@ const args = process.argv.slice(2);
4
4
  const flags = new Set(args);
5
5
 
6
6
  if (flags.has('--version') || flags.has('-v')) {
7
- console.log('0.2.1');
7
+ console.log('0.3.1');
8
8
  process.exit(0);
9
9
  }
10
10
 
11
11
  if (flags.has('--help') || flags.has('-h')) {
12
- console.log(`MCP Event Intelligence v0.1
12
+ console.log(`MCP Event Intelligence v0.3
13
13
 
14
14
  Durable temporal event intelligence for sleeping agents.
15
15
 
@@ -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
+ }