@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
package/src/mcpl/types.ts
CHANGED
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
export interface JsonRpcRequest {
|
|
23
23
|
jsonrpc: '2.0';
|
|
24
24
|
method: string;
|
|
25
|
-
id
|
|
25
|
+
/** A request's id; null is allowed, though JSON-RPC 2.0 discourages it. */
|
|
26
|
+
id?: string | number | null;
|
|
26
27
|
params?: Record<string, unknown>;
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -31,7 +32,8 @@ export interface JsonRpcRequest {
|
|
|
31
32
|
*/
|
|
32
33
|
export interface JsonRpcResponse {
|
|
33
34
|
jsonrpc: '2.0';
|
|
34
|
-
id
|
|
35
|
+
/** The request's id, or null when the request's own couldn't be read. */
|
|
36
|
+
id: string | number | null;
|
|
35
37
|
result?: unknown;
|
|
36
38
|
error?: JsonRpcError;
|
|
37
39
|
}
|
|
@@ -265,8 +267,9 @@ export interface McplServerConfig {
|
|
|
265
267
|
* - `ws://` or `wss://` is a legacy MCPL server over MCPL's WebSocket
|
|
266
268
|
* binding. The host dials it and runs the same newline-delimited JSON-RPC
|
|
267
269
|
* as over stdio.
|
|
268
|
-
* - `http://` or `https://` is a modern MCP
|
|
269
|
-
*
|
|
270
|
+
* - `http://` or `https://` is a modern MCP server over Streamable HTTP.
|
|
271
|
+
* Its revision is negotiated at each connect: 2026-07-28 when the server
|
|
272
|
+
* offers it, and otherwise 2025-11-25, 2025-06-18 or 2025-03-26.
|
|
270
273
|
*/
|
|
271
274
|
url?: string;
|
|
272
275
|
|
|
@@ -426,14 +429,34 @@ export interface McplServerConfig {
|
|
|
426
429
|
* Only `true` turns it on, and null counts as not set. `create()`,
|
|
427
430
|
* `connectMcplServer` and `restartMcplServer` refuse any other value, such
|
|
428
431
|
* as a quoted "false".
|
|
432
|
+
*
|
|
433
|
+
* A modern server reached over HTTP at a 2025 revision can hold a session
|
|
434
|
+
* for this client. When the server ends it (HTTP 404), or stops serving its
|
|
435
|
+
* revision or its streams as a server upgraded to 2026-07-28 does, after it
|
|
436
|
+
* has answered a request, a new session starts at once whether or not this
|
|
437
|
+
* is set: the connection emits 'close' while its `willReconnect` reads
|
|
438
|
+
* true, then 'reconnect'. If that new session can't start, this setting
|
|
439
|
+
* decides, as for any lost connection, and a revision verdict stops it for
|
|
440
|
+
* good, as on any reconnect; without this setting, a second 'close', while
|
|
441
|
+
* `willReconnect` reads false, says the server is gone. An answered session
|
|
442
|
+
* that ends less than `reconnectIntervalMs` after it started gets a new
|
|
443
|
+
* one at once only if the last session restarted that way had lived that
|
|
444
|
+
* long, or there was none. A second such young end in a row, and a session
|
|
445
|
+
* that ends before it has answered, count as a failed connect, and follow
|
|
446
|
+
* this setting.
|
|
429
447
|
*/
|
|
430
448
|
reconnect?: boolean;
|
|
431
449
|
|
|
432
450
|
/**
|
|
433
451
|
* Base interval between reconnection attempts in milliseconds.
|
|
434
452
|
* The actual delay doubles with each consecutive failure (with ±25% jitter)
|
|
435
|
-
* up to `reconnectMaxIntervalMs`, and resets after a successful handshake
|
|
436
|
-
*
|
|
453
|
+
* up to `reconnectMaxIntervalMs`, and resets after a successful handshake
|
|
454
|
+
* (for a modern server's 2025 session over HTTP, once that session's end
|
|
455
|
+
* starts a new one at once). Over HTTP the same backoff paces a modern
|
|
456
|
+
* server's streams: a dropped stream's first try waits the server's
|
|
457
|
+
* `retry` hint when it sent one above 0, and the backoff's first step
|
|
458
|
+
* otherwise, and a try after a failed one waits the longer of the hint
|
|
459
|
+
* and the doubling backoff. Default: 5000 (5 seconds).
|
|
437
460
|
*/
|
|
438
461
|
reconnectIntervalMs?: number;
|
|
439
462
|
|
|
@@ -596,6 +619,10 @@ export interface FeatureSetDeclaration {
|
|
|
596
619
|
coreTags?: string[];
|
|
597
620
|
tags?: Record<string, unknown>;
|
|
598
621
|
keyed?: Record<string, unknown>;
|
|
622
|
+
/** Ordered suggested rules (RFC-001 §5.1). Advisory: applied only on
|
|
623
|
+
* acceptance (§5.2), which wake onboarding asks the agent for. */
|
|
624
|
+
suggestedTreatment?: unknown[];
|
|
625
|
+
/** @deprecated RFC-001 revision 1's name for suggestedTreatment; still read. */
|
|
599
626
|
defaultTreatment?: unknown[];
|
|
600
627
|
open?: boolean;
|
|
601
628
|
};
|
package/src/module-registry.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { JsStateRegistration, JsStore } from '@animalabs/chronicle';
|
|
2
2
|
import type { ContentBlock } from '@animalabs/membrane';
|
|
3
3
|
import type {
|
|
4
|
+
ContextManager,
|
|
4
5
|
MessageId,
|
|
5
6
|
MessageMetadata,
|
|
6
7
|
MessageQuery,
|
|
7
8
|
ContextInjection,
|
|
9
|
+
StoredMessage,
|
|
10
|
+
WindowStatus,
|
|
8
11
|
} from '@animalabs/context-manager';
|
|
12
|
+
import { WriteOutcomeUnknownError } from './context-manager-errors.js';
|
|
9
13
|
import type {
|
|
10
14
|
Module,
|
|
11
15
|
ModuleContext,
|
|
@@ -25,7 +29,6 @@ import type {
|
|
|
25
29
|
ModuleContextInjection,
|
|
26
30
|
MessageQueryResult,
|
|
27
31
|
} from './types/index.js';
|
|
28
|
-
import { heldWriteId } from './held-writes.js';
|
|
29
32
|
import { boundedErrorMessage } from './error-message.js';
|
|
30
33
|
import type { Agent } from './agent.js';
|
|
31
34
|
import { DEFAULT_SHUTDOWN_TIMEOUT_MS, validateShutdownTimeout, waitForShutdown } from './shutdown.js';
|
|
@@ -150,6 +153,13 @@ export class ModuleRegistry {
|
|
|
150
153
|
message: string,
|
|
151
154
|
data?: Record<string, unknown>,
|
|
152
155
|
) => void;
|
|
156
|
+
/** The window lookups ModuleContext.windowStatusOf, observes, viewKeeps
|
|
157
|
+
* and agentNameOf give modules (#291), when the framework offers them.
|
|
158
|
+
* Readonly-public, as notifyOpsFn is. */
|
|
159
|
+
readonly windowStatusOfFn?: (id: MessageId, opts?: { forAgent?: string }) => WindowStatus;
|
|
160
|
+
readonly observesFn?: (observer: string, observed: string) => boolean;
|
|
161
|
+
readonly viewKeepsFn?: (row: StoredMessage, opts?: { forAgent?: string }) => boolean;
|
|
162
|
+
readonly agentNameOfFn?: (contextManager: ContextManager) => string | undefined;
|
|
153
163
|
|
|
154
164
|
constructor(
|
|
155
165
|
store: JsStore,
|
|
@@ -170,6 +180,14 @@ export class ModuleRegistry {
|
|
|
170
180
|
onTrace: (listener: TraceEventListener) => () => void;
|
|
171
181
|
callTool: (call: ToolCall) => Promise<ToolResult>;
|
|
172
182
|
notifyOps?: (kind: string, agentName: string, message: string, data?: Record<string, unknown>) => void;
|
|
183
|
+
/** Where a row stands with an agent's window (ModuleContext.windowStatusOf). */
|
|
184
|
+
windowStatusOf?: (id: MessageId, opts?: { forAgent?: string }) => WindowStatus;
|
|
185
|
+
/** Whether one agent observes another's own rows (ModuleContext.observes). */
|
|
186
|
+
observes?: (observer: string, observed: string) => boolean;
|
|
187
|
+
/** Whether an agent's view keeps a stored row (ModuleContext.viewKeeps). */
|
|
188
|
+
viewKeeps?: (row: StoredMessage, opts?: { forAgent?: string }) => boolean;
|
|
189
|
+
/** The live agent whose context a context manager is (ModuleContext.agentNameOf). */
|
|
190
|
+
agentNameOf?: (contextManager: ContextManager) => string | undefined;
|
|
173
191
|
}
|
|
174
192
|
) {
|
|
175
193
|
this.store = store;
|
|
@@ -184,6 +202,10 @@ export class ModuleRegistry {
|
|
|
184
202
|
this.onTraceFn = options.onTrace;
|
|
185
203
|
this.callToolFn = options.callTool;
|
|
186
204
|
this.notifyOpsFn = options.notifyOps;
|
|
205
|
+
this.windowStatusOfFn = options.windowStatusOf;
|
|
206
|
+
this.observesFn = options.observes;
|
|
207
|
+
this.viewKeepsFn = options.viewKeeps;
|
|
208
|
+
this.agentNameOfFn = options.agentNameOf;
|
|
187
209
|
this.dropRetiredPushFn = options.dropRetiredPush;
|
|
188
210
|
}
|
|
189
211
|
|
|
@@ -748,6 +770,12 @@ class ModuleContextImpl implements ModuleContext {
|
|
|
748
770
|
private pushEventFn: (event: ProcessEvent, moduleName?: string) => void;
|
|
749
771
|
private onTraceFn: (listener: TraceEventListener) => () => void;
|
|
750
772
|
private callToolFn: (call: ToolCall) => Promise<ToolResult>;
|
|
773
|
+
/** Offered only when the registry was given the framework's lookups, so
|
|
774
|
+
* a module can tell a framework that has them from one that hasn't. */
|
|
775
|
+
readonly windowStatusOf?: (id: MessageId, opts?: { forAgent?: string }) => WindowStatus;
|
|
776
|
+
readonly observes?: (observer: string, observed: string) => boolean;
|
|
777
|
+
readonly viewKeeps?: (row: StoredMessage, opts?: { forAgent?: string }) => boolean;
|
|
778
|
+
readonly agentNameOf?: (contextManager: ContextManager) => string | undefined;
|
|
751
779
|
|
|
752
780
|
// External ID mapping stored in module state
|
|
753
781
|
private externalIdMap: Map<string, MessageId> = new Map();
|
|
@@ -794,6 +822,14 @@ class ModuleContextImpl implements ModuleContext {
|
|
|
794
822
|
this.pushEventFn = pushEvent;
|
|
795
823
|
this.onTraceFn = onTrace;
|
|
796
824
|
this.callToolFn = callTool;
|
|
825
|
+
const windowStatusOf = registry.windowStatusOfFn;
|
|
826
|
+
if (windowStatusOf) this.windowStatusOf = (id, opts) => windowStatusOf(id, opts);
|
|
827
|
+
const observes = registry.observesFn;
|
|
828
|
+
if (observes) this.observes = (observer, observed) => observes(observer, observed);
|
|
829
|
+
const viewKeeps = registry.viewKeepsFn;
|
|
830
|
+
if (viewKeeps) this.viewKeeps = (row, opts) => viewKeeps(row, opts);
|
|
831
|
+
const agentNameOf = registry.agentNameOfFn;
|
|
832
|
+
if (agentNameOf) this.agentNameOf = (contextManager) => agentNameOf(contextManager);
|
|
797
833
|
|
|
798
834
|
// Load external ID map from state if exists
|
|
799
835
|
const state = this.getState<{ externalIdMap?: Record<string, string> }>();
|
|
@@ -951,15 +987,35 @@ class ModuleContextImpl implements ModuleContext {
|
|
|
951
987
|
throw new Error(`A message for agent ${JSON.stringify(opts.forAgent)} can't carry metadata.external: `
|
|
952
988
|
+ "its external id would be looked up in the primary's window. Leave forAgent out, or the external id.");
|
|
953
989
|
}
|
|
954
|
-
|
|
990
|
+
let id: MessageId;
|
|
991
|
+
try {
|
|
992
|
+
id = this.addMessageFn(participant, content, metadata, opts);
|
|
993
|
+
} catch (error) {
|
|
994
|
+
// A write whose store threw where context-manager can't tell whether
|
|
995
|
+
// it landed (WriteOutcomeUnknownError, which the write is answered by)
|
|
996
|
+
// may be stored: its external id maps to '', as a write kept in memory
|
|
997
|
+
// does, so findMessageByExternalId looks it up in the store. A mapping
|
|
998
|
+
// that can't be persisted is logged, and the write's own error thrown.
|
|
999
|
+
if (metadata?.external && error instanceof WriteOutcomeUnknownError) {
|
|
1000
|
+
this.externalIdMap.set(`${metadata.external.source}:${metadata.external.id}`, '');
|
|
1001
|
+
try {
|
|
1002
|
+
this.persistExternalIdMap();
|
|
1003
|
+
} catch (persist) {
|
|
1004
|
+
console.error(`[module:${this.moduleName}] the external id of a write that may be stored could not be persisted:`, persist);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
throw error;
|
|
1008
|
+
}
|
|
955
1009
|
|
|
956
|
-
// Track external ID if provided
|
|
957
|
-
//
|
|
958
|
-
//
|
|
959
|
-
//
|
|
1010
|
+
// Track external ID if provided: the stored id the write was given
|
|
1011
|
+
// (#291 stores every write at once), or '' for one kept in memory (a
|
|
1012
|
+
// surgery's hold, or the wait for its agent's recovery), as earlier
|
|
1013
|
+
// releases kept '' for a write they held.
|
|
1014
|
+
// findMessageByExternalId finds such a write by its external id once it
|
|
1015
|
+
// is stored.
|
|
960
1016
|
if (metadata?.external) {
|
|
961
1017
|
const key = `${metadata.external.source}:${metadata.external.id}`;
|
|
962
|
-
this.externalIdMap.set(key,
|
|
1018
|
+
this.externalIdMap.set(key, id);
|
|
963
1019
|
// Persist the mapping
|
|
964
1020
|
this.persistExternalIdMap();
|
|
965
1021
|
}
|
|
@@ -991,15 +1047,16 @@ class ModuleContextImpl implements ModuleContext {
|
|
|
991
1047
|
if (entry === undefined) return null;
|
|
992
1048
|
// A stored id answers while the store holds its row, and once the row is
|
|
993
1049
|
// gone the entry goes, as removeMessage drops it, except from a context
|
|
994
|
-
// whose module has stopped, which keeps its mapping as it was.
|
|
995
|
-
// write
|
|
996
|
-
//
|
|
997
|
-
//
|
|
998
|
-
//
|
|
999
|
-
//
|
|
1000
|
-
//
|
|
1001
|
-
//
|
|
1002
|
-
//
|
|
1050
|
+
// whose module has stopped, which keeps its mapping as it was. A '' here
|
|
1051
|
+
// names no row: a write kept in memory (a surgery's hold, or the wait for
|
|
1052
|
+
// its agent's recovery), or one an earlier release held, whose map it
|
|
1053
|
+
// persisted with ''. So the message is looked up in the store by its
|
|
1054
|
+
// external id, and the first row found is taken, as context-manager's
|
|
1055
|
+
// findByExternalId takes it, and its id becomes the entry (but in a
|
|
1056
|
+
// stopped module's context). With nothing found, '' stays: in a module's
|
|
1057
|
+
// start(), a write an earlier release left queued isn't stored yet, since
|
|
1058
|
+
// create() imports those after the modules start, and a write that shows
|
|
1059
|
+
// later finds its entry.
|
|
1003
1060
|
if (entry !== '') {
|
|
1004
1061
|
if (this.getMessageFn(entry)) return entry;
|
|
1005
1062
|
if (!this.retired) {
|
|
@@ -1009,7 +1066,6 @@ class ModuleContextImpl implements ModuleContext {
|
|
|
1009
1066
|
return null;
|
|
1010
1067
|
}
|
|
1011
1068
|
const row = this.queryMessagesFn({ source, externalIds: [externalId] }).messages[0];
|
|
1012
|
-
if (row?.held) return row.id;
|
|
1013
1069
|
if (!row) return null;
|
|
1014
1070
|
if (!this.retired) {
|
|
1015
1071
|
this.externalIdMap.set(key, row.id);
|