@animalabs/agent-framework 0.32.0 → 0.34.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 +340 -22
- package/dist/src/admission/admit.d.ts +18 -0
- package/dist/src/admission/admit.d.ts.map +1 -1
- package/dist/src/admission/admit.js +16 -3
- package/dist/src/admission/admit.js.map +1 -1
- package/dist/src/agent.d.ts +208 -80
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +345 -113
- 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 +50 -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 +4 -20
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/append-all.d.ts +5 -0
- package/dist/src/append-all.d.ts.map +1 -0
- package/dist/src/append-all.js +8 -0
- package/dist/src/append-all.js.map +1 -0
- package/dist/src/code-execution/isolate/scripts.d.ts +12 -8
- package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/scripts.js +24 -0
- package/dist/src/code-execution/isolate/scripts.js.map +1 -1
- package/dist/src/config-checks.d.ts +7 -0
- package/dist/src/config-checks.d.ts.map +1 -1
- package/dist/src/config-checks.js +14 -0
- package/dist/src/config-checks.js.map +1 -1
- package/dist/src/context-manager-errors.d.ts +25 -0
- package/dist/src/context-manager-errors.d.ts.map +1 -0
- package/dist/src/context-manager-errors.js +31 -0
- package/dist/src/context-manager-errors.js.map +1 -0
- package/dist/src/context-options.d.ts +70 -0
- package/dist/src/context-options.d.ts.map +1 -0
- package/dist/src/context-options.js +90 -0
- package/dist/src/context-options.js.map +1 -0
- package/dist/src/cut-off-round.js +4 -4
- package/dist/src/deferred-import.d.ts +93 -0
- package/dist/src/deferred-import.d.ts.map +1 -0
- package/dist/src/deferred-import.js +177 -0
- package/dist/src/deferred-import.js.map +1 -0
- package/dist/src/dendrite/audience.d.ts +223 -0
- package/dist/src/dendrite/audience.d.ts.map +1 -0
- package/dist/src/dendrite/audience.js +202 -0
- package/dist/src/dendrite/audience.js.map +1 -0
- package/dist/src/dendrite/index.d.ts +5 -3
- package/dist/src/dendrite/index.d.ts.map +1 -1
- package/dist/src/dendrite/index.js +2 -1
- package/dist/src/dendrite/index.js.map +1 -1
- package/dist/src/dendrite/presets.d.ts +10 -5
- package/dist/src/dendrite/presets.d.ts.map +1 -1
- package/dist/src/dendrite/presets.js +17 -5
- package/dist/src/dendrite/presets.js.map +1 -1
- package/dist/src/dendrite/registry.d.ts +62 -7
- package/dist/src/dendrite/registry.d.ts.map +1 -1
- package/dist/src/dendrite/registry.js +183 -12
- package/dist/src/dendrite/registry.js.map +1 -1
- package/dist/src/dendrite/types.d.ts +91 -8
- package/dist/src/dendrite/types.d.ts.map +1 -1
- package/dist/src/failure-text.d.ts +36 -0
- package/dist/src/failure-text.d.ts.map +1 -0
- package/dist/src/failure-text.js +89 -0
- package/dist/src/failure-text.js.map +1 -0
- package/dist/src/foreign-rounds.d.ts +69 -0
- package/dist/src/foreign-rounds.d.ts.map +1 -0
- package/dist/src/foreign-rounds.js +152 -0
- package/dist/src/foreign-rounds.js.map +1 -0
- package/dist/src/framework.d.ts +2064 -842
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +8586 -3739
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +125 -21
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +487 -72
- 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.map +1 -1
- package/dist/src/gate/reply-judge.d.ts +4 -0
- package/dist/src/gate/reply-judge.d.ts.map +1 -1
- package/dist/src/gate/reply-judge.js +12 -3
- package/dist/src/gate/reply-judge.js.map +1 -1
- package/dist/src/gate/rule-scope.d.ts +30 -0
- package/dist/src/gate/rule-scope.d.ts.map +1 -0
- package/dist/src/gate/rule-scope.js +41 -0
- package/dist/src/gate/rule-scope.js.map +1 -0
- package/dist/src/gate/suppress-script-worker.d.ts +2 -0
- package/dist/src/gate/suppress-script-worker.d.ts.map +1 -0
- package/dist/src/gate/suppress-script-worker.js +103 -0
- package/dist/src/gate/suppress-script-worker.js.map +1 -0
- package/dist/src/gate/suppress-scripts.d.ts +105 -0
- package/dist/src/gate/suppress-scripts.d.ts.map +1 -0
- package/dist/src/gate/suppress-scripts.js +403 -0
- package/dist/src/gate/suppress-scripts.js.map +1 -0
- package/dist/src/gate/suppression-review.d.ts +143 -0
- package/dist/src/gate/suppression-review.d.ts.map +1 -0
- package/dist/src/gate/suppression-review.js +463 -0
- package/dist/src/gate/suppression-review.js.map +1 -0
- package/dist/src/gate/suppression-stats.d.ts +125 -0
- package/dist/src/gate/suppression-stats.d.ts.map +1 -0
- package/dist/src/gate/suppression-stats.js +214 -0
- package/dist/src/gate/suppression-stats.js.map +1 -0
- package/dist/src/gate/types.d.ts +142 -7
- package/dist/src/gate/types.d.ts.map +1 -1
- package/dist/src/gate/wake-onboarding.d.ts +119 -0
- package/dist/src/gate/wake-onboarding.d.ts.map +1 -0
- package/dist/src/gate/wake-onboarding.js +277 -0
- package/dist/src/gate/wake-onboarding.js.map +1 -0
- package/dist/src/heartbeat/heartbeat.js +1 -1
- package/dist/src/heartbeat/heartbeat.js.map +1 -1
- package/dist/src/held-writes.d.ts +31 -23
- package/dist/src/held-writes.d.ts.map +1 -1
- package/dist/src/held-writes.js +44 -59
- package/dist/src/held-writes.js.map +1 -1
- package/dist/src/index.d.ts +6 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/inference-bounds.d.ts +2 -1
- package/dist/src/inference-bounds.d.ts.map +1 -1
- package/dist/src/inference-bounds.js +9 -6
- package/dist/src/inference-bounds.js.map +1 -1
- package/dist/src/jsonrpc-envelope.d.ts +69 -0
- package/dist/src/jsonrpc-envelope.d.ts.map +1 -0
- package/dist/src/jsonrpc-envelope.js +66 -0
- package/dist/src/jsonrpc-envelope.js.map +1 -0
- package/dist/src/mcpl/channel-registry.d.ts +188 -28
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +426 -70
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/checkpoint-manager.d.ts +2 -4
- package/dist/src/mcpl/checkpoint-manager.d.ts.map +1 -1
- package/dist/src/mcpl/checkpoint-manager.js.map +1 -1
- package/dist/src/mcpl/feature-set-manager.d.ts +2 -4
- package/dist/src/mcpl/feature-set-manager.d.ts.map +1 -1
- package/dist/src/mcpl/feature-set-manager.js.map +1 -1
- package/dist/src/mcpl/inbound-source.d.ts +2 -1
- package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
- package/dist/src/mcpl/inbound-source.js +2 -1
- package/dist/src/mcpl/inbound-source.js.map +1 -1
- package/dist/src/mcpl/inference-router.d.ts +6 -6
- package/dist/src/mcpl/inference-router.d.ts.map +1 -1
- package/dist/src/mcpl/inference-router.js.map +1 -1
- package/dist/src/mcpl/modern-connection.d.ts +109 -15
- package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
- package/dist/src/mcpl/modern-connection.js +593 -86
- package/dist/src/mcpl/modern-connection.js.map +1 -1
- package/dist/src/mcpl/protocol-family.d.ts +3 -1
- package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
- package/dist/src/mcpl/protocol-family.js +15 -9
- package/dist/src/mcpl/protocol-family.js.map +1 -1
- package/dist/src/mcpl/push-coalescer.d.ts +132 -22
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +105 -15
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/push-handler.d.ts +9 -7
- package/dist/src/mcpl/push-handler.d.ts.map +1 -1
- package/dist/src/mcpl/push-handler.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +50 -28
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +165 -72
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/tool-classes.d.ts.map +1 -1
- package/dist/src/mcpl/tool-classes.js +3 -0
- package/dist/src/mcpl/tool-classes.js.map +1 -1
- package/dist/src/mcpl/tool-presence.d.ts.map +1 -1
- package/dist/src/mcpl/tool-presence.js +10 -6
- package/dist/src/mcpl/tool-presence.js.map +1 -1
- package/dist/src/mcpl/toolset-host.d.ts.map +1 -1
- package/dist/src/mcpl/toolset-host.js +7 -6
- package/dist/src/mcpl/toolset-host.js.map +1 -1
- package/dist/src/mcpl/toolsets-module.d.ts.map +1 -1
- package/dist/src/mcpl/toolsets-module.js +2 -1
- package/dist/src/mcpl/toolsets-module.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +33 -6
- 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 +24 -1
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +68 -18
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/discord/index.d.ts +45 -8
- package/dist/src/modules/discord/index.d.ts.map +1 -1
- package/dist/src/modules/discord/index.js +238 -87
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/health/index.js +2 -2
- package/dist/src/modules/health/index.js.map +1 -1
- package/dist/src/modules/history/index.d.ts +59 -0
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +432 -67
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/history/semantic.d.ts +6 -5
- package/dist/src/modules/history/semantic.d.ts.map +1 -1
- package/dist/src/modules/history/semantic.js +18 -25
- package/dist/src/modules/history/semantic.js.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.d.ts +1 -1
- package/dist/src/modules/workspace/disk-agreement.js +1 -1
- package/dist/src/modules/workspace/index.d.ts +28 -7
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +80 -25
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +2 -1
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +3 -2
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/notice-tags.d.ts +20 -9
- package/dist/src/notice-tags.d.ts.map +1 -1
- package/dist/src/notice-tags.js +20 -9
- package/dist/src/notice-tags.js.map +1 -1
- package/dist/src/operator-log.d.ts +36 -3
- package/dist/src/operator-log.d.ts.map +1 -1
- package/dist/src/operator-log.js +2 -2
- package/dist/src/operator-log.js.map +1 -1
- package/dist/src/presentation.d.ts +747 -0
- package/dist/src/presentation.d.ts.map +1 -0
- package/dist/src/presentation.js +1437 -0
- package/dist/src/presentation.js.map +1 -0
- package/dist/src/prose-drafts.d.ts +15 -11
- package/dist/src/prose-drafts.d.ts.map +1 -1
- package/dist/src/prose-drafts.js +16 -12
- package/dist/src/prose-drafts.js.map +1 -1
- package/dist/src/read-marks.d.ts +192 -0
- package/dist/src/read-marks.d.ts.map +1 -0
- package/dist/src/read-marks.js +242 -0
- package/dist/src/read-marks.js.map +1 -0
- package/dist/src/reasoning-loss.d.ts +5 -0
- package/dist/src/reasoning-loss.d.ts.map +1 -0
- package/dist/src/reasoning-loss.js +8 -0
- package/dist/src/reasoning-loss.js.map +1 -0
- package/dist/src/recovery/offline-branch.d.ts +91 -6
- package/dist/src/recovery/offline-branch.d.ts.map +1 -1
- package/dist/src/recovery/offline-branch.js +277 -32
- package/dist/src/recovery/offline-branch.js.map +1 -1
- package/dist/src/recovery/recover-cli.js +24 -4
- package/dist/src/recovery/recover-cli.js.map +1 -1
- package/dist/src/send-tools.d.ts +5 -9
- package/dist/src/send-tools.d.ts.map +1 -1
- package/dist/src/send-tools.js +40 -7
- package/dist/src/send-tools.js.map +1 -1
- package/dist/src/sent-rows.js +1 -1
- package/dist/src/stored-injections.d.ts +2 -2
- package/dist/src/stored-injections.js +2 -2
- package/dist/src/stored-removal.d.ts +17 -4
- package/dist/src/stored-removal.d.ts.map +1 -1
- package/dist/src/stored-removal.js +29 -5
- package/dist/src/stored-removal.js.map +1 -1
- package/dist/src/supplied-text.d.ts +1 -1
- package/dist/src/supplied-text.js +3 -3
- package/dist/src/supplied-text.js.map +1 -1
- package/dist/src/thinking-drops.d.ts +2 -0
- package/dist/src/thinking-drops.d.ts.map +1 -1
- package/dist/src/thinking-drops.js.map +1 -1
- package/dist/src/tool-presentation.d.ts.map +1 -1
- package/dist/src/tool-presentation.js +38 -9
- package/dist/src/tool-presentation.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts +12 -1
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +42 -8
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +1170 -81
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +3732 -369
- package/dist/src/tune-out/coordinator.js.map +1 -1
- package/dist/src/tune-out/tools.d.ts +114 -17
- package/dist/src/tune-out/tools.d.ts.map +1 -1
- package/dist/src/tune-out/tools.js +89 -28
- package/dist/src/tune-out/tools.js.map +1 -1
- package/dist/src/tune-out/window-anchor.d.ts +143 -0
- package/dist/src/tune-out/window-anchor.d.ts.map +1 -0
- package/dist/src/tune-out/window-anchor.js +202 -0
- package/dist/src/tune-out/window-anchor.js.map +1 -0
- package/dist/src/types/agent.d.ts +121 -25
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +2 -0
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +72 -17
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/inference-log.d.ts +1 -0
- package/dist/src/types/inference-log.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +180 -69
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +573 -39
- package/dist/src/types/trace.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/admission/admit.ts +32 -3
- package/src/agent.ts +392 -132
- package/src/api/mcp-server-core.ts +54 -17
- package/src/api/server.ts +4 -23
- package/src/append-all.ts +6 -0
- package/src/code-execution/isolate/scripts.ts +28 -3
- package/src/config-checks.ts +14 -0
- package/src/context-manager-errors.ts +37 -0
- package/src/context-options.ts +106 -0
- package/src/cut-off-round.ts +4 -4
- package/src/deferred-import.ts +239 -0
- package/src/dendrite/audience.ts +315 -0
- package/src/dendrite/index.ts +14 -2
- package/src/dendrite/presets.ts +18 -6
- package/src/dendrite/registry.ts +213 -14
- package/src/dendrite/types.ts +92 -8
- package/src/failure-text.ts +88 -0
- package/src/foreign-rounds.ts +199 -0
- package/src/framework.ts +8796 -3813
- package/src/gate/event-gate.ts +518 -91
- package/src/gate/index.ts +3 -0
- package/src/gate/reply-judge.ts +12 -3
- package/src/gate/rule-scope.ts +45 -0
- package/src/gate/suppress-script-worker.ts +89 -0
- package/src/gate/suppress-scripts.ts +414 -0
- package/src/gate/suppression-review.ts +517 -0
- package/src/gate/suppression-stats.ts +314 -0
- package/src/gate/types.ts +148 -7
- package/src/gate/wake-onboarding.ts +309 -0
- package/src/heartbeat/heartbeat.ts +1 -1
- package/src/held-writes.ts +49 -60
- package/src/index.ts +10 -2
- package/src/inference-bounds.ts +11 -6
- package/src/jsonrpc-envelope.ts +81 -0
- package/src/mcpl/channel-registry.ts +513 -116
- package/src/mcpl/checkpoint-manager.ts +3 -2
- package/src/mcpl/feature-set-manager.ts +2 -1
- package/src/mcpl/inbound-source.ts +2 -1
- package/src/mcpl/inference-router.ts +7 -4
- package/src/mcpl/modern-connection.ts +629 -91
- package/src/mcpl/protocol-family.ts +15 -9
- package/src/mcpl/push-coalescer.ts +193 -34
- package/src/mcpl/push-handler.ts +10 -5
- package/src/mcpl/server-connection.ts +169 -75
- package/src/mcpl/tool-classes.ts +3 -0
- package/src/mcpl/tool-presence.ts +10 -5
- package/src/mcpl/toolset-host.ts +7 -6
- package/src/mcpl/toolsets-module.ts +2 -1
- package/src/mcpl/types.ts +33 -6
- package/src/module-registry.ts +73 -17
- package/src/modules/discord/index.ts +230 -82
- package/src/modules/health/index.ts +2 -2
- package/src/modules/history/index.ts +439 -70
- package/src/modules/history/semantic.ts +18 -24
- package/src/modules/workspace/disk-agreement.ts +1 -1
- package/src/modules/workspace/index.ts +89 -26
- package/src/modules/workspace/observe.ts +2 -1
- package/src/modules/workspace/reconcile.ts +3 -2
- package/src/notice-tags.ts +21 -9
- package/src/operator-log.ts +36 -3
- package/src/presentation.ts +1678 -0
- package/src/prose-drafts.ts +16 -12
- package/src/read-marks.ts +328 -0
- package/src/reasoning-loss.ts +7 -0
- package/src/recovery/offline-branch.ts +350 -35
- package/src/recovery/recover-cli.ts +23 -4
- package/src/send-tools.ts +40 -7
- package/src/sent-rows.ts +1 -1
- package/src/stored-injections.ts +2 -2
- package/src/stored-removal.ts +31 -7
- package/src/supplied-text.ts +3 -3
- package/src/thinking-drops.ts +2 -0
- package/src/tool-presentation.ts +34 -9
- package/src/tool-result-guard.ts +41 -7
- package/src/tune-out/coordinator.ts +4121 -472
- package/src/tune-out/tools.ts +162 -44
- package/src/tune-out/window-anchor.ts +277 -0
- package/src/types/agent.ts +122 -25
- package/src/types/events.ts +2 -0
- package/src/types/framework.ts +73 -17
- package/src/types/inference-log.ts +1 -0
- package/src/types/module.ts +181 -68
- package/src/types/trace.ts +607 -43
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the agent's suppress rules have kept out of its context
|
|
3
|
+
* (`suppression_stats`), read from the stored rows themselves: each carries
|
|
4
|
+
* the record a suppress rule stamped on it as it arrived
|
|
5
|
+
* (`metadata.suppressed = { rule, eventType }`, the framework's
|
|
6
|
+
* suppressedRow). The rows are the record, so the counts cover every start
|
|
7
|
+
* of the host and follow the branch the store is on, and nothing beside
|
|
8
|
+
* them is kept.
|
|
9
|
+
*/
|
|
10
|
+
/** Longest preview shown, in characters. */
|
|
11
|
+
export const SUPPRESSION_PREVIEW_CHARS = 160;
|
|
12
|
+
/** Most recent rows shown per rule. */
|
|
13
|
+
export const MAX_RECENT = 20;
|
|
14
|
+
const DEFAULT_RECENT = 3;
|
|
15
|
+
const MAX_KEYS = 10;
|
|
16
|
+
/** The record a row carries when a suppress rule took it, or undefined. */
|
|
17
|
+
export function suppressionRecordOf(metadata) {
|
|
18
|
+
const record = metadata?.suppressed;
|
|
19
|
+
if (!record || typeof record !== 'object')
|
|
20
|
+
return undefined;
|
|
21
|
+
const { rule, eventType, source } = record;
|
|
22
|
+
if (typeof rule !== 'string')
|
|
23
|
+
return undefined;
|
|
24
|
+
return {
|
|
25
|
+
rule,
|
|
26
|
+
...(typeof eventType === 'string' && eventType !== '' ? { eventType } : {}),
|
|
27
|
+
...(typeof source === 'string' && source !== '' ? { source } : {}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Where a suppressed row came from: the source its record names (a module's, which its metadata may not), else its server. */
|
|
31
|
+
function sourceOf(row, record) {
|
|
32
|
+
if (record?.source)
|
|
33
|
+
return record.source;
|
|
34
|
+
const serverId = row.metadata?.serverId;
|
|
35
|
+
return typeof serverId === 'string' && serverId !== '' ? serverId : undefined;
|
|
36
|
+
}
|
|
37
|
+
/** The author a row names: a channel message's `author.name`, or a push event's `authorName`. */
|
|
38
|
+
function authorOf(md) {
|
|
39
|
+
const name = md.author?.name ?? md.authorName;
|
|
40
|
+
return typeof name === 'string' && name !== '' ? name : undefined;
|
|
41
|
+
}
|
|
42
|
+
const textOf = (row) => row.content.filter((b) => b.type === 'text' && typeof b.text === 'string').map((b) => b.text).join('\n');
|
|
43
|
+
const msOf = (timestamp) => timestamp instanceof Date ? timestamp.getTime() : typeof timestamp === 'number' ? timestamp : Date.parse(timestamp);
|
|
44
|
+
const isoOf = (ms) => (Number.isFinite(ms) ? new Date(ms).toISOString() : 'unknown');
|
|
45
|
+
/** A text on one line, cut at SUPPRESSION_PREVIEW_CHARS characters (code points), with an ellipsis where cut. */
|
|
46
|
+
function previewOf(text) {
|
|
47
|
+
const line = text.replace(/\s+/g, ' ').trim();
|
|
48
|
+
const chars = [...line];
|
|
49
|
+
return chars.length <= SUPPRESSION_PREVIEW_CHARS ? line : `${chars.slice(0, SUPPRESSION_PREVIEW_CHARS - 1).join('')}…`;
|
|
50
|
+
}
|
|
51
|
+
/** Counts, the largest first; past MAX_KEYS, the rest summed as "(others)". Built from entries, so any name, "__proto__" included, is a key of its own. */
|
|
52
|
+
function topCounts(counts) {
|
|
53
|
+
const sorted = [...counts].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
54
|
+
const entries = sorted.slice(0, MAX_KEYS);
|
|
55
|
+
const rest = sorted.slice(MAX_KEYS).reduce((sum, [, n]) => sum + n, 0);
|
|
56
|
+
if (rest > 0)
|
|
57
|
+
entries.push(['(others)', rest]);
|
|
58
|
+
return Object.fromEntries(entries);
|
|
59
|
+
}
|
|
60
|
+
function shown(row, record) {
|
|
61
|
+
const md = row.metadata ?? {};
|
|
62
|
+
const source = sourceOf(row, record);
|
|
63
|
+
const channel = typeof md.channelId === 'string' && md.channelId !== '' ? md.channelId : undefined;
|
|
64
|
+
const author = authorOf(md);
|
|
65
|
+
return {
|
|
66
|
+
id: row.id,
|
|
67
|
+
at: isoOf(msOf(row.timestamp)),
|
|
68
|
+
eventType: record?.eventType ?? 'unknown',
|
|
69
|
+
...(source ? { source } : {}),
|
|
70
|
+
...(channel ? { channel } : {}),
|
|
71
|
+
...(author ? { author } : {}),
|
|
72
|
+
preview: previewOf(textOf(row)),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The stats for `rows` (a message slot, oldest first), with every suppress
|
|
77
|
+
* rule in force listed even where it has hidden nothing yet. Rules in force
|
|
78
|
+
* come first, in gate.json's order; rules no longer in force follow, the
|
|
79
|
+
* most recently active first.
|
|
80
|
+
*/
|
|
81
|
+
export function suppressionStats(rows, inForce, opts = {}) {
|
|
82
|
+
const recentWanted = Math.max(0, Math.min(MAX_RECENT, Math.floor(opts.recent ?? DEFAULT_RECENT)));
|
|
83
|
+
const tallies = new Map();
|
|
84
|
+
let total = 0;
|
|
85
|
+
let totalCharacters = 0;
|
|
86
|
+
for (const row of rows) {
|
|
87
|
+
const record = suppressionRecordOf(row.metadata);
|
|
88
|
+
if (!record)
|
|
89
|
+
continue;
|
|
90
|
+
if (opts.rule !== undefined && record.rule !== opts.rule)
|
|
91
|
+
continue;
|
|
92
|
+
const at = msOf(row.timestamp);
|
|
93
|
+
if (opts.sinceMs !== undefined && !(at >= opts.sinceMs))
|
|
94
|
+
continue;
|
|
95
|
+
let tally = tallies.get(record.rule);
|
|
96
|
+
if (!tally) {
|
|
97
|
+
tally = { suppressed: 0, characters: 0, first: at, last: at, bySource: new Map(), byEventType: new Map(), recent: [] };
|
|
98
|
+
tallies.set(record.rule, tally);
|
|
99
|
+
}
|
|
100
|
+
const characters = [...textOf(row)].length;
|
|
101
|
+
tally.suppressed++;
|
|
102
|
+
tally.characters += characters;
|
|
103
|
+
if (at < tally.first)
|
|
104
|
+
tally.first = at;
|
|
105
|
+
if (at > tally.last)
|
|
106
|
+
tally.last = at;
|
|
107
|
+
const source = sourceOf(row, record) ?? '(none)';
|
|
108
|
+
tally.bySource.set(source, (tally.bySource.get(source) ?? 0) + 1);
|
|
109
|
+
const eventType = record.eventType ?? 'unknown';
|
|
110
|
+
tally.byEventType.set(eventType, (tally.byEventType.get(eventType) ?? 0) + 1);
|
|
111
|
+
if (recentWanted > 0) {
|
|
112
|
+
tally.recent.push({ row, record });
|
|
113
|
+
if (tally.recent.length > recentWanted)
|
|
114
|
+
tally.recent.shift();
|
|
115
|
+
}
|
|
116
|
+
total++;
|
|
117
|
+
totalCharacters += characters;
|
|
118
|
+
}
|
|
119
|
+
const ruleStats = (name, rule) => {
|
|
120
|
+
const tally = tallies.get(name);
|
|
121
|
+
return {
|
|
122
|
+
rule: name,
|
|
123
|
+
inForce: rule !== undefined,
|
|
124
|
+
...(rule !== undefined ? { sinceStart: rule.sinceStart } : {}),
|
|
125
|
+
suppressed: tally?.suppressed ?? 0,
|
|
126
|
+
characters: tally?.characters ?? 0,
|
|
127
|
+
...(tally ? { first: isoOf(tally.first), last: isoOf(tally.last) } : {}),
|
|
128
|
+
bySource: tally ? topCounts(tally.bySource) : {},
|
|
129
|
+
byEventType: tally ? topCounts(tally.byEventType) : {},
|
|
130
|
+
recent: tally ? tally.recent.slice().reverse().map(({ row, record }) => shown(row, record)) : [],
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const listed = new Set();
|
|
134
|
+
const out = [];
|
|
135
|
+
for (const rule of inForce) {
|
|
136
|
+
if (listed.has(rule.name) || (opts.rule !== undefined && rule.name !== opts.rule))
|
|
137
|
+
continue;
|
|
138
|
+
listed.add(rule.name);
|
|
139
|
+
out.push(ruleStats(rule.name, rule));
|
|
140
|
+
}
|
|
141
|
+
const gone = [...tallies.keys()].filter((name) => !listed.has(name))
|
|
142
|
+
.sort((a, b) => tallies.get(b).last - tallies.get(a).last || a.localeCompare(b));
|
|
143
|
+
for (const name of gone)
|
|
144
|
+
out.push(ruleStats(name, undefined));
|
|
145
|
+
return { rules: out, total, totalCharacters };
|
|
146
|
+
}
|
|
147
|
+
/** A row's content as text: text blocks as written, any other block named in brackets. */
|
|
148
|
+
function fullTextOf(row) {
|
|
149
|
+
return row.content
|
|
150
|
+
.map((b) => (b.type === 'text' && typeof b.text === 'string' ? b.text : `[${b.type}]`))
|
|
151
|
+
.join('\n');
|
|
152
|
+
}
|
|
153
|
+
/** The suppressed rows among `rows`, oldest first, their text in full; times are when each was stored. */
|
|
154
|
+
export function suppressedRecords(rows, opts = {}) {
|
|
155
|
+
const out = [];
|
|
156
|
+
for (const row of rows) {
|
|
157
|
+
const record = suppressionRecordOf(row.metadata);
|
|
158
|
+
if (!record || (opts.rule !== undefined && record.rule !== opts.rule))
|
|
159
|
+
continue;
|
|
160
|
+
const at = msOf(row.timestamp);
|
|
161
|
+
if (opts.sinceMs !== undefined && !(at >= opts.sinceMs))
|
|
162
|
+
continue;
|
|
163
|
+
if (opts.untilMs !== undefined && !(at < opts.untilMs))
|
|
164
|
+
continue;
|
|
165
|
+
const { source, channel, author } = shown(row, record);
|
|
166
|
+
out.push({
|
|
167
|
+
id: row.id,
|
|
168
|
+
at: isoOf(at),
|
|
169
|
+
rule: record.rule,
|
|
170
|
+
eventType: record.eventType ?? 'unknown',
|
|
171
|
+
...(source ? { source } : {}),
|
|
172
|
+
...(channel ? { channel } : {}),
|
|
173
|
+
...(author ? { author } : {}),
|
|
174
|
+
text: fullTextOf(row),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return out;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A dump's file content, at most `maxBytes` (UTF-8): the newest records that
|
|
181
|
+
* fit, oldest first, and how many older ones were left out to fit. A
|
|
182
|
+
* transcript opens with a header naming what it holds (`title`, given how
|
|
183
|
+
* many it holds and the oldest's time) and, when some were left out, how many.
|
|
184
|
+
*/
|
|
185
|
+
export function renderSuppressedDump(records, format, opts) {
|
|
186
|
+
const entry = (r) => format === 'jsonl'
|
|
187
|
+
? `${JSON.stringify(r)}\n`
|
|
188
|
+
: `[${r.at}] ${r.rule} · ${r.eventType}${r.source ? ` · ${r.source}` : ''}${r.channel ? ` · ${r.channel}` : ''}`
|
|
189
|
+
+ `${r.author ? ` · ${r.author}` : ''} · ${r.id}\n${r.text}\n\n`;
|
|
190
|
+
const entries = records.map(entry);
|
|
191
|
+
const titleOf = (from) => typeof opts.title === 'string'
|
|
192
|
+
? opts.title
|
|
193
|
+
: opts.title(entries.length - from, records[from]?.at ?? '');
|
|
194
|
+
const header = (from) => format === 'jsonl'
|
|
195
|
+
? ''
|
|
196
|
+
: `# ${titleOf(from)}\n${from > 0 ? `(${from} older events left out to fit)\n` : ''}\n`;
|
|
197
|
+
// The most records, newest first, that fit beside the header they make:
|
|
198
|
+
// the header names how many were left out, so it's sized for each count.
|
|
199
|
+
let bytes = 0;
|
|
200
|
+
let from = entries.length;
|
|
201
|
+
let best = entries.length;
|
|
202
|
+
while (from > 0) {
|
|
203
|
+
bytes += Buffer.byteLength(entries[from - 1]);
|
|
204
|
+
from--;
|
|
205
|
+
if (Buffer.byteLength(header(from)) + bytes <= opts.maxBytes)
|
|
206
|
+
best = from;
|
|
207
|
+
else if (bytes > opts.maxBytes)
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
if (best === entries.length)
|
|
211
|
+
return { content: '', written: 0, omitted: entries.length };
|
|
212
|
+
return { content: header(best) + entries.slice(best).join(''), written: entries.length - best, omitted: best };
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=suppression-stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suppression-stats.js","sourceRoot":"","sources":["../../../src/gate/suppression-stats.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiEH,4CAA4C;AAC5C,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAC7C,uCAAuC;AACvC,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAC7B,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,QAAQ,GAAG,EAAE,CAAC;AAEpB,2EAA2E;AAC3E,MAAM,UAAU,mBAAmB,CAAC,QAA6C;IAC/E,MAAM,MAAM,GAAG,QAAQ,EAAE,UAAU,CAAC;IACpC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC5D,MAAM,EAAE,IAAI,EAAE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C,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,kCAAkC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;IAC1F,wEAAwE;IACxE,yEAAyE;IACzE,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAC1B,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAC1B,OAAO,IAAI,GAAG,CAAC,EAAE,CAAC;QAChB,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC,CAAC;QAC/C,IAAI,EAAE,CAAC;QACP,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,QAAQ;YAAE,IAAI,GAAG,IAAI,CAAC;aACrE,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ;YAAE,MAAM;IACxC,CAAC;IACD,IAAI,IAAI,KAAK,OAAO,CAAC,MAAM;QAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;IACzF,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjH,CAAC"}
|
package/dist/src/gate/types.d.ts
CHANGED
|
@@ -165,6 +165,79 @@ export interface GatePolicy {
|
|
|
165
165
|
* fire" has no meaning distinct from the behavior itself.
|
|
166
166
|
*/
|
|
167
167
|
passthrough?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Suppression: an event this rule takes is stored in the chronicle and
|
|
170
|
+
* never rendered into the residents' context. It isn't compiled, injected
|
|
171
|
+
* at a tool boundary, folded into memory, woken for, or counted as the
|
|
172
|
+
* latest inbound. The framework decides this once, as the event arrives
|
|
173
|
+
* (`EventGate.decideSuppression`), and stamps the row
|
|
174
|
+
* (`metadata.suppressed = { rule, eventType }`). The view filters read only
|
|
175
|
+
* that stamp, so changing the rule later never changes what was already
|
|
176
|
+
* rendered or hidden: a removed rule stops suppressing from then on, and
|
|
177
|
+
* the rows it hid stay hidden.
|
|
178
|
+
*
|
|
179
|
+
* The rule needs `behavior: "defer"` (or the legacy `"skip"`), so a release
|
|
180
|
+
* that doesn't know `suppress` defers its events instead of waking the
|
|
181
|
+
* agent on them, and a match that narrows something. Rules stay
|
|
182
|
+
* first-match, with three exceptions: an event addressed to the agent
|
|
183
|
+
* (`chat:addressed`), a heartbeat, and console or API input are never
|
|
184
|
+
* suppressed. The rule lets them by, and the rules after it decide them.
|
|
185
|
+
* A suppress rule decides no wake for an event suppression was asked about
|
|
186
|
+
* (`evaluate` and `probe` pass over it there, `GateEventInfo.suppressionAsked`);
|
|
187
|
+
* where suppression wasn't asked, it defers, as its behavior says.
|
|
188
|
+
*/
|
|
189
|
+
suppress?: SuppressConfig;
|
|
190
|
+
}
|
|
191
|
+
/** A suppress rule's own settings (GatePolicy.suppress). */
|
|
192
|
+
export interface SuppressConfig {
|
|
193
|
+
/**
|
|
194
|
+
* What the rule is for, in the agent's words ("the eye going on and off").
|
|
195
|
+
* Required: the periodic review (SuppressionReviewOptions), where the host
|
|
196
|
+
* runs it, checks a sample of the events the rule hid against it.
|
|
197
|
+
*/
|
|
198
|
+
description: string;
|
|
199
|
+
/**
|
|
200
|
+
* The agent's own logic for the rule, when matching isn't enough: the
|
|
201
|
+
* source of a function `(event, state) => boolean`, called for each event
|
|
202
|
+
* the rule's match takes that reaches it (one an earlier rule decides, an
|
|
203
|
+
* addressed one, or the heartbeat's never does), only `true` hiding it. `event` is the event's type,
|
|
204
|
+
* source, channel, author, tags, text, arrival time (`at`, ms) and
|
|
205
|
+
* metadata. `state` is the rule's own JSON object, which the script reads
|
|
206
|
+
* and changes as it likes, kept between events and across restarts
|
|
207
|
+
* (suppress-scripts.ts), and started afresh when the script changes or the
|
|
208
|
+
* rule is removed. So a rule can hide repeats, count, or keep a window of
|
|
209
|
+
* its own. A script that throws or runs past its time counts as saying
|
|
210
|
+
* show: the event goes on to the rules after it. Left out, every event the
|
|
211
|
+
* rule matches is hidden.
|
|
212
|
+
*/
|
|
213
|
+
script?: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The periodic review of what suppress rules hid (src/gate/suppression-review.ts):
|
|
217
|
+
* every `intervalMs`, for each rule that hid events since the last review, a
|
|
218
|
+
* small model reads the rule's description and the events it hid (a sample,
|
|
219
|
+
* past `maxEventsPerRule`) and flags any that don't fit the description or
|
|
220
|
+
* that the agent would plausibly need to see. The agent is told what each
|
|
221
|
+
* rule hid and what was flagged, in a `[suppression review]` notice; a
|
|
222
|
+
* flagged event wakes it.
|
|
223
|
+
*/
|
|
224
|
+
export interface SuppressionReviewOptions {
|
|
225
|
+
/** False turns the review off. Default true. */
|
|
226
|
+
enabled?: boolean;
|
|
227
|
+
/** How often, in ms. Default 2 hours; at least 10 minutes. */
|
|
228
|
+
intervalMs?: number;
|
|
229
|
+
/** The reviewer's model, as the host's membrane names it. Default `claude-haiku-5-5`. */
|
|
230
|
+
model?: string;
|
|
231
|
+
/** When the agent is told: after every review in which a rule hid something (`"always"`, the default), or only when an event was flagged (`"flagged"`). */
|
|
232
|
+
notify?: 'always' | 'flagged';
|
|
233
|
+
/** Whether a flagged event wakes the agent, which is a full turn of its own model, so a false flag costs that turn. Default true. */
|
|
234
|
+
wakeOnFlag?: boolean;
|
|
235
|
+
/** The most events of one rule the reviewer reads in one review, spread across the period. Default 60. */
|
|
236
|
+
maxEventsPerRule?: number;
|
|
237
|
+
/** How long one rule's review may take, in ms. Default 60,000. */
|
|
238
|
+
timeoutMs?: number;
|
|
239
|
+
/** The reviewer's effort (`output_config.effort`); `"none"` sends none. Default `"low"`. */
|
|
240
|
+
effort?: 'low' | 'medium' | 'high' | 'none';
|
|
168
241
|
}
|
|
169
242
|
/** Top-level gate configuration, stored in gate.json. */
|
|
170
243
|
export interface GateConfig {
|
|
@@ -199,6 +272,21 @@ export interface GateOptions {
|
|
|
199
272
|
* null), the judge is wired with its defaults; it runs only for `judge`
|
|
200
273
|
* rules, so a gate with none makes no judge calls. */
|
|
201
274
|
judge?: ReplyJudgeOptions | null;
|
|
275
|
+
/**
|
|
276
|
+
* The periodic review of what suppress rules hid (SuppressionReviewOptions).
|
|
277
|
+
* On by default wherever a gate is; false turns it off.
|
|
278
|
+
*/
|
|
279
|
+
suppressionReview?: SuppressionReviewOptions | false;
|
|
280
|
+
/** How long a suppress rule's script may take for one event before the event is shown (ms). Default 50. */
|
|
281
|
+
suppressScriptTimeoutMs?: number;
|
|
282
|
+
/**
|
|
283
|
+
* Wake onboarding (gate/wake-onboarding.ts): the first event from an MCPL
|
|
284
|
+
* server that the agent's rules let go by without deciding about it brings
|
|
285
|
+
* the agent that server's suggested treatment (MCPL RFC-001 §5), once per
|
|
286
|
+
* declared ontology, with `wake_accept_suggestions` / `wake_decline` to
|
|
287
|
+
* answer. On unless set to false.
|
|
288
|
+
*/
|
|
289
|
+
onboarding?: boolean;
|
|
202
290
|
}
|
|
203
291
|
/**
|
|
204
292
|
* Host options for the reply judge, the small model `judge` rules ask whether
|
|
@@ -253,6 +341,8 @@ export interface JudgeEventSummary {
|
|
|
253
341
|
/** When the event arrived (ms). */
|
|
254
342
|
at: number;
|
|
255
343
|
}
|
|
344
|
+
/** The kinds of UpcomingWake. */
|
|
345
|
+
export type UpcomingWakeKind = 'heartbeat' | 'reminder' | 'self-wake' | 'sleep-end' | 'debounce' | 'judge-batch' | 'queued' | 'provider-hold';
|
|
256
346
|
/**
|
|
257
347
|
* Something that will (or, for a batch going to the judge, may) wake the
|
|
258
348
|
* agent with no new event: what the judge is told would happen if it answers
|
|
@@ -265,6 +355,9 @@ export interface UpcomingWake {
|
|
|
265
355
|
certain: boolean;
|
|
266
356
|
/** What it is, as the judge is told ("its own skip_reply timer"). */
|
|
267
357
|
what: string;
|
|
358
|
+
/** What it is, in a word that quotes nothing, for healthSnapshot: `what` can
|
|
359
|
+
* quote a reminder or a queue reason. The judge isn't told it. */
|
|
360
|
+
kind?: UpcomingWakeKind;
|
|
268
361
|
}
|
|
269
362
|
/** What the gate asks the reply judge for one batch. */
|
|
270
363
|
export interface JudgeRequest {
|
|
@@ -365,6 +458,27 @@ export interface GateEventInfo {
|
|
|
365
458
|
paths?: string[];
|
|
366
459
|
/** Event tags (MCPL RFC-001), already implication-expanded by the host. */
|
|
367
460
|
tags?: string[];
|
|
461
|
+
/** The agents admission delivered a targeted event to (its targetAgents).
|
|
462
|
+
* A debounced batch wakes each agent with the events it may see, those
|
|
463
|
+
* naming it and those naming no agent, and agents that may see the same
|
|
464
|
+
* events share one line. Absent for an untargeted event, whose batch wakes
|
|
465
|
+
* every agent getAgentNames lists. */
|
|
466
|
+
recipients?: readonly string[];
|
|
467
|
+
/**
|
|
468
|
+
* Set when the framework asked whether the event is suppressed before it
|
|
469
|
+
* asked about its wake (decideSuppression), so a suppress rule that
|
|
470
|
+
* matches it let it by. Left out, a suppress rule defers the events it
|
|
471
|
+
* matches, as its behavior says: suppression wasn't asked, as for an event
|
|
472
|
+
* that lands where no view hides suppressed rows.
|
|
473
|
+
*/
|
|
474
|
+
suppressionAsked?: boolean;
|
|
475
|
+
/**
|
|
476
|
+
* A coalesced render, which folds its batch's every occurrence while its
|
|
477
|
+
* `tags` are the latest's (MCPL RFC-006): never taken as a `chat:system`
|
|
478
|
+
* notice, as the render's own wake isn't, so a message it folds keeps
|
|
479
|
+
* its channel when a notice came last.
|
|
480
|
+
*/
|
|
481
|
+
folds?: true;
|
|
368
482
|
}
|
|
369
483
|
/** An MCPL event whose content the framework stored at arrival, as a
|
|
370
484
|
* batched wake names it to the framework (EventGate's `isNewestEntry`):
|
|
@@ -381,13 +495,13 @@ export interface GateEntryRef {
|
|
|
381
495
|
* than wrote: its batch was one event whose entry was still the newest in
|
|
382
496
|
* the window when the batch fired (EventGate's `isNewestEntry`). A fresh
|
|
383
497
|
* start of the wake's turn decides it (the framework's placeWakeLines): the
|
|
384
|
-
* delivery agent's
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
* later fresh start of the same wake. Its text
|
|
390
|
-
* written (wakeLineText), so its age is true then.
|
|
498
|
+
* delivery agent's start, and on a presented window each resident's own
|
|
499
|
+
* start, decides its own line, leaving it out while that entry is still
|
|
500
|
+
* the newest in its window and writing it once something follows; a
|
|
501
|
+
* co-resident whose window isn't presented places none; two or more such
|
|
502
|
+
* lines are each written; and none is written while the host is quiesced.
|
|
503
|
+
* A line left out stays for a later fresh start of the same wake. Its text
|
|
504
|
+
* is rendered when it's written (wakeLineText), so its age is true then.
|
|
391
505
|
*
|
|
392
506
|
* Every request for one wake carries the same object: the framework writes
|
|
393
507
|
* each line once by its identity, across the wake's retries and holds. A
|
|
@@ -411,6 +525,17 @@ export interface GatePolicyStats {
|
|
|
411
525
|
behavior: GateBehavior;
|
|
412
526
|
matchCount: number;
|
|
413
527
|
lastMatchTimestamp: number | null;
|
|
528
|
+
/**
|
|
529
|
+
* Present on a suppress rule: its settings, and with a script, how the
|
|
530
|
+
* script has run since this process started. Its `matchCount` and
|
|
531
|
+
* `lastMatchTimestamp` count the events it took since then: those it
|
|
532
|
+
* suppressed, and those it only deferred where suppression wasn't asked
|
|
533
|
+
* (a channel under conversation routing). `suppression_stats` reads the
|
|
534
|
+
* stamped rows themselves, so its counts cover every start.
|
|
535
|
+
*/
|
|
536
|
+
suppress?: SuppressConfig & {
|
|
537
|
+
scriptStatus?: import('./suppress-scripts.js').SuppressScriptStatus;
|
|
538
|
+
};
|
|
414
539
|
debounceState?: {
|
|
415
540
|
pendingCount: number;
|
|
416
541
|
nextDeliveryMs: number | null;
|
|
@@ -466,6 +591,16 @@ export interface GateStatus {
|
|
|
466
591
|
* same hazards wake_add_rule warns about at install time.
|
|
467
592
|
*/
|
|
468
593
|
shadowWarnings: string[];
|
|
594
|
+
/**
|
|
595
|
+
* The first rule that takes MCPL servers' events without naming a server, a
|
|
596
|
+
* channel or a tag (gate/wake-onboarding.ts placementFor): every server
|
|
597
|
+
* connected later is handled by it until a rule for that server goes ahead of
|
|
598
|
+
* it. Absent when there is none.
|
|
599
|
+
*/
|
|
600
|
+
catchAll?: {
|
|
601
|
+
rule: string;
|
|
602
|
+
note: string;
|
|
603
|
+
};
|
|
469
604
|
/** Total events the gate has evaluated since startup. */
|
|
470
605
|
totalEvaluations: number;
|
|
471
606
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/gate/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd;yCACqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW;IAC1B,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,0DAA0D;AAC1D,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,OAAO,GACP,MAAM,GACN;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GACpB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AAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACrE,CAAC;IACF,+DAA+D;IAC/D,KAAK,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,0EAA0E;QAC1E,UAAU,EAAE,MAAM,CAAC;QACnB,gEAAgE;QAChE,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { GateBehavior, GateDecision, GatePolicy } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Tags that say an event is addressed to the agent or waiting on it (MCPL
|
|
4
|
+
* RFC-001 `chat:addressed`, RFC-014 `surface:turn`/`surface:alert`; not
|
|
5
|
+
* `surface:invite`, which only suggests). The first undecided event carrying
|
|
6
|
+
* one wakes the agent to decide; any other undecided event leaves its offer
|
|
7
|
+
* for the agent's next turn.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ATTENTION_TAGS: readonly string[];
|
|
10
|
+
/** Accepted rules are named `suggested:<server>:<n>`: the name is the attribution. */
|
|
11
|
+
export declare const SUGGESTED_RULE_PREFIX = "suggested:";
|
|
12
|
+
export declare const suggestedRuleName: (server: string, n: number) => string;
|
|
13
|
+
/** Exactly `suggested:<server>:<n>`: a server id that another extends (`games`, `games:beta`) never claims the other's rules. */
|
|
14
|
+
export declare const isSuggestedRuleOf: (name: string, server: string) => boolean;
|
|
15
|
+
/** One of a server's suggestions as the host offers it: the server's words and the rule it becomes. */
|
|
16
|
+
export interface OfferedRule {
|
|
17
|
+
/** 1-based: the number `wake_accept_suggestions` takes it by. */
|
|
18
|
+
n: number;
|
|
19
|
+
/** The feature set that declared it; empty for the host's own fallback. */
|
|
20
|
+
featureSet: string;
|
|
21
|
+
match: {
|
|
22
|
+
tagsAny?: string[];
|
|
23
|
+
tagsAll?: string[];
|
|
24
|
+
tagsNone?: string[];
|
|
25
|
+
};
|
|
26
|
+
/** The gate behavior the suggestion becomes. */
|
|
27
|
+
behavior: GateBehavior;
|
|
28
|
+
/** The server's own word for it (`immediate`, `{ debounce: 60000 }`, …). */
|
|
29
|
+
said: unknown;
|
|
30
|
+
/** The server's account of what the rule is for and what declining costs. */
|
|
31
|
+
rationale?: string;
|
|
32
|
+
/** The host wrote it: the server suggested nothing it could use. */
|
|
33
|
+
fallback?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ServerOffer {
|
|
36
|
+
server: string;
|
|
37
|
+
/** What the decision is about: a digest of the server's declared ontologies ('none' without one). */
|
|
38
|
+
digest: string;
|
|
39
|
+
rules: OfferedRule[];
|
|
40
|
+
/** Descriptions the server gave of the tags its rules name. */
|
|
41
|
+
tagDescriptions: Record<string, string>;
|
|
42
|
+
/** Suggestions in the declaration the host could not translate, as given. */
|
|
43
|
+
untranslated: unknown[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A suggested behavior (RFC-001 §6's vocabulary, or the gate's own names) as a
|
|
47
|
+
* gate behavior; null for one with no faithful translation.
|
|
48
|
+
*/
|
|
49
|
+
export declare function translateBehavior(said: unknown): GateBehavior | null;
|
|
50
|
+
/**
|
|
51
|
+
* A server's suggestions from its declared feature sets (null: none declared).
|
|
52
|
+
* Feature sets in name order; in each, its ordered rules as declared, then
|
|
53
|
+
* per-tag suggestions no ordered rule already makes, by tag. A server that suggests nothing the host can
|
|
54
|
+
* use gets one host-written rule: wake for its events tagged as addressed to
|
|
55
|
+
* the agent or waiting on it, nothing else.
|
|
56
|
+
*/
|
|
57
|
+
export declare function offerFor(server: string, declared: Record<string, {
|
|
58
|
+
tagOntology?: unknown;
|
|
59
|
+
}> | null): ServerOffer;
|
|
60
|
+
export { ruleDecides } from './rule-scope.js';
|
|
61
|
+
/**
|
|
62
|
+
* Whether the gate let an event go by without anyone having decided to: it did
|
|
63
|
+
* not wake and will not (`defer`/`skip`), by the default or by a rule that
|
|
64
|
+
* doesn't decide about it (ruleDecides). `policy` is the matched rule, as in
|
|
65
|
+
* force; undefined when the decision named none or it can't be found.
|
|
66
|
+
*/
|
|
67
|
+
export declare function isUndecided(decision: GateDecision, policy: GatePolicy | undefined): boolean;
|
|
68
|
+
export declare const carriesAttention: (tags: readonly string[] | undefined) => boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Where an accepted rule goes: ahead of the first rule that would let the
|
|
71
|
+
* server's events by without deciding about them (a catch-all that defers or
|
|
72
|
+
* skips), so the rules the agent wrote for this server, or for a channel or
|
|
73
|
+
* tags, keep their place before it, and so do catch-alls that wake (a mention
|
|
74
|
+
* rule on metadata): a muted suggestion can't swallow an explicit mention.
|
|
75
|
+
* Null: there is none; the rule goes last, ahead of the default. (Accepted
|
|
76
|
+
* rules name their source, so they are never the catch-all.)
|
|
77
|
+
*/
|
|
78
|
+
export declare const placementFor: (policies: readonly GatePolicy[]) => string | null;
|
|
79
|
+
/** The gate rules accepting `rules` of `offer` writes. */
|
|
80
|
+
export declare function rulesToWrite(offer: ServerOffer, accepted: readonly OfferedRule[]): GatePolicy[];
|
|
81
|
+
/** The least time between two offers for one server (WakeDecisions.mayOffer). */
|
|
82
|
+
export declare const OFFER_FLOOR_MS: number;
|
|
83
|
+
export type DecisionState = 'offered' | 'accepted' | 'declined';
|
|
84
|
+
export interface DecisionRecord {
|
|
85
|
+
digest: string;
|
|
86
|
+
state: DecisionState;
|
|
87
|
+
/** The rule names an acceptance wrote (kept while a newer ontology is being asked about). */
|
|
88
|
+
rules?: string[];
|
|
89
|
+
/** The digest whose numbered list the agent was last shown, when newer than `digest` (a drift refusal re-showed it). */
|
|
90
|
+
shown?: string;
|
|
91
|
+
at: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The agent's decisions per server, beside gate.json (`wake-decisions.json`).
|
|
95
|
+
* Written whole, through a temporary file; one that can't be read is set aside
|
|
96
|
+
* and starts empty, so a damaged file costs a repeated offer, never a crash.
|
|
97
|
+
*/
|
|
98
|
+
export declare class WakeDecisions {
|
|
99
|
+
private readonly path;
|
|
100
|
+
private readonly log;
|
|
101
|
+
private records;
|
|
102
|
+
constructor(path: string, log?: (message: string) => void);
|
|
103
|
+
get(server: string): DecisionRecord | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Whether an offer for `server` may go out now: never twice for the same
|
|
106
|
+
* digest, answered or not, and not within OFFER_FLOOR_MS of the server's
|
|
107
|
+
* last offer or decision even when its ontology changed — a server can't
|
|
108
|
+
* buy itself a stream of questions by editing what it declares.
|
|
109
|
+
*/
|
|
110
|
+
/** Whether an offer for `server` could go out at all, before its digest is known: not within the floor of the last one. */
|
|
111
|
+
mayOfferSoon(server: string, now?: number): boolean;
|
|
112
|
+
mayOffer(server: string, digest: string, now?: number): boolean;
|
|
113
|
+
set(server: string, record: Omit<DecisionRecord, 'at'>, now?: number): DecisionRecord;
|
|
114
|
+
/** Record that the agent was shown `digest`'s list, leaving the decision and its time as they are (the floor doesn't restart). */
|
|
115
|
+
markShown(server: string, digest: string): void;
|
|
116
|
+
all(): Readonly<Record<string, DecisionRecord>>;
|
|
117
|
+
private write;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=wake-onboarding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wake-onboarding.d.ts","sourceRoot":"","sources":["../../../src/gate/wake-onboarding.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAAwD,CAAC;AAErG,sFAAsF;AACtF,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,iBAAiB,WAAY,MAAM,KAAK,MAAM,KAAG,MAAkD,CA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