@animalabs/agent-framework 0.26.2 → 0.28.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 +99 -8
- package/dist/src/agent.d.ts +291 -23
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +596 -61
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +5 -4
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/auto-continue.d.ts +34 -0
- package/dist/src/auto-continue.d.ts.map +1 -0
- package/dist/src/auto-continue.js +36 -0
- package/dist/src/auto-continue.js.map +1 -0
- package/dist/src/code-execution/isolate/scripts.d.ts +11 -0
- package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/scripts.js +5 -1
- package/dist/src/code-execution/isolate/scripts.js.map +1 -1
- package/dist/src/cut-off-round.d.ts +24 -0
- package/dist/src/cut-off-round.d.ts.map +1 -0
- package/dist/src/cut-off-round.js +87 -0
- package/dist/src/cut-off-round.js.map +1 -0
- package/dist/src/framework.d.ts +1038 -193
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +5967 -1514
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +405 -46
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +2646 -399
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/gate/index.d.ts +3 -2
- package/dist/src/gate/index.d.ts.map +1 -1
- package/dist/src/gate/index.js +2 -1
- package/dist/src/gate/index.js.map +1 -1
- package/dist/src/gate/recipe-reconcile.d.ts +103 -0
- package/dist/src/gate/recipe-reconcile.d.ts.map +1 -0
- package/dist/src/gate/recipe-reconcile.js +325 -0
- package/dist/src/gate/recipe-reconcile.js.map +1 -0
- package/dist/src/gate/reply-judge.d.ts +116 -0
- package/dist/src/gate/reply-judge.d.ts.map +1 -0
- package/dist/src/gate/reply-judge.js +467 -0
- package/dist/src/gate/reply-judge.js.map +1 -0
- package/dist/src/gate/types.d.ts +229 -8
- package/dist/src/gate/types.d.ts.map +1 -1
- package/dist/src/heartbeat/heartbeat.d.ts +184 -0
- package/dist/src/heartbeat/heartbeat.d.ts.map +1 -0
- package/dist/src/heartbeat/heartbeat.js +752 -0
- package/dist/src/heartbeat/heartbeat.js.map +1 -0
- package/dist/src/heartbeat/reminder-time.d.ts +5 -0
- package/dist/src/heartbeat/reminder-time.d.ts.map +1 -0
- package/dist/src/heartbeat/reminder-time.js +107 -0
- package/dist/src/heartbeat/reminder-time.js.map +1 -0
- package/dist/src/index.d.ts +10 -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/mcpl/capability-mask.d.ts.map +1 -1
- package/dist/src/mcpl/capability-mask.js +3 -2
- package/dist/src/mcpl/capability-mask.js.map +1 -1
- package/dist/src/mcpl/channel-registry.d.ts +433 -113
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +1154 -435
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/conversation-router.d.ts +16 -8
- package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
- package/dist/src/mcpl/conversation-router.js +29 -15
- package/dist/src/mcpl/conversation-router.js.map +1 -1
- package/dist/src/mcpl/convert-block.d.ts.map +1 -1
- package/dist/src/mcpl/convert-block.js +14 -2
- package/dist/src/mcpl/convert-block.js.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts +7 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.js +32 -7
- package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
- package/dist/src/mcpl/inbound-source.d.ts +26 -10
- package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
- package/dist/src/mcpl/inbound-source.js +40 -69
- package/dist/src/mcpl/inbound-source.js.map +1 -1
- package/dist/src/mcpl/index.d.ts +5 -1
- package/dist/src/mcpl/index.d.ts.map +1 -1
- package/dist/src/mcpl/index.js +4 -0
- package/dist/src/mcpl/index.js.map +1 -1
- package/dist/src/mcpl/inference-router.d.ts +14 -2
- package/dist/src/mcpl/inference-router.d.ts.map +1 -1
- package/dist/src/mcpl/inference-router.js +73 -28
- package/dist/src/mcpl/inference-router.js.map +1 -1
- package/dist/src/mcpl/prose-grammar.d.ts +4 -0
- package/dist/src/mcpl/prose-grammar.d.ts.map +1 -1
- package/dist/src/mcpl/prose-grammar.js +6 -0
- package/dist/src/mcpl/prose-grammar.js.map +1 -1
- package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
- package/dist/src/mcpl/protocol-family.js +3 -0
- package/dist/src/mcpl/protocol-family.js.map +1 -1
- package/dist/src/mcpl/push-coalescer.d.ts +20 -2
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +33 -11
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/reference-fetcher.d.ts +63 -42
- package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
- package/dist/src/mcpl/reference-fetcher.js +177 -145
- package/dist/src/mcpl/reference-fetcher.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +380 -46
- package/dist/src/mcpl/references.d.ts.map +1 -1
- package/dist/src/mcpl/references.js +736 -77
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +93 -4
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +176 -11
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/tags.d.ts +9 -2
- package/dist/src/mcpl/tags.d.ts.map +1 -1
- package/dist/src/mcpl/tags.js +12 -2
- package/dist/src/mcpl/tags.js.map +1 -1
- package/dist/src/mcpl/tool-lifecycle.d.ts +11 -0
- package/dist/src/mcpl/tool-lifecycle.d.ts.map +1 -1
- package/dist/src/mcpl/tool-lifecycle.js +21 -0
- package/dist/src/mcpl/tool-lifecycle.js.map +1 -1
- package/dist/src/mcpl/tool-presence.d.ts +311 -0
- package/dist/src/mcpl/tool-presence.d.ts.map +1 -0
- package/dist/src/mcpl/tool-presence.js +697 -0
- package/dist/src/mcpl/tool-presence.js.map +1 -0
- package/dist/src/mcpl/tool-result-normalize.d.ts +9 -3
- package/dist/src/mcpl/tool-result-normalize.d.ts.map +1 -1
- package/dist/src/mcpl/tool-result-normalize.js +14 -6
- package/dist/src/mcpl/tool-result-normalize.js.map +1 -1
- package/dist/src/mcpl/tool-signature.d.ts +46 -0
- package/dist/src/mcpl/tool-signature.d.ts.map +1 -0
- package/dist/src/mcpl/tool-signature.js +321 -0
- package/dist/src/mcpl/tool-signature.js.map +1 -0
- package/dist/src/mcpl/toolset-host.d.ts +251 -0
- package/dist/src/mcpl/toolset-host.d.ts.map +1 -0
- package/dist/src/mcpl/toolset-host.js +720 -0
- package/dist/src/mcpl/toolset-host.js.map +1 -0
- package/dist/src/mcpl/toolsets-module.d.ts +83 -0
- package/dist/src/mcpl/toolsets-module.d.ts.map +1 -0
- package/dist/src/mcpl/toolsets-module.js +523 -0
- package/dist/src/mcpl/toolsets-module.js.map +1 -0
- package/dist/src/mcpl/transport.d.ts +2 -2
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +3 -2
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +24 -2
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/mcpl/visible-content.d.ts +7 -9
- package/dist/src/mcpl/visible-content.d.ts.map +1 -1
- package/dist/src/mcpl/visible-content.js +21 -9
- package/dist/src/mcpl/visible-content.js.map +1 -1
- package/dist/src/module-registry.d.ts +27 -9
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +77 -17
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/discord/index.js +1 -1
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/history/index.d.ts +2 -1
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +73 -28
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/history/semantic.d.ts +108 -6
- package/dist/src/modules/history/semantic.d.ts.map +1 -1
- package/dist/src/modules/history/semantic.js +273 -57
- package/dist/src/modules/history/semantic.js.map +1 -1
- package/dist/src/modules/workspace/answers.d.ts +22 -0
- package/dist/src/modules/workspace/answers.d.ts.map +1 -0
- package/dist/src/modules/workspace/answers.js +123 -0
- package/dist/src/modules/workspace/answers.js.map +1 -0
- package/dist/src/modules/workspace/branch-intent.d.ts +5 -3
- package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -1
- package/dist/src/modules/workspace/branch-intent.js +6 -2
- package/dist/src/modules/workspace/branch-intent.js.map +1 -1
- package/dist/src/modules/workspace/direct-write.d.ts +184 -0
- package/dist/src/modules/workspace/direct-write.d.ts.map +1 -0
- package/dist/src/modules/workspace/direct-write.js +417 -0
- package/dist/src/modules/workspace/direct-write.js.map +1 -0
- package/dist/src/modules/workspace/disk-agreement.d.ts +33 -11
- package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.js +48 -17
- package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
- package/dist/src/modules/workspace/edit-text.d.ts +27 -12
- package/dist/src/modules/workspace/edit-text.d.ts.map +1 -1
- package/dist/src/modules/workspace/edit-text.js +61 -29
- package/dist/src/modules/workspace/edit-text.js.map +1 -1
- package/dist/src/modules/workspace/effects.d.ts +10 -0
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/effects.js +21 -14
- package/dist/src/modules/workspace/effects.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +308 -78
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +2103 -720
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +75 -63
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +366 -180
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/read-page.d.ts +41 -0
- package/dist/src/modules/workspace/read-page.d.ts.map +1 -0
- package/dist/src/modules/workspace/read-page.js +219 -0
- package/dist/src/modules/workspace/read-page.js.map +1 -0
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +26 -16
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/modules/workspace/result-text.d.ts +68 -0
- package/dist/src/modules/workspace/result-text.d.ts.map +1 -0
- package/dist/src/modules/workspace/result-text.js +94 -0
- package/dist/src/modules/workspace/result-text.js.map +1 -0
- package/dist/src/modules/workspace/sync.d.ts +9 -0
- package/dist/src/modules/workspace/sync.d.ts.map +1 -1
- package/dist/src/modules/workspace/sync.js +14 -0
- package/dist/src/modules/workspace/sync.js.map +1 -1
- package/dist/src/modules/workspace/text.d.ts +29 -12
- package/dist/src/modules/workspace/text.d.ts.map +1 -1
- package/dist/src/modules/workspace/text.js +35 -33
- package/dist/src/modules/workspace/text.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +137 -60
- package/dist/src/modules/workspace/types.d.ts.map +1 -1
- package/dist/src/modules/workspace/types.js.map +1 -1
- package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
- package/dist/src/modules/workspace/watcher.js +8 -3
- package/dist/src/modules/workspace/watcher.js.map +1 -1
- package/dist/src/prose-drafts.d.ts +4 -3
- package/dist/src/prose-drafts.d.ts.map +1 -1
- package/dist/src/prose-drafts.js +3 -2
- package/dist/src/prose-drafts.js.map +1 -1
- package/dist/src/reasoning-loss-notice.d.ts +23 -0
- package/dist/src/reasoning-loss-notice.d.ts.map +1 -0
- package/dist/src/reasoning-loss-notice.js +50 -0
- package/dist/src/reasoning-loss-notice.js.map +1 -0
- package/dist/src/reasoning-loss.d.ts +24 -0
- package/dist/src/reasoning-loss.d.ts.map +1 -0
- package/dist/src/reasoning-loss.js +102 -0
- package/dist/src/reasoning-loss.js.map +1 -0
- package/dist/src/send-tools.d.ts +3 -2
- package/dist/src/send-tools.d.ts.map +1 -1
- package/dist/src/send-tools.js +3 -2
- package/dist/src/send-tools.js.map +1 -1
- package/dist/src/sent-rows.d.ts +59 -0
- package/dist/src/sent-rows.d.ts.map +1 -0
- package/dist/src/sent-rows.js +145 -0
- package/dist/src/sent-rows.js.map +1 -0
- package/dist/src/silent-heartbeat.d.ts +17 -10
- package/dist/src/silent-heartbeat.d.ts.map +1 -1
- package/dist/src/silent-heartbeat.js.map +1 -1
- package/dist/src/stable-hash.d.ts +3 -0
- package/dist/src/stable-hash.d.ts.map +1 -0
- package/dist/src/stable-hash.js +15 -0
- package/dist/src/stable-hash.js.map +1 -0
- package/dist/src/stored-injections.d.ts +99 -0
- package/dist/src/stored-injections.d.ts.map +1 -0
- package/dist/src/stored-injections.js +106 -0
- package/dist/src/stored-injections.js.map +1 -0
- package/dist/src/text-as-stored.d.ts +4 -3
- package/dist/src/text-as-stored.d.ts.map +1 -1
- package/dist/src/text-as-stored.js +4 -3
- package/dist/src/text-as-stored.js.map +1 -1
- package/dist/src/thinking-drops.d.ts +74 -0
- package/dist/src/thinking-drops.d.ts.map +1 -0
- package/dist/src/thinking-drops.js +96 -0
- package/dist/src/thinking-drops.js.map +1 -0
- package/dist/src/tool-args.d.ts +12 -0
- package/dist/src/tool-args.d.ts.map +1 -1
- package/dist/src/tool-args.js +35 -1
- package/dist/src/tool-args.js.map +1 -1
- package/dist/src/tool-image-ledger.d.ts +9 -8
- package/dist/src/tool-image-ledger.d.ts.map +1 -1
- package/dist/src/tool-image-ledger.js +9 -8
- 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 +3 -1
- package/dist/src/tool-presentation.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts +12 -6
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +44 -17
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tool-result-history.d.ts +176 -24
- package/dist/src/tool-result-history.d.ts.map +1 -1
- package/dist/src/tool-result-history.js +411 -91
- package/dist/src/tool-result-history.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +17 -9
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +84 -37
- package/dist/src/tune-out/coordinator.js.map +1 -1
- package/dist/src/tune-out/tools.d.ts +4 -1
- package/dist/src/tune-out/tools.d.ts.map +1 -1
- package/dist/src/types/agent.d.ts +217 -7
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +33 -9
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +39 -3
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +95 -9
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +91 -3
- package/dist/src/types/trace.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/agent.ts +661 -67
- package/src/api/server.ts +5 -4
- package/src/auto-continue.ts +43 -0
- package/src/code-execution/isolate/scripts.ts +11 -3
- package/src/cut-off-round.ts +98 -0
- package/src/framework.ts +6168 -1540
- package/src/gate/event-gate.ts +2895 -405
- package/src/gate/index.ts +10 -1
- package/src/gate/recipe-reconcile.ts +355 -0
- package/src/gate/reply-judge.ts +512 -0
- package/src/gate/types.ts +234 -9
- package/src/heartbeat/heartbeat.ts +804 -0
- package/src/heartbeat/reminder-time.ts +107 -0
- package/src/index.ts +11 -4
- package/src/mcpl/capability-mask.ts +3 -2
- package/src/mcpl/channel-registry.ts +1222 -468
- package/src/mcpl/conversation-router.ts +34 -16
- package/src/mcpl/convert-block.ts +14 -1
- package/src/mcpl/hook-orchestrator.ts +33 -6
- package/src/mcpl/inbound-source.ts +42 -69
- package/src/mcpl/index.ts +6 -1
- package/src/mcpl/inference-router.ts +79 -34
- package/src/mcpl/prose-grammar.ts +7 -0
- package/src/mcpl/protocol-family.ts +2 -0
- package/src/mcpl/push-coalescer.ts +51 -13
- package/src/mcpl/reference-fetcher.ts +201 -162
- package/src/mcpl/references.ts +851 -77
- package/src/mcpl/server-connection.ts +189 -11
- package/src/mcpl/tags.ts +13 -2
- package/src/mcpl/tool-lifecycle.ts +21 -0
- package/src/mcpl/tool-presence.ts +716 -0
- package/src/mcpl/tool-result-normalize.ts +18 -6
- package/src/mcpl/tool-signature.ts +316 -0
- package/src/mcpl/toolset-host.ts +727 -0
- package/src/mcpl/toolsets-module.ts +545 -0
- package/src/mcpl/transport.ts +3 -2
- package/src/mcpl/types.ts +25 -2
- package/src/mcpl/visible-content.ts +22 -9
- package/src/module-registry.ts +85 -26
- package/src/modules/discord/index.ts +1 -1
- package/src/modules/history/index.ts +70 -30
- package/src/modules/history/semantic.ts +308 -54
- package/src/modules/workspace/answers.ts +133 -0
- package/src/modules/workspace/branch-intent.ts +10 -5
- package/src/modules/workspace/direct-write.ts +460 -0
- package/src/modules/workspace/disk-agreement.ts +52 -21
- package/src/modules/workspace/edit-text.ts +84 -35
- package/src/modules/workspace/effects.ts +22 -13
- package/src/modules/workspace/index.ts +2142 -723
- package/src/modules/workspace/observe.ts +381 -177
- package/src/modules/workspace/read-page.ts +228 -0
- package/src/modules/workspace/reconcile.ts +27 -15
- package/src/modules/workspace/result-text.ts +121 -0
- package/src/modules/workspace/sync.ts +16 -0
- package/src/modules/workspace/text.ts +58 -32
- package/src/modules/workspace/types.ts +137 -60
- package/src/modules/workspace/watcher.ts +8 -3
- package/src/prose-drafts.ts +4 -3
- package/src/reasoning-loss-notice.ts +62 -0
- package/src/reasoning-loss.ts +120 -0
- package/src/send-tools.ts +3 -2
- package/src/sent-rows.ts +162 -0
- package/src/silent-heartbeat.ts +17 -10
- package/src/stable-hash.ts +14 -0
- package/src/stored-injections.ts +131 -0
- package/src/text-as-stored.ts +4 -3
- package/src/thinking-drops.ts +135 -0
- package/src/tool-args.ts +34 -1
- package/src/tool-image-ledger.ts +9 -8
- package/src/tool-presentation.ts +3 -1
- package/src/tool-result-guard.ts +45 -17
- package/src/tool-result-history.ts +471 -90
- package/src/tune-out/coordinator.ts +80 -37
- package/src/tune-out/tools.ts +4 -1
- package/src/types/agent.ts +220 -7
- package/src/types/events.ts +33 -9
- package/src/types/framework.ts +36 -3
- package/src/types/module.ts +91 -9
- package/src/types/trace.ts +94 -3
package/src/gate/types.ts
CHANGED
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
* bucket are denied (decision: trigger=false). Tokens regenerate at one per
|
|
18
18
|
* `refillIntervalMs`, capped at `tokens`. Buckets are partitioned by the
|
|
19
19
|
* value of `keyBy` resolved against event metadata — so a per-user limit
|
|
20
|
-
* uses `keyBy: "senderId"`, a per-channel limit uses `keyBy: "channelId"
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* uses `keyBy: "senderId"`, a per-channel limit uses `keyBy: "channelId"`
|
|
21
|
+
* (resolved to the channel's registered id, as `keyBy` says), etc. With no
|
|
22
|
+
* `keyBy` (or when the resolved value is missing), one shared bucket is used
|
|
23
|
+
* for the policy.
|
|
23
24
|
*/
|
|
24
25
|
export interface RateLimitConfig {
|
|
25
26
|
/** Max bucket capacity, also the initial fill. Must be > 0. */
|
|
@@ -27,8 +28,12 @@ export interface RateLimitConfig {
|
|
|
27
28
|
/** Milliseconds between token regenerations. Must be > 0. */
|
|
28
29
|
refillIntervalMs: number;
|
|
29
30
|
/**
|
|
30
|
-
* Metadata field name to partition buckets by.
|
|
31
|
-
*
|
|
31
|
+
* Metadata field name to partition buckets by. `"channelId"` takes the
|
|
32
|
+
* channel's registered id where the gate resolves one, as `match.channel`
|
|
33
|
+
* does, so a channel's push events share its messages' bucket, a voice
|
|
34
|
+
* report's included, though it carries no `channelId`. Otherwise, if
|
|
35
|
+
* absent or the metadata field is missing on a given event, all such
|
|
36
|
+
* events share one bucket.
|
|
32
37
|
*/
|
|
33
38
|
keyBy?: string;
|
|
34
39
|
}
|
|
@@ -45,10 +50,44 @@ export interface RateLimitConfig {
|
|
|
45
50
|
export interface PassiveSampleConfig {
|
|
46
51
|
/** Trigger every N-th match. Must be > 0. */
|
|
47
52
|
every: number;
|
|
48
|
-
/** Optional metadata field name for separate per-key counters
|
|
53
|
+
/** Optional metadata field name for separate per-key counters, resolved
|
|
54
|
+
* as `RateLimitConfig.keyBy` is. */
|
|
49
55
|
keyBy?: string;
|
|
50
56
|
}
|
|
51
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Configuration for the `judge` behavior: batch matching events as `debounce`
|
|
60
|
+
* does, then, instead of waking the agent when the batch fires, ask a small,
|
|
61
|
+
* cheap model (the host's reply judge, `GateOptions.judge`) whether now is a
|
|
62
|
+
* good time for the agent to reply. The judge reads the agent's context as one
|
|
63
|
+
* document (its newest part), the agent's own `instructions` and the batch,
|
|
64
|
+
* and answers reply or wait. On reply the
|
|
65
|
+
* batch is delivered as a debounce's is; on wait the agent isn't woken: the
|
|
66
|
+
* events are in its context already, as for `defer`, and the next batch is
|
|
67
|
+
* judged afresh. Rules are read in order, as ever: a mention rule placed ahead
|
|
68
|
+
* of a judge rule wakes the agent without the judge. A judge that fails or
|
|
69
|
+
* times out wakes the agent (fail open),
|
|
70
|
+
* unless the host set its `onError` to `"skip"`.
|
|
71
|
+
*/
|
|
72
|
+
export interface JudgeConfig {
|
|
73
|
+
/** Quiet period (ms) before the batch is judged, as `debounce`'s. */
|
|
74
|
+
debounceMs: number;
|
|
75
|
+
/**
|
|
76
|
+
* The longest (ms) a batch waits from its first event before it's judged,
|
|
77
|
+
* even while events keep arriving and pushing the quiet period back. Left
|
|
78
|
+
* out, a batch is judged only after `debounceMs` of quiet, as a debounce
|
|
79
|
+
* delivers.
|
|
80
|
+
*/
|
|
81
|
+
maxWaitMs?: number;
|
|
82
|
+
/**
|
|
83
|
+
* The agent's own word to the judge: when it wants to be woken and when it
|
|
84
|
+
* would rather stay quiet ("wake me when someone asks me something or the
|
|
85
|
+
* talk turns to the garden; let banter between others go by"). Shown to the
|
|
86
|
+
* judge with every batch this rule sends it.
|
|
87
|
+
*/
|
|
88
|
+
instructions?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
52
91
|
/** How a matching policy affects inference triggering. */
|
|
53
92
|
export type GateBehavior =
|
|
54
93
|
| 'always' // Trigger inference immediately
|
|
@@ -56,7 +95,8 @@ export type GateBehavior =
|
|
|
56
95
|
| 'skip' // Legacy alias for 'defer' (still accepted).
|
|
57
96
|
| { debounce: number } // Batch events per-policy, deliver after delay (ms)
|
|
58
97
|
| { rate_limit: RateLimitConfig } // Token bucket per `keyBy`; deny when empty
|
|
59
|
-
| { passive_sample: PassiveSampleConfig }
|
|
98
|
+
| { passive_sample: PassiveSampleConfig } // Fire every Nth match
|
|
99
|
+
| { judge: JudgeConfig }; // Batch like debounce, then ask the reply judge
|
|
60
100
|
|
|
61
101
|
// ---------------------------------------------------------------------------
|
|
62
102
|
// Policy match criteria
|
|
@@ -68,7 +108,12 @@ export interface GatePolicyMatch {
|
|
|
68
108
|
scope?: string[];
|
|
69
109
|
/** ServerId to match (exact or glob with *). */
|
|
70
110
|
source?: string;
|
|
71
|
-
/**
|
|
111
|
+
/** Channel to match (exact or glob with *): against the event's channel
|
|
112
|
+
* id, then the registered id the gate resolves for it
|
|
113
|
+
* (`resolveRouteChannel`). A channels/incoming message carries the
|
|
114
|
+
* registered id (`discord:<guild>:<channel>`), and a push the adapter's
|
|
115
|
+
* raw one or none, so a registered-form pattern meets every event in its
|
|
116
|
+
* channel whose push names the channel, and a raw id only push events. */
|
|
72
117
|
channel?: string;
|
|
73
118
|
/** Content text filter. */
|
|
74
119
|
filter?: { type: 'text' | 'regex'; pattern: string };
|
|
@@ -155,7 +200,17 @@ export interface GateConfig {
|
|
|
155
200
|
export interface GateOptions {
|
|
156
201
|
/** Path to gate.json. Default: derived from storePath. */
|
|
157
202
|
configPath?: string;
|
|
158
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* The recipe's gate config. The first start seeds gate.json with it. Each
|
|
205
|
+
* later start merges it into gate.json against the recipe last applied,
|
|
206
|
+
* which the gate keeps beside gate.json (`gate.recipe.json`): a rule the
|
|
207
|
+
* recipe dropped, renamed, moved or redefined follows it, a rule edited at
|
|
208
|
+
* run time or by hand stays, and so does one no recipe declared. Rules are
|
|
209
|
+
* merged by name, compared by what they mean and kept as written: a
|
|
210
|
+
* recipe's rule with no name is never merged, as one with no name was never
|
|
211
|
+
* added, and where gate.json or the recipe names a rule twice, a start only
|
|
212
|
+
* adds the rules gate.json lacks. See `recipe-reconcile.ts`.
|
|
213
|
+
*/
|
|
159
214
|
config?: GateConfig;
|
|
160
215
|
/**
|
|
161
216
|
* Path to a JSON file listing user ids that may wake the agent even while
|
|
@@ -164,8 +219,117 @@ export interface GateOptions {
|
|
|
164
219
|
* missing, no one bypasses sleep.
|
|
165
220
|
*/
|
|
166
221
|
privilegedUsersPath?: string;
|
|
222
|
+
/** The reply judge that `judge` rules ask (see JudgeConfig). Left out (or
|
|
223
|
+
* null), the judge is wired with its defaults; it runs only for `judge`
|
|
224
|
+
* rules, so a gate with none makes no judge calls. */
|
|
225
|
+
judge?: ReplyJudgeOptions | null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Host options for the reply judge, the small model `judge` rules ask whether
|
|
230
|
+
* now is a good time for the agent to reply. The host sets the model and how
|
|
231
|
+
* the judge runs, not the agent: an agent's rule says when to ask and what to
|
|
232
|
+
* say.
|
|
233
|
+
*/
|
|
234
|
+
export interface ReplyJudgeOptions {
|
|
235
|
+
/** False leaves the judge unwired: `wake_add_rule` then offers no `judge`,
|
|
236
|
+
* and a `judge` rule in gate.json wakes the agent as a debounce of its
|
|
237
|
+
* `debounceMs` would, which gate_status says. Default true. */
|
|
238
|
+
enabled?: boolean;
|
|
239
|
+
/** The model the judge runs on, as the host's membrane names it. Default
|
|
240
|
+
* `claude-haiku-5-5`. */
|
|
241
|
+
model?: string;
|
|
242
|
+
/**
|
|
243
|
+
* The most input tokens one judge request may carry, its instructions and
|
|
244
|
+
* the batch included; the context document is cut from its oldest end to
|
|
245
|
+
* fit. Default 90,000: Claude Haiku 5.5 costs five times as much past
|
|
246
|
+
* 100,000 input tokens, and the margin covers the estimate's error. The
|
|
247
|
+
* least is 4,000, a short tail of the conversation: cheaper and quicker,
|
|
248
|
+
* with less of the room's history to weigh.
|
|
249
|
+
*/
|
|
250
|
+
maxInputTokens?: number;
|
|
251
|
+
/** The longest (ms) a judge request may take before the batch is decided by
|
|
252
|
+
* `onError`. Default 20,000. */
|
|
253
|
+
timeoutMs?: number;
|
|
254
|
+
/** What a judge that fails, times out or answers unreadably does: `"wake"`
|
|
255
|
+
* wakes the agent as a debounce would (the default, so a judge outage
|
|
256
|
+
* never silences the agent); `"skip"` doesn't. */
|
|
257
|
+
onError?: 'wake' | 'skip';
|
|
258
|
+
/** The judge's effort (`output_config.effort`). Default `"low"`: a short
|
|
259
|
+
* verdict, quickly. `"none"` sends no effort, for a provider that doesn't
|
|
260
|
+
* take Anthropic's `output_config`. */
|
|
261
|
+
effort?: 'low' | 'medium' | 'high' | 'none';
|
|
262
|
+
/** The prompt cache's lifetime for the judge's context document. `"5m"`
|
|
263
|
+
* (the default) suits judge rules that fire minutes apart; `"1h"` costs
|
|
264
|
+
* more to write and suits ones that fire less often. */
|
|
265
|
+
cacheTtl?: '5m' | '1h';
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** One event of a batch, as the reply judge is shown it. */
|
|
269
|
+
export interface JudgeEventSummary {
|
|
270
|
+
eventType: string;
|
|
271
|
+
/** The channel as the agent is shown it, when the event named one. */
|
|
272
|
+
channel?: string;
|
|
273
|
+
/** The author's id, when the event named one. */
|
|
274
|
+
authorId?: string;
|
|
275
|
+
/** Whether the event addressed the agent (mention, reply, DM). */
|
|
276
|
+
addressed: boolean;
|
|
277
|
+
/** The event's text, cut short when long. */
|
|
278
|
+
content: string;
|
|
279
|
+
/** When the event arrived (ms). */
|
|
280
|
+
at: number;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Something that will (or, for a batch going to the judge, may) wake the
|
|
285
|
+
* agent with no new event: what the judge is told would happen if it answers
|
|
286
|
+
* wait and nothing else arrives.
|
|
287
|
+
*/
|
|
288
|
+
export interface UpcomingWake {
|
|
289
|
+
/** When (ms), when known; absent for one due as soon as the agent is free. */
|
|
290
|
+
at?: number;
|
|
291
|
+
/** False when it only may wake the agent (a judge rule's batch goes to the judge then). */
|
|
292
|
+
certain: boolean;
|
|
293
|
+
/** What it is, as the judge is told ("its own skip_reply timer"). */
|
|
294
|
+
what: string;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** What the gate asks the reply judge for one batch. */
|
|
298
|
+
export interface JudgeRequest {
|
|
299
|
+
/** The rule whose batch this is. */
|
|
300
|
+
policyName: string;
|
|
301
|
+
/** The rule's `instructions`, the agent's own word to the judge. */
|
|
302
|
+
instructions?: string;
|
|
303
|
+
/** The batch, oldest first. */
|
|
304
|
+
events: JudgeEventSummary[];
|
|
305
|
+
/** The agents the batch would wake. */
|
|
306
|
+
agentNames: string[];
|
|
307
|
+
/** The gate's own timers that will wake those agents with no new event
|
|
308
|
+
* (upcomingWakes): their self-wakes, a sleep's end, other rules' pending
|
|
309
|
+
* batches. The judge adds what the framework knows besides. */
|
|
310
|
+
upcomingWakes?: UpcomingWake[];
|
|
311
|
+
/** Aborted when the judge's time is up or the gate is disposed. */
|
|
312
|
+
signal: AbortSignal;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** The reply judge's answer for one batch. */
|
|
316
|
+
export interface JudgeVerdict {
|
|
317
|
+
/** True: wake the agent now. False: let the batch go by. */
|
|
318
|
+
reply: boolean;
|
|
319
|
+
/** The judge's one-line reason. */
|
|
320
|
+
reason: string;
|
|
321
|
+
/** The model that answered. */
|
|
322
|
+
model?: string;
|
|
323
|
+
/** Input tokens the request carried (all of them: uncached, cache reads and writes). */
|
|
324
|
+
inputTokens?: number;
|
|
325
|
+
/** Of those, the tokens read from the prompt cache. */
|
|
326
|
+
cacheReadTokens?: number;
|
|
327
|
+
outputTokens?: number;
|
|
167
328
|
}
|
|
168
329
|
|
|
330
|
+
/** The judge's function, as the framework wires it into the gate. */
|
|
331
|
+
export type JudgeFn = (request: JudgeRequest) => Promise<JudgeVerdict>;
|
|
332
|
+
|
|
169
333
|
// ---------------------------------------------------------------------------
|
|
170
334
|
// Runtime types (internal to EventGate, exported for tests/tools)
|
|
171
335
|
// ---------------------------------------------------------------------------
|
|
@@ -231,6 +395,47 @@ export interface GateEventInfo {
|
|
|
231
395
|
tags?: string[];
|
|
232
396
|
}
|
|
233
397
|
|
|
398
|
+
/** An MCPL event whose content the framework stored at arrival, as a
|
|
399
|
+
* batched wake names it to the framework (EventGate's `isNewestEntry`):
|
|
400
|
+
* a channel message by its server, channel and message id, a push event by
|
|
401
|
+
* its server and event id. */
|
|
402
|
+
export interface GateEntryRef {
|
|
403
|
+
eventType: string;
|
|
404
|
+
serverId?: string;
|
|
405
|
+
channelId?: string;
|
|
406
|
+
messageId?: string;
|
|
407
|
+
eventId?: string;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** A batched wake's `[Gate: …]` line that the gate handed to the wake rather
|
|
411
|
+
* than wrote: its batch was one event whose entry was still the newest in
|
|
412
|
+
* the window when the batch fired (EventGate's `isNewestEntry`). A fresh
|
|
413
|
+
* start of the wake's turn decides it (the framework's placeWakeLines): the
|
|
414
|
+
* delivery agent's own start leaves it out while that entry is still the
|
|
415
|
+
* newest, and writes it once something follows; a co-resident's start
|
|
416
|
+
* places none; two or more such lines are each written;
|
|
417
|
+
* and none is written while the host is quiesced or another reader of the
|
|
418
|
+
* residents' shared slot has a turn alive. A line left out stays for a
|
|
419
|
+
* later fresh start of the same wake. Its text is rendered when it's
|
|
420
|
+
* written (wakeLineText), so its age is true then.
|
|
421
|
+
*
|
|
422
|
+
* Every request for one wake carries the same object: the framework writes
|
|
423
|
+
* each line once by its identity, across the wake's retries and holds. A
|
|
424
|
+
* host that hands the gate's requests on itself passes the line on as it
|
|
425
|
+
* is, not a copy per agent. */
|
|
426
|
+
export interface WakeLine {
|
|
427
|
+
/** The event's own entry. */
|
|
428
|
+
entry: GateEntryRef;
|
|
429
|
+
policyNames: string[];
|
|
430
|
+
/** The channel as the line names it to the agent. */
|
|
431
|
+
shown: string;
|
|
432
|
+
/** When the event arrived (ms): the line's age is counted from it to when
|
|
433
|
+
* the line is written (wakeLineText). */
|
|
434
|
+
at: number;
|
|
435
|
+
/** The channel the line names, as the omission's trace reports it. */
|
|
436
|
+
channelId?: string;
|
|
437
|
+
}
|
|
438
|
+
|
|
234
439
|
/** Per-policy runtime statistics (for gate:status). */
|
|
235
440
|
export interface GatePolicyStats {
|
|
236
441
|
name: string;
|
|
@@ -251,6 +456,26 @@ export interface GatePolicyStats {
|
|
|
251
456
|
counterCount: number;
|
|
252
457
|
fireCount: number;
|
|
253
458
|
};
|
|
459
|
+
/** Present for `judge` behaviors. */
|
|
460
|
+
judgeState?: {
|
|
461
|
+
/** Events in the batch still waiting out its quiet period. */
|
|
462
|
+
pendingCount: number;
|
|
463
|
+
/** Whether the judge is deciding one of this rule's batches now. */
|
|
464
|
+
judging: boolean;
|
|
465
|
+
/** Events held for the judge until the agent's turn (or the host's quiesce) ends. */
|
|
466
|
+
heldCount: number;
|
|
467
|
+
/** Verdicts so far: woke the agent, let the batch go by, and judge failures. */
|
|
468
|
+
verdicts: { reply: number; wait: number; error: number };
|
|
469
|
+
/** The newest verdict. */
|
|
470
|
+
last?: {
|
|
471
|
+
at: number;
|
|
472
|
+
verdict: 'reply' | 'wait' | 'error';
|
|
473
|
+
reason: string;
|
|
474
|
+
eventCount: number;
|
|
475
|
+
durationMs: number;
|
|
476
|
+
inputTokens?: number;
|
|
477
|
+
};
|
|
478
|
+
};
|
|
254
479
|
}
|
|
255
480
|
|
|
256
481
|
/** Full gate status returned by gate:status tool. */
|