@animalabs/agent-framework 0.28.0 → 0.30.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/README.md +88 -25
- package/dist/src/admission/admit.d.ts +90 -0
- package/dist/src/admission/admit.d.ts.map +1 -0
- package/dist/src/admission/admit.js +43 -0
- package/dist/src/admission/admit.js.map +1 -0
- package/dist/src/agent.d.ts +21 -0
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +47 -7
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/mcp-server-core.d.ts.map +1 -1
- package/dist/src/api/mcp-server-core.js +3 -12
- package/dist/src/api/mcp-server-core.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +7 -3
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/author-presentation.d.ts +50 -0
- package/dist/src/author-presentation.d.ts.map +1 -0
- package/dist/src/author-presentation.js +58 -0
- package/dist/src/author-presentation.js.map +1 -0
- package/dist/src/auto-continue.d.ts +2 -0
- package/dist/src/auto-continue.d.ts.map +1 -1
- package/dist/src/auto-continue.js +5 -2
- package/dist/src/auto-continue.js.map +1 -1
- package/dist/src/code-execution/isolate/runner.d.ts +7 -5
- package/dist/src/code-execution/isolate/runner.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/runner.js +7 -5
- package/dist/src/code-execution/isolate/runner.js.map +1 -1
- package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/scripts.js +3 -2
- package/dist/src/code-execution/isolate/scripts.js.map +1 -1
- package/dist/src/dendrite/index.d.ts +6 -0
- package/dist/src/dendrite/index.d.ts.map +1 -0
- package/dist/src/dendrite/index.js +3 -0
- package/dist/src/dendrite/index.js.map +1 -0
- package/dist/src/dendrite/presets.d.ts +60 -0
- package/dist/src/dendrite/presets.d.ts.map +1 -0
- package/dist/src/dendrite/presets.js +117 -0
- package/dist/src/dendrite/presets.js.map +1 -0
- package/dist/src/dendrite/registry.d.ts +260 -0
- package/dist/src/dendrite/registry.d.ts.map +1 -0
- package/dist/src/dendrite/registry.js +742 -0
- package/dist/src/dendrite/registry.js.map +1 -0
- package/dist/src/dendrite/types.d.ts +392 -0
- package/dist/src/dendrite/types.d.ts.map +1 -0
- package/dist/src/dendrite/types.js +24 -0
- package/dist/src/dendrite/types.js.map +1 -0
- package/dist/src/framework.d.ts +846 -67
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +4213 -924
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +46 -14
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +143 -53
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/gate/index.d.ts +1 -1
- package/dist/src/gate/index.d.ts.map +1 -1
- package/dist/src/gate/index.js +1 -1
- package/dist/src/gate/index.js.map +1 -1
- package/dist/src/gate/types.d.ts +12 -2
- package/dist/src/gate/types.d.ts.map +1 -1
- package/dist/src/heartbeat/heartbeat.d.ts +18 -0
- package/dist/src/heartbeat/heartbeat.d.ts.map +1 -1
- package/dist/src/heartbeat/heartbeat.js +34 -8
- package/dist/src/heartbeat/heartbeat.js.map +1 -1
- package/dist/src/held-writes.d.ts +3 -3
- package/dist/src/held-writes.js +3 -3
- package/dist/src/host-presentation.d.ts +174 -0
- package/dist/src/host-presentation.d.ts.map +1 -0
- package/dist/src/host-presentation.js +565 -0
- package/dist/src/host-presentation.js.map +1 -0
- package/dist/src/index.d.ts +7 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/line-reader.d.ts +4 -0
- package/dist/src/line-reader.d.ts.map +1 -0
- package/dist/src/line-reader.js +59 -0
- package/dist/src/line-reader.js.map +1 -0
- package/dist/src/mcpl/channel-registry.d.ts +118 -15
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +266 -110
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
- package/dist/src/mcpl/conversation-router.js +2 -1
- package/dist/src/mcpl/conversation-router.js.map +1 -1
- package/dist/src/mcpl/convert-block.d.ts +1 -0
- package/dist/src/mcpl/convert-block.d.ts.map +1 -1
- package/dist/src/mcpl/convert-block.js +16 -4
- package/dist/src/mcpl/convert-block.js.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.js +4 -3
- package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
- package/dist/src/mcpl/inbound-source.d.ts +3 -1
- package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
- package/dist/src/mcpl/inbound-source.js +3 -1
- package/dist/src/mcpl/inbound-source.js.map +1 -1
- package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
- package/dist/src/mcpl/modern-connection.js +11 -7
- package/dist/src/mcpl/modern-connection.js.map +1 -1
- package/dist/src/mcpl/protocol-family.d.ts +3 -2
- package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
- package/dist/src/mcpl/protocol-family.js +25 -3
- package/dist/src/mcpl/protocol-family.js.map +1 -1
- package/dist/src/mcpl/push-coalescer.d.ts +9 -0
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +21 -0
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/push-handler.js +2 -2
- package/dist/src/mcpl/push-handler.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +12 -40
- package/dist/src/mcpl/references.d.ts.map +1 -1
- package/dist/src/mcpl/references.js +29 -23
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +20 -20
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/skip-reply-wake.d.ts +25 -0
- package/dist/src/mcpl/skip-reply-wake.d.ts.map +1 -1
- package/dist/src/mcpl/skip-reply-wake.js +25 -0
- package/dist/src/mcpl/skip-reply-wake.js.map +1 -1
- package/dist/src/mcpl/tool-presence.d.ts.map +1 -1
- package/dist/src/mcpl/tool-presence.js +18 -17
- package/dist/src/mcpl/tool-presence.js.map +1 -1
- package/dist/src/mcpl/tool-signature.d.ts.map +1 -1
- package/dist/src/mcpl/tool-signature.js +17 -16
- package/dist/src/mcpl/tool-signature.js.map +1 -1
- package/dist/src/mcpl/toolset-host.d.ts +8 -26
- package/dist/src/mcpl/toolset-host.d.ts.map +1 -1
- package/dist/src/mcpl/toolset-host.js +16 -6
- package/dist/src/mcpl/toolset-host.js.map +1 -1
- package/dist/src/mcpl/toolsets-module.d.ts +14 -25
- package/dist/src/mcpl/toolsets-module.d.ts.map +1 -1
- package/dist/src/mcpl/toolsets-module.js +187 -50
- package/dist/src/mcpl/toolsets-module.js.map +1 -1
- package/dist/src/mcpl/transport.d.ts +1 -1
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +16 -16
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +28 -12
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/module-registry.d.ts +6 -7
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +6 -7
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/api/index.d.ts.map +1 -1
- package/dist/src/modules/api/index.js +4 -2
- package/dist/src/modules/api/index.js.map +1 -1
- package/dist/src/modules/discord/index.d.ts.map +1 -1
- package/dist/src/modules/discord/index.js +33 -25
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/history/index.js +8 -6
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/sender-name.d.ts +7 -0
- package/dist/src/modules/sender-name.d.ts.map +1 -0
- package/dist/src/modules/sender-name.js +10 -0
- package/dist/src/modules/sender-name.js.map +1 -0
- package/dist/src/modules/workspace/answers.d.ts +5 -1
- package/dist/src/modules/workspace/answers.d.ts.map +1 -1
- package/dist/src/modules/workspace/answers.js +16 -1
- package/dist/src/modules/workspace/answers.js.map +1 -1
- package/dist/src/modules/workspace/direct-write.d.ts.map +1 -1
- package/dist/src/modules/workspace/direct-write.js +6 -4
- package/dist/src/modules/workspace/direct-write.js.map +1 -1
- package/dist/src/modules/workspace/effects.d.ts +4 -2
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/effects.js +50 -40
- package/dist/src/modules/workspace/effects.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +1 -0
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +66 -36
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +51 -20
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +120 -82
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/reconcile.d.ts +7 -1
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +133 -37
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/notice-tags.d.ts +81 -0
- package/dist/src/notice-tags.d.ts.map +1 -0
- package/dist/src/notice-tags.js +85 -0
- package/dist/src/notice-tags.js.map +1 -0
- package/dist/src/reasoning-loss-notice.d.ts.map +1 -1
- package/dist/src/reasoning-loss-notice.js +5 -3
- package/dist/src/reasoning-loss-notice.js.map +1 -1
- package/dist/src/silent-heartbeat.d.ts +5 -55
- package/dist/src/silent-heartbeat.d.ts.map +1 -1
- package/dist/src/silent-heartbeat.js +63 -7
- package/dist/src/silent-heartbeat.js.map +1 -1
- package/dist/src/stored-injections.d.ts +4 -0
- package/dist/src/stored-injections.d.ts.map +1 -1
- package/dist/src/stored-injections.js +6 -0
- package/dist/src/stored-injections.js.map +1 -1
- package/dist/src/supplied-text.d.ts +35 -0
- package/dist/src/supplied-text.d.ts.map +1 -0
- package/dist/src/supplied-text.js +141 -0
- package/dist/src/supplied-text.js.map +1 -0
- package/dist/src/tool-args.d.ts.map +1 -1
- package/dist/src/tool-args.js +9 -8
- package/dist/src/tool-args.js.map +1 -1
- package/dist/src/tool-image-ledger.d.ts.map +1 -1
- package/dist/src/tool-image-ledger.js +2 -1
- package/dist/src/tool-image-ledger.js.map +1 -1
- package/dist/src/tool-presentation.d.ts.map +1 -1
- package/dist/src/tool-presentation.js +5 -4
- package/dist/src/tool-presentation.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +382 -11
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +1100 -119
- package/dist/src/tune-out/coordinator.js.map +1 -1
- package/dist/src/tune-out/tools.d.ts +101 -5
- package/dist/src/tune-out/tools.d.ts.map +1 -1
- package/dist/src/tune-out/tools.js +55 -18
- package/dist/src/tune-out/tools.js.map +1 -1
- package/dist/src/types/agent.d.ts +48 -9
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +142 -0
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +22 -11
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +136 -0
- package/dist/src/types/trace.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/admission/admit.ts +113 -0
- package/src/agent.ts +52 -7
- package/src/api/mcp-server-core.ts +3 -14
- package/src/api/server.ts +7 -3
- package/src/author-presentation.ts +81 -0
- package/src/auto-continue.ts +8 -2
- package/src/code-execution/isolate/runner.ts +7 -5
- package/src/code-execution/isolate/scripts.ts +3 -2
- package/src/dendrite/index.ts +32 -0
- package/src/dendrite/presets.ts +149 -0
- package/src/dendrite/registry.ts +808 -0
- package/src/dendrite/types.ts +397 -0
- package/src/framework.ts +4362 -852
- package/src/gate/event-gate.ts +159 -52
- package/src/gate/index.ts +1 -1
- package/src/gate/types.ts +12 -2
- package/src/heartbeat/heartbeat.ts +48 -9
- package/src/held-writes.ts +3 -3
- package/src/host-presentation.ts +612 -0
- package/src/index.ts +17 -4
- package/src/line-reader.ts +58 -0
- package/src/mcpl/channel-registry.ts +306 -111
- package/src/mcpl/conversation-router.ts +2 -1
- package/src/mcpl/convert-block.ts +17 -4
- package/src/mcpl/hook-orchestrator.ts +4 -3
- package/src/mcpl/inbound-source.ts +3 -1
- package/src/mcpl/modern-connection.ts +11 -7
- package/src/mcpl/protocol-family.ts +24 -3
- package/src/mcpl/push-coalescer.ts +19 -0
- package/src/mcpl/push-handler.ts +2 -2
- package/src/mcpl/references.ts +31 -23
- package/src/mcpl/server-connection.ts +20 -18
- package/src/mcpl/skip-reply-wake.ts +35 -0
- package/src/mcpl/tool-presence.ts +18 -17
- package/src/mcpl/tool-signature.ts +17 -16
- package/src/mcpl/toolset-host.ts +18 -6
- package/src/mcpl/toolsets-module.ts +149 -50
- package/src/mcpl/transport.ts +18 -14
- package/src/mcpl/types.ts +29 -12
- package/src/module-registry.ts +6 -7
- package/src/modules/api/index.ts +4 -2
- package/src/modules/discord/index.ts +37 -25
- package/src/modules/history/index.ts +8 -6
- package/src/modules/sender-name.ts +9 -0
- package/src/modules/workspace/answers.ts +20 -2
- package/src/modules/workspace/direct-write.ts +4 -3
- package/src/modules/workspace/effects.ts +50 -40
- package/src/modules/workspace/index.ts +58 -34
- package/src/modules/workspace/observe.ts +139 -88
- package/src/modules/workspace/reconcile.ts +159 -36
- package/src/notice-tags.ts +86 -0
- package/src/reasoning-loss-notice.ts +5 -3
- package/src/silent-heartbeat.ts +11 -7
- package/src/stored-injections.ts +7 -0
- package/src/supplied-text.ts +154 -0
- package/src/tool-args.ts +9 -8
- package/src/tool-image-ledger.ts +2 -1
- package/src/tool-presentation.ts +5 -4
- package/src/tune-out/coordinator.ts +1252 -123
- package/src/tune-out/tools.ts +152 -11
- package/src/types/agent.ts +51 -9
- package/src/types/framework.ts +146 -0
- package/src/types/module.ts +23 -11
- package/src/types/trace.ts +150 -0
|
@@ -127,17 +127,28 @@ export declare function shownValue(value: unknown): string;
|
|
|
127
127
|
* left out.
|
|
128
128
|
*/
|
|
129
129
|
export declare function checkToolInput(tool: string, input: Record<string, unknown>, properties: Readonly<Record<string, unknown>>, notes: string[], means?: Readonly<Record<string, string>>): Record<string, unknown>;
|
|
130
|
+
/** The event types the gate can see from an MCPL server: its pushes and its
|
|
131
|
+
* channels' messages. */
|
|
132
|
+
export declare const MCPL_GATE_EVENT_TYPES: readonly string[];
|
|
133
|
+
/** The event types a host knows a source sends (EventGate's
|
|
134
|
+
* `eventTypesFrom`), or undefined when it could send any. */
|
|
135
|
+
export type EventTypesFrom = (source: string) => readonly string[] | undefined;
|
|
130
136
|
/**
|
|
131
|
-
* Find rules
|
|
137
|
+
* Find rules an earlier, broader rule keeps from applying (first match wins),
|
|
138
|
+
* in whole or for some event types.
|
|
132
139
|
* The 2026-08-08 Mythos incident is the canonical catch: a prepended
|
|
133
140
|
* `{scope:[mcpl:channel-incoming]}` sampler silently made the
|
|
134
141
|
* direct-address and mention rules dead for the whole incoming lane.
|
|
135
142
|
* `passthrough` observers shadow nothing — non-firing matches fall through.
|
|
143
|
+
* `eventTypesFrom` leaves out types a rule's source is known never to send:
|
|
144
|
+
* a rule for an MCPL server's events isn't told about another rule that
|
|
145
|
+
* takes every `external-message`.
|
|
136
146
|
*/
|
|
137
|
-
export declare function findShadowedPolicies(policies: GatePolicy[]): ShadowWarning[];
|
|
138
|
-
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
147
|
+
export declare function findShadowedPolicies(policies: GatePolicy[], eventTypesFrom?: EventTypesFrom): ShadowWarning[];
|
|
148
|
+
/** A ShadowWarning in words, used in tool results, traces, and gate_status
|
|
149
|
+
* alike so the same note reads the same way everywhere. It says which of
|
|
150
|
+
* three it is (the rule never applies; it misses some of its events; it
|
|
151
|
+
* may not be meant for those events at all) and what to do. */
|
|
141
152
|
export declare function formatShadowWarning(w: ShadowWarning): string;
|
|
142
153
|
export declare class EventGate {
|
|
143
154
|
private configPath;
|
|
@@ -207,8 +218,9 @@ export declare class EventGate {
|
|
|
207
218
|
/** Lifetime count of buffer-cap evictions (see bufferForInference). */
|
|
208
219
|
private droppedBufferedEvents;
|
|
209
220
|
private stats;
|
|
210
|
-
private shadowWarningsCache;
|
|
211
221
|
private shadowWarningsFingerprint;
|
|
222
|
+
/** See the constructor's `eventTypesFrom`. */
|
|
223
|
+
private eventTypesFromFn;
|
|
212
224
|
private totalEvaluations;
|
|
213
225
|
private defaultTriggered;
|
|
214
226
|
private defaultSkipped;
|
|
@@ -234,6 +246,8 @@ export declare class EventGate {
|
|
|
234
246
|
private addMessageFn;
|
|
235
247
|
private requestInferenceFn;
|
|
236
248
|
private getAgentNamesFn;
|
|
249
|
+
/** Delivery-time re-check: is this channel held from the recipients now? */
|
|
250
|
+
private isHeldFn;
|
|
237
251
|
private resolveRouteChannelFn;
|
|
238
252
|
private channelShownFn?;
|
|
239
253
|
private isNewestEntryFn?;
|
|
@@ -254,6 +268,13 @@ export declare class EventGate {
|
|
|
254
268
|
* message is answered. */
|
|
255
269
|
requestInference: (agentName: string, reason: string, source: string, provenance?: WakeProvenance, after?: WritePlacement) => void;
|
|
256
270
|
getAgentNames: () => string[];
|
|
271
|
+
/**
|
|
272
|
+
* Whether a channel is held from the recipients (a tune-out epoch in
|
|
273
|
+
* force). A held event never enters a batch — admission runs before the
|
|
274
|
+
* gate — but a hold can begin after an event was batched; at delivery
|
|
275
|
+
* the batch is re-checked and held events are dropped (#232 H3).
|
|
276
|
+
*/
|
|
277
|
+
isHeld?: (serverId: string | undefined, channelId: string | undefined) => boolean;
|
|
257
278
|
/** Optional clock — defaults to Date.now. Tests inject for deterministic time. */
|
|
258
279
|
now?: () => number;
|
|
259
280
|
/** Per-event timeout (ms) for the optional gate.js script. Default 50. */
|
|
@@ -293,6 +314,11 @@ export declare class EventGate {
|
|
|
293
314
|
* (WakeProvenance.line), for a fresh start of the wake's turn to decide
|
|
294
315
|
* (WakeLine). Absent: every batched wake writes its line, as before. */
|
|
295
316
|
isNewestEntry?: (entry: GateEntryRef) => boolean;
|
|
317
|
+
/** The event types the gate can see from a source, when the host knows
|
|
318
|
+
* them (an MCPL server's id: MCPL_GATE_EVENT_TYPES), else undefined.
|
|
319
|
+
* The rule-order notes (findShadowedPolicies) leave out types a rule's
|
|
320
|
+
* source never sends. Absent: any source can send any type. */
|
|
321
|
+
eventTypesFrom?: EventTypesFrom;
|
|
296
322
|
});
|
|
297
323
|
/**
|
|
298
324
|
* Write the starting rules to gate.json, as given, when it's absent, and
|
|
@@ -553,10 +579,17 @@ export declare class EventGate {
|
|
|
553
579
|
* cheap (policy lists are tens of entries at most). */
|
|
554
580
|
lintShadows(): ShadowWarning[];
|
|
555
581
|
/**
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
|
|
582
|
+
* The sources the host knows changed (eventTypesFrom answers differently),
|
|
583
|
+
* as when an MCPL server connects or is removed: the rule-order notes are
|
|
584
|
+
* made again, and traced if they changed, as a change to the rules would.
|
|
585
|
+
*/
|
|
586
|
+
sourcesChanged(): void;
|
|
587
|
+
/**
|
|
588
|
+
* Recompute shadow warnings and, when the set changed, emit a
|
|
589
|
+
* `gate:shadow-warnings` trace so the hazard lands in ops observability at
|
|
590
|
+
* the moment the order changed — not at the next missed DM — and, with an
|
|
591
|
+
* empty list, the moment the last of them went. Called from writeConfig,
|
|
592
|
+
* reloadIfChanged and sourcesChanged.
|
|
560
593
|
*/
|
|
561
594
|
private refreshShadowWarnings;
|
|
562
595
|
/**
|
|
@@ -680,10 +713,9 @@ export declare class EventGate {
|
|
|
680
713
|
*/
|
|
681
714
|
private armSleepWake;
|
|
682
715
|
/**
|
|
683
|
-
* `agentName` is gone, as
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
* framework refuses their `sleep`).
|
|
716
|
+
* `agentName` is gone, as an agent's end removes one: its pending
|
|
717
|
+
* self-wake is cancelled, and a sleep it set ends, rather than go on
|
|
718
|
+
* quieting every agent and then wake a name that no longer exists.
|
|
687
719
|
*/
|
|
688
720
|
agentGone(agentName: string): void;
|
|
689
721
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-gate.d.ts","sourceRoot":"","sources":["../../../src/gate/event-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"event-gate.d.ts","sourceRoot":"","sources":["../../../src/gate/event-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,aAAa,EAEb,UAAU,EACV,aAAa,EACb,YAAY,EAGZ,OAAO,EAEP,YAAY,EACb,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAC5E,WAAW,EAAE,iBAAiB,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,GACrG,MAAM,YAAY,CAAC;AAiEpB,UAAU,YAAY;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;8DAI0D;IAC1D,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;gCAE4B;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;mFAC+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;8EAC0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,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MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAI7D;IAED;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IA+CtB,yGAAyG;IACzG,OAAO,CAAC,yBAAyB;IAQjC,iBAAiB,IAAI,cAAc,CAQlC;IAEK,cAAc,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,UAAU,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAOvF;IAED,SAAS,IAAI,UAAU,CA+EtB;IAED,sEAAsE;IACtE,OAAO,CAAC,kBAAkB;IAU1B,wFAAwF;IACxF,OAAO,CAAC,kBAAkB;IAa1B,OAAO,IAAI,IAAI,CAyCd;CACF"}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* and are always dispatched to modules — the gate decides whether to spend
|
|
11
11
|
* inference tokens, not whether the agent should know about the event.
|
|
12
12
|
*/
|
|
13
|
+
import { NOTICE_TAG } from '../notice-tags.js';
|
|
14
|
+
import { cutToFit, suppliedValue } from '../supplied-text.js';
|
|
13
15
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
14
16
|
import { basename, dirname, join } from 'node:path';
|
|
15
17
|
import { GateScript } from './gate-script.js';
|
|
@@ -151,7 +153,7 @@ function referenceLine(count, channel, oldest, now) {
|
|
|
151
153
|
/** A handed batched-wake line's text (WakeLine), as it reads when written at
|
|
152
154
|
* `now`: the gate's words, its message's age counted to then. */
|
|
153
155
|
export function wakeLineText(line, now) {
|
|
154
|
-
return `[
|
|
156
|
+
return `[${NOTICE_TAG.gate}: 1 event matched]\n\n${referenceLine(1, line.shown, line.at, now)}`;
|
|
155
157
|
}
|
|
156
158
|
/** The event's own stored entry, as the framework is asked about it. */
|
|
157
159
|
function entryRef(event) {
|
|
@@ -1476,32 +1478,69 @@ function globAtLeastAsBroad(earlier, later) {
|
|
|
1476
1478
|
return true;
|
|
1477
1479
|
return earlier === later;
|
|
1478
1480
|
}
|
|
1481
|
+
/** The event types the gate can see from an MCPL server: its pushes and its
|
|
1482
|
+
* channels' messages. */
|
|
1483
|
+
export const MCPL_GATE_EVENT_TYPES = ['mcpl:push-event', 'mcpl:channel-incoming'];
|
|
1484
|
+
/** The event types `rule` can match: its scope's, narrowed to those its
|
|
1485
|
+
* source is known to send; 'all' when neither says. */
|
|
1486
|
+
function typesSeenBy(rule, eventTypesFrom) {
|
|
1487
|
+
const scope = rule.match.scope && rule.match.scope.length > 0 ? rule.match.scope : undefined;
|
|
1488
|
+
const source = rule.match.source;
|
|
1489
|
+
let sent;
|
|
1490
|
+
if (eventTypesFrom && source !== undefined && !source.includes('*')) {
|
|
1491
|
+
try {
|
|
1492
|
+
sent = eventTypesFrom(source);
|
|
1493
|
+
}
|
|
1494
|
+
catch {
|
|
1495
|
+
sent = undefined;
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
if (scope && sent)
|
|
1499
|
+
return { types: scope.filter((t) => sent.includes(t)), known: true };
|
|
1500
|
+
if (scope)
|
|
1501
|
+
return { types: scope, known: true };
|
|
1502
|
+
if (sent)
|
|
1503
|
+
return { types: [...sent], known: true };
|
|
1504
|
+
return { types: 'all', known: false };
|
|
1505
|
+
}
|
|
1479
1506
|
/**
|
|
1480
|
-
*
|
|
1481
|
-
*
|
|
1482
|
-
*
|
|
1483
|
-
*
|
|
1484
|
-
*
|
|
1507
|
+
* Whether `earlier` provably matches events `later` would match, so that
|
|
1508
|
+
* `later` doesn't see them when `earlier` sits before it and consumes its
|
|
1509
|
+
* matches: the event types concerned, whether that's every event `later`
|
|
1510
|
+
* would match, and whether `later` is known to see those types. Returns null
|
|
1511
|
+
* when it can't be proven (which is not proof of safety — the lint is
|
|
1512
|
+
* deliberately one-sided so every note it emits is true).
|
|
1485
1513
|
*/
|
|
1486
|
-
function subsumedEventTypes(earlier, later) {
|
|
1514
|
+
function subsumedEventTypes(earlier, later, eventTypesFrom) {
|
|
1487
1515
|
const e = earlier.match;
|
|
1488
1516
|
const l = later.match;
|
|
1489
|
-
//
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1517
|
+
// Event types: which of those `later` can match does `earlier` cover?
|
|
1518
|
+
const seen = typesSeenBy(later, eventTypesFrom);
|
|
1519
|
+
const earlierTypes = e.scope && e.scope.length > 0 ? e.scope : 'all';
|
|
1520
|
+
let eventTypes;
|
|
1521
|
+
let whole;
|
|
1522
|
+
let known = seen.known;
|
|
1523
|
+
if (earlierTypes === 'all') {
|
|
1524
|
+
eventTypes = seen.types;
|
|
1525
|
+
whole = true;
|
|
1526
|
+
}
|
|
1527
|
+
else if (seen.types === 'all') {
|
|
1528
|
+
// `later` matches every type; `earlier` only consumes its own scope, so
|
|
1529
|
+
// the overlap is partial — exactly those types, which may never reach
|
|
1530
|
+
// `later`.
|
|
1531
|
+
eventTypes = earlierTypes;
|
|
1532
|
+
whole = false;
|
|
1498
1533
|
}
|
|
1499
1534
|
else {
|
|
1500
|
-
const overlap =
|
|
1535
|
+
const overlap = seen.types.filter((t) => earlierTypes.includes(t));
|
|
1501
1536
|
if (overlap.length === 0)
|
|
1502
1537
|
return null;
|
|
1503
|
-
|
|
1538
|
+
eventTypes = overlap;
|
|
1539
|
+
whole = overlap.length === seen.types.length;
|
|
1540
|
+
known = true;
|
|
1504
1541
|
}
|
|
1542
|
+
if (Array.isArray(eventTypes) && eventTypes.length === 0)
|
|
1543
|
+
return null;
|
|
1505
1544
|
// Every remaining discriminator on `earlier` must be at least as broad as
|
|
1506
1545
|
// `later`'s, otherwise some `later` events slip past `earlier`.
|
|
1507
1546
|
if (!globAtLeastAsBroad(e.source, l.source))
|
|
@@ -1533,37 +1572,54 @@ function subsumedEventTypes(earlier, later) {
|
|
|
1533
1572
|
return null;
|
|
1534
1573
|
if (e.tagsNone && !subsetOf(e.tagsNone, l.tagsNone ?? []))
|
|
1535
1574
|
return null;
|
|
1536
|
-
return
|
|
1575
|
+
return { eventTypes, whole, known };
|
|
1537
1576
|
}
|
|
1538
1577
|
/**
|
|
1539
|
-
* Find rules
|
|
1578
|
+
* Find rules an earlier, broader rule keeps from applying (first match wins),
|
|
1579
|
+
* in whole or for some event types.
|
|
1540
1580
|
* The 2026-08-08 Mythos incident is the canonical catch: a prepended
|
|
1541
1581
|
* `{scope:[mcpl:channel-incoming]}` sampler silently made the
|
|
1542
1582
|
* direct-address and mention rules dead for the whole incoming lane.
|
|
1543
1583
|
* `passthrough` observers shadow nothing — non-firing matches fall through.
|
|
1584
|
+
* `eventTypesFrom` leaves out types a rule's source is known never to send:
|
|
1585
|
+
* a rule for an MCPL server's events isn't told about another rule that
|
|
1586
|
+
* takes every `external-message`.
|
|
1544
1587
|
*/
|
|
1545
|
-
export function findShadowedPolicies(policies) {
|
|
1588
|
+
export function findShadowedPolicies(policies, eventTypesFrom) {
|
|
1546
1589
|
const out = [];
|
|
1547
1590
|
for (let i = 0; i < policies.length; i++) {
|
|
1548
1591
|
const earlier = policies[i];
|
|
1549
1592
|
if (earlier.passthrough)
|
|
1550
1593
|
continue;
|
|
1551
1594
|
for (let j = i + 1; j < policies.length; j++) {
|
|
1552
|
-
const
|
|
1553
|
-
if (
|
|
1554
|
-
out.push({ earlier: earlier.name, later: policies[j].name,
|
|
1595
|
+
const found = subsumedEventTypes(earlier, policies[j], eventTypesFrom);
|
|
1596
|
+
if (found) {
|
|
1597
|
+
out.push({ earlier: earlier.name, later: policies[j].name, ...found });
|
|
1555
1598
|
}
|
|
1556
1599
|
}
|
|
1557
1600
|
}
|
|
1558
1601
|
return out;
|
|
1559
1602
|
}
|
|
1560
|
-
/**
|
|
1561
|
-
*
|
|
1562
|
-
*
|
|
1603
|
+
/** A ShadowWarning in words, used in tool results, traces, and gate_status
|
|
1604
|
+
* alike so the same note reads the same way everywhere. It says which of
|
|
1605
|
+
* three it is (the rule never applies; it misses some of its events; it
|
|
1606
|
+
* may not be meant for those events at all) and what to do. */
|
|
1563
1607
|
export function formatShadowWarning(w) {
|
|
1564
|
-
const
|
|
1565
|
-
|
|
1566
|
-
|
|
1608
|
+
const later = `"${w.later}"`;
|
|
1609
|
+
const earlier = `"${w.earlier}"`;
|
|
1610
|
+
const move = `move ${later} above ${earlier} (wake_add_rule with the whole rule and insertBefore: "${w.earlier}")`;
|
|
1611
|
+
if (w.whole) {
|
|
1612
|
+
return `${later} never applies: ${earlier} comes first and matches every event ${later} would. `
|
|
1613
|
+
+ `If ${later} should apply, ${move}, or narrow ${earlier}.`;
|
|
1614
|
+
}
|
|
1615
|
+
const types = w.eventTypes === 'all' ? 'all' : w.eventTypes.join(', ');
|
|
1616
|
+
if (w.known) {
|
|
1617
|
+
return `${earlier} comes first and takes ${later}'s ${types} events, so ${later} applies only to its others. `
|
|
1618
|
+
+ `If it should apply to those too, ${move}.`;
|
|
1619
|
+
}
|
|
1620
|
+
return `${earlier} comes first and takes every ${types} event, so ${later} sees none. `
|
|
1621
|
+
+ `Nothing to do unless ${later} is meant for ${types} events; then ${move}. `
|
|
1622
|
+
+ `A scope on ${later} naming the event types it's for clears this note.`;
|
|
1567
1623
|
}
|
|
1568
1624
|
/** The text of a thrown value, for a log line. It never throws itself, whatever was thrown. */
|
|
1569
1625
|
function errorText(err) {
|
|
@@ -1682,10 +1738,12 @@ export class EventGate {
|
|
|
1682
1738
|
droppedBufferedEvents = 0;
|
|
1683
1739
|
// Per-policy stats
|
|
1684
1740
|
stats = new Map();
|
|
1685
|
-
//
|
|
1686
|
-
// config change
|
|
1687
|
-
|
|
1741
|
+
// The shadow lint's last findings (see refreshShadowWarnings), recomputed
|
|
1742
|
+
// on every config change and fingerprinted so an unchanged set doesn't
|
|
1743
|
+
// re-trace.
|
|
1688
1744
|
shadowWarningsFingerprint = '[]';
|
|
1745
|
+
/** See the constructor's `eventTypesFrom`. */
|
|
1746
|
+
eventTypesFromFn;
|
|
1689
1747
|
// Observability counters for events that didn't match any policy
|
|
1690
1748
|
totalEvaluations = 0;
|
|
1691
1749
|
defaultTriggered = 0;
|
|
@@ -1727,6 +1785,8 @@ export class EventGate {
|
|
|
1727
1785
|
addMessageFn;
|
|
1728
1786
|
requestInferenceFn;
|
|
1729
1787
|
getAgentNamesFn;
|
|
1788
|
+
/** Delivery-time re-check: is this channel held from the recipients now? */
|
|
1789
|
+
isHeldFn;
|
|
1730
1790
|
resolveRouteChannelFn;
|
|
1731
1791
|
channelShownFn;
|
|
1732
1792
|
isNewestEntryFn;
|
|
@@ -1740,9 +1800,11 @@ export class EventGate {
|
|
|
1740
1800
|
this.addMessageFn = opts.addMessage;
|
|
1741
1801
|
this.requestInferenceFn = opts.requestInference;
|
|
1742
1802
|
this.getAgentNamesFn = opts.getAgentNames;
|
|
1803
|
+
this.isHeldFn = opts.isHeld ?? (() => false);
|
|
1743
1804
|
this.resolveRouteChannelFn = opts.resolveRouteChannel ?? defaultRouteChannel;
|
|
1744
1805
|
this.channelShownFn = opts.channelShown;
|
|
1745
1806
|
this.isNewestEntryFn = opts.isNewestEntry;
|
|
1807
|
+
this.eventTypesFromFn = opts.eventTypesFrom;
|
|
1746
1808
|
this.now = opts.now ?? (() => Date.now());
|
|
1747
1809
|
this.judgeFn = opts.judge;
|
|
1748
1810
|
this.changesJudgedContextFn = opts.changesJudgedContext;
|
|
@@ -2988,22 +3050,31 @@ export class EventGate {
|
|
|
2988
3050
|
/** Current shadow-lint findings for the live policy order. Fresh compute —
|
|
2989
3051
|
* cheap (policy lists are tens of entries at most). */
|
|
2990
3052
|
lintShadows() {
|
|
2991
|
-
return findShadowedPolicies(this.config.policies);
|
|
3053
|
+
return findShadowedPolicies(this.config.policies, this.eventTypesFromFn);
|
|
2992
3054
|
}
|
|
2993
3055
|
/**
|
|
2994
|
-
*
|
|
2995
|
-
*
|
|
2996
|
-
*
|
|
2997
|
-
|
|
3056
|
+
* The sources the host knows changed (eventTypesFrom answers differently),
|
|
3057
|
+
* as when an MCPL server connects or is removed: the rule-order notes are
|
|
3058
|
+
* made again, and traced if they changed, as a change to the rules would.
|
|
3059
|
+
*/
|
|
3060
|
+
sourcesChanged() {
|
|
3061
|
+
this.refreshShadowWarnings('sources-changed');
|
|
3062
|
+
}
|
|
3063
|
+
/**
|
|
3064
|
+
* Recompute shadow warnings and, when the set changed, emit a
|
|
3065
|
+
* `gate:shadow-warnings` trace so the hazard lands in ops observability at
|
|
3066
|
+
* the moment the order changed — not at the next missed DM — and, with an
|
|
3067
|
+
* empty list, the moment the last of them went. Called from writeConfig,
|
|
3068
|
+
* reloadIfChanged and sourcesChanged.
|
|
2998
3069
|
*/
|
|
2999
3070
|
refreshShadowWarnings(reason) {
|
|
3000
3071
|
const warnings = this.lintShadows();
|
|
3001
3072
|
const fingerprint = JSON.stringify(warnings);
|
|
3002
3073
|
if (fingerprint === this.shadowWarningsFingerprint)
|
|
3003
3074
|
return;
|
|
3075
|
+
const hadSome = this.shadowWarningsFingerprint !== '[]';
|
|
3004
3076
|
this.shadowWarningsFingerprint = fingerprint;
|
|
3005
|
-
|
|
3006
|
-
if (warnings.length > 0) {
|
|
3077
|
+
if (warnings.length > 0 || hadSome) {
|
|
3007
3078
|
this.emitTrace({
|
|
3008
3079
|
type: 'gate:shadow-warnings',
|
|
3009
3080
|
reason,
|
|
@@ -3133,7 +3204,23 @@ export class EventGate {
|
|
|
3133
3204
|
// =========================================================================
|
|
3134
3205
|
// Event delivery
|
|
3135
3206
|
// =========================================================================
|
|
3136
|
-
deliverEvents(
|
|
3207
|
+
deliverEvents(batched) {
|
|
3208
|
+
// Delivery-time re-check: a channel tuned out after its events were
|
|
3209
|
+
// batched is held now, and "already shown above at arrival" would be
|
|
3210
|
+
// untrue of them. They are dropped; the hold's own reader has them.
|
|
3211
|
+
const heldAt = (e) => e.routeChannelId ?? e.channelId;
|
|
3212
|
+
const events = batched.filter((e) => {
|
|
3213
|
+
const channel = heldAt(e);
|
|
3214
|
+
return !(channel && this.isHeldFn(e.serverId, channel));
|
|
3215
|
+
});
|
|
3216
|
+
if (events.length < batched.length) {
|
|
3217
|
+
this.emitTrace({
|
|
3218
|
+
type: 'gate:held-dropped',
|
|
3219
|
+
dropped: batched.length - events.length,
|
|
3220
|
+
channels: [...new Set(batched.filter((e) => !events.includes(e)).map(heldAt))],
|
|
3221
|
+
timestamp: this.now(),
|
|
3222
|
+
});
|
|
3223
|
+
}
|
|
3137
3224
|
if (events.length === 0)
|
|
3138
3225
|
return;
|
|
3139
3226
|
const policyNames = [...new Set(events.map(e => e.policyName))];
|
|
@@ -3144,7 +3231,7 @@ export class EventGate {
|
|
|
3144
3231
|
// Only events with no context entry of their own carry their content.
|
|
3145
3232
|
const quoted = events.filter(e => !e.inContext);
|
|
3146
3233
|
const referenced = events.filter(e => e.inContext);
|
|
3147
|
-
const lines = quoted.map(e => `- [${e.policyName}] (${e.eventType}): ${e.content}`);
|
|
3234
|
+
const lines = quoted.map(e => `- [${e.policyName}] (${e.eventType}): ${suppliedValue(e.content)}`);
|
|
3148
3235
|
// How each referenced channel is named in the line, in order.
|
|
3149
3236
|
const shown = [];
|
|
3150
3237
|
if (referenced.length > 0) {
|
|
@@ -3163,7 +3250,7 @@ export class EventGate {
|
|
|
3163
3250
|
? '(unknown channel)'
|
|
3164
3251
|
: e.routeChannelId !== undefined && e.serverId !== undefined && this.channelShownFn
|
|
3165
3252
|
? this.channelShownFn({ serverId: e.serverId, channelId: e.routeChannelId })
|
|
3166
|
-
: id;
|
|
3253
|
+
: suppliedValue(id);
|
|
3167
3254
|
const key = JSON.stringify([e.serverId ?? null, id ?? null]);
|
|
3168
3255
|
const entry = byChannel.get(key) ?? { name, count: 0, oldest: e.timestamp, label: e.channelLabel };
|
|
3169
3256
|
entry.count += 1;
|
|
@@ -3176,7 +3263,7 @@ export class EventGate {
|
|
|
3176
3263
|
// agent can still address tools that want the composite id. A name
|
|
3177
3264
|
// may carry its own `#`, so one is added only where the name lacks
|
|
3178
3265
|
// it, as at the other places that add a `#`.
|
|
3179
|
-
const channel = label ? `${label.startsWith('#') ?
|
|
3266
|
+
const channel = label ? `${label.startsWith('#') ? '' : '#'}${suppliedValue(label)} (${name})` : name;
|
|
3180
3267
|
shown.push(channel);
|
|
3181
3268
|
lines.push(referenceLine(count, channel, oldest, Date.now()));
|
|
3182
3269
|
}
|
|
@@ -3188,7 +3275,7 @@ export class EventGate {
|
|
|
3188
3275
|
// gate hands the line to the wake (WakeProvenance.line) and a fresh start
|
|
3189
3276
|
// of the wake's turn decides it (WakeLine). Several messages, one with
|
|
3190
3277
|
// anything after it, or content the line quotes, keep the line now.
|
|
3191
|
-
const text = `[
|
|
3278
|
+
const text = `[${NOTICE_TAG.gate}: ${events.length} event${events.length > 1 ? 's' : ''} matched]\n\n${lines.join('\n')}`;
|
|
3192
3279
|
const only = events.length === 1 && events[0].inContext ? events[0] : undefined;
|
|
3193
3280
|
let line;
|
|
3194
3281
|
if (only && this.newestEntry(only)) {
|
|
@@ -3431,7 +3518,7 @@ export class EventGate {
|
|
|
3431
3518
|
record.last = {
|
|
3432
3519
|
at: Date.now(),
|
|
3433
3520
|
verdict: outcome,
|
|
3434
|
-
reason:
|
|
3521
|
+
reason: cutToFit(suppliedValue(reason), 300),
|
|
3435
3522
|
eventCount: state.events.length,
|
|
3436
3523
|
durationMs,
|
|
3437
3524
|
...(!failed && typeof verdict.inputTokens === 'number' ? { inputTokens: verdict.inputTokens } : {}),
|
|
@@ -3440,7 +3527,7 @@ export class EventGate {
|
|
|
3440
3527
|
this.judgeRecords.set(policyName, record);
|
|
3441
3528
|
if (failed) {
|
|
3442
3529
|
this.judgeFailStreak++;
|
|
3443
|
-
this.judgeLastFailure =
|
|
3530
|
+
this.judgeLastFailure = cutToFit(suppliedValue(reason), 200);
|
|
3444
3531
|
}
|
|
3445
3532
|
else {
|
|
3446
3533
|
this.judgeFailStreak = 0;
|
|
@@ -3696,10 +3783,9 @@ export class EventGate {
|
|
|
3696
3783
|
this.sleepTimer = setTimeout(() => this.wakeFromSleep('sleep-expired'), Math.min(remaining, MAX_TIMER_MS));
|
|
3697
3784
|
}
|
|
3698
3785
|
/**
|
|
3699
|
-
* `agentName` is gone, as
|
|
3700
|
-
*
|
|
3701
|
-
*
|
|
3702
|
-
* framework refuses their `sleep`).
|
|
3786
|
+
* `agentName` is gone, as an agent's end removes one: its pending
|
|
3787
|
+
* self-wake is cancelled, and a sleep it set ends, rather than go on
|
|
3788
|
+
* quieting every agent and then wake a name that no longer exists.
|
|
3703
3789
|
*/
|
|
3704
3790
|
agentGone(agentName) {
|
|
3705
3791
|
const selfWake = this.selfWakeTimers.get(agentName);
|
|
@@ -3707,6 +3793,8 @@ export class EventGate {
|
|
|
3707
3793
|
clearTimeout(selfWake);
|
|
3708
3794
|
this.selfWakeTimers.delete(agentName);
|
|
3709
3795
|
}
|
|
3796
|
+
if (this.sleepAgent === agentName)
|
|
3797
|
+
this.clearSleep();
|
|
3710
3798
|
}
|
|
3711
3799
|
// =========================================================================
|
|
3712
3800
|
// Self-wake (skip_reply wake_in_seconds)
|
|
@@ -3752,7 +3840,7 @@ export class EventGate {
|
|
|
3752
3840
|
const placement = {};
|
|
3753
3841
|
this.addMessageFn('user', [{
|
|
3754
3842
|
type: 'text',
|
|
3755
|
-
text: `[
|
|
3843
|
+
text: `[${NOTICE_TAG.selfWake}] your ${source} timer (${Math.round(ms / 1000)}s) elapsed — now ${nowIso}`,
|
|
3756
3844
|
}], { source: 'gate:self-wake' }, agentName, placement);
|
|
3757
3845
|
this.requestInferenceFn(agentName, `self-scheduled wake (${source}, ${Math.round(ms / 1000)}s)`, 'self-wake', undefined, placement);
|
|
3758
3846
|
}, ms);
|
|
@@ -4008,7 +4096,9 @@ export class EventGate {
|
|
|
4008
4096
|
this.judgeUnwiredNotice(), this.judgeFailingNotice(),
|
|
4009
4097
|
]
|
|
4010
4098
|
.filter((e) => e !== null),
|
|
4011
|
-
|
|
4099
|
+
// Fresh, not the cache: the sources the host knows (eventTypesFrom)
|
|
4100
|
+
// change as servers connect, with no change to the rules.
|
|
4101
|
+
shadowWarnings: this.lintShadows().map(formatShadowWarning),
|
|
4012
4102
|
totalEvaluations: this.totalEvaluations,
|
|
4013
4103
|
defaultDecisions: {
|
|
4014
4104
|
triggered: this.defaultTriggered,
|