@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,242 @@
|
|
|
1
|
+
const HEAD = Symbol('read-mark head');
|
|
2
|
+
const LENGTH = Symbol('read-mark length');
|
|
3
|
+
function mark(branch, head, length) {
|
|
4
|
+
return Object.freeze({ branch, [HEAD]: head, [LENGTH]: length });
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A mark of where `cm` stands now: its branch, the store's head (the
|
|
8
|
+
* chronicle head, not the slot's last row: in legacy mode a compile reads
|
|
9
|
+
* everything stored on the branch that its view keeps, rows merged in from
|
|
10
|
+
* another slot included; a double without a store gives its last row's
|
|
11
|
+
* sequence), and
|
|
12
|
+
* its index length when it is in presented mode, where a compile reads the
|
|
13
|
+
* window and the mark covers by that length, not by the head. Null for a
|
|
14
|
+
* double that can't say, or when reading throws.
|
|
15
|
+
*/
|
|
16
|
+
export function readMarkOf(cm) {
|
|
17
|
+
try {
|
|
18
|
+
const head = storeHeadOf(cm);
|
|
19
|
+
if (head === null)
|
|
20
|
+
return null;
|
|
21
|
+
const presented = typeof cm.windowMode === 'function' && cm.windowMode() === 'presented'
|
|
22
|
+
&& typeof cm.indexLength === 'function';
|
|
23
|
+
return mark(cm.currentBranch().name, head, presented ? cm.indexLength() : null);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The store's head as `cm` reads it now, the head a mark readMarkOf takes
|
|
31
|
+
* keeps: the chronicle head, not the slot's last message, since in legacy
|
|
32
|
+
* mode a compile reads everything stored on the branch so far, rows merged
|
|
33
|
+
* in from another slot included (in presented mode it reads the window,
|
|
34
|
+
* which a mark covers by its index length). A record sequence, on the
|
|
35
|
+
* branch `cm` is on: for a reader
|
|
36
|
+
* that compares stored rows' sequences with it on that branch (Agent's
|
|
37
|
+
* branchHead), not a cover of the window. Null for a context double that
|
|
38
|
+
* can't say.
|
|
39
|
+
*/
|
|
40
|
+
export function storeHeadOf(cm) {
|
|
41
|
+
try {
|
|
42
|
+
if (typeof cm.currentBranch !== 'function' || typeof cm.getAllMessages !== 'function')
|
|
43
|
+
return null;
|
|
44
|
+
const store = typeof cm.getStore === 'function' ? cm.getStore() : undefined;
|
|
45
|
+
let head = typeof store?.currentSequence === 'function' ? store.currentSequence() : undefined;
|
|
46
|
+
if (head === undefined) {
|
|
47
|
+
const count = typeof cm.getMessageCount === 'function' ? cm.getMessageCount() : cm.getAllMessages().length;
|
|
48
|
+
head = count > 0 ? cm.getAllMessages().at(-1)?.sequence ?? 0 : 0;
|
|
49
|
+
}
|
|
50
|
+
return head;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A mark of where `cm` stands now, as readMarkOf takes one, that covers its
|
|
58
|
+
* window only below `length` (an index length of that window, at most its
|
|
59
|
+
* own): for a redo on the window (AgentFramework.redo), which puts back,
|
|
60
|
+
* at new ordinals and in their order, rows a mark covered before they were
|
|
61
|
+
* undone and rows it didn't, so the mark it gives again covers the first
|
|
62
|
+
* and not the rest. Null where readMarkOf gives null, and in legacy mode,
|
|
63
|
+
* where a mark has no length.
|
|
64
|
+
*/
|
|
65
|
+
export function readMarkThrough(cm, length) {
|
|
66
|
+
const now = readMarkOf(cm);
|
|
67
|
+
if (!now || now[LENGTH] === null)
|
|
68
|
+
return null;
|
|
69
|
+
return mark(now.branch, now[HEAD], Math.min(length, now[LENGTH]));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether a mark was taken in presented mode: it keeps the window's index
|
|
73
|
+
* length, and covers rows by their ordinals there, so a row taken out of the
|
|
74
|
+
* window and presented again, at a new ordinal past its length, leaves it.
|
|
75
|
+
* A mark taken in legacy mode keeps none: it covers by sequence while its
|
|
76
|
+
* window is the record, and, once the window is written down, by ordinal
|
|
77
|
+
* too, below the first row the window didn't hold by its head (coverTest),
|
|
78
|
+
* so a row presented again after it leaves it in the same way.
|
|
79
|
+
*/
|
|
80
|
+
export function coversByOrdinal(mark) {
|
|
81
|
+
return !!mark && mark[LENGTH] !== null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A test of many rows against one mark, read against `reader` (the manager
|
|
85
|
+
* whose window the mark is of), which reads the reader's branch and mode
|
|
86
|
+
* once. The rules:
|
|
87
|
+
*
|
|
88
|
+
* - no mark: doubt;
|
|
89
|
+
* - a mark on another branch than the reader's: doubt, except that a mark
|
|
90
|
+
* taken in legacy mode, read `across` a branch point (`partAt`, the last
|
|
91
|
+
* sequence the two branches share), reads as one on the reader's branch
|
|
92
|
+
* (below) through the lower of its head and the branch point;
|
|
93
|
+
* - a mark taken in legacy mode, read against a reader in legacy mode: a
|
|
94
|
+
* row at or below its head is covered;
|
|
95
|
+
* - a mark taken in legacy mode, read against a reader in presented mode:
|
|
96
|
+
* a row the window has held where it stands since the head or before is
|
|
97
|
+
* covered (windowLengthAt: the window's rows below the ordinal of its first
|
|
98
|
+
* row a branch cut at the head wouldn't keep), and no other: not a row
|
|
99
|
+
* stored after the head, out of the window, or presented after the head,
|
|
100
|
+
* again or for the first time. A reader that can't say where its window
|
|
101
|
+
* held a row (a double without ordinalOf, getPresentedMessages,
|
|
102
|
+
* branchSequenceOf or indexLength) is read by sequence, as in legacy
|
|
103
|
+
* mode; a read of the window that throws is doubt for the rows at or
|
|
104
|
+
* below the head;
|
|
105
|
+
* - a mark taken in presented mode, read against a reader no longer in it:
|
|
106
|
+
* doubt;
|
|
107
|
+
* - else a row is covered when its ordinal is below the mark's length:
|
|
108
|
+
* strictly, since the length is the ordinal the next row would take. A row
|
|
109
|
+
* out of the window (never presented, or taken out) is not covered.
|
|
110
|
+
*/
|
|
111
|
+
export function coverTest(mark, reader, across) {
|
|
112
|
+
if (!mark)
|
|
113
|
+
return () => 'doubt';
|
|
114
|
+
let branch;
|
|
115
|
+
let presented = false;
|
|
116
|
+
try {
|
|
117
|
+
branch = typeof reader.currentBranch === 'function' ? reader.currentBranch().name : undefined;
|
|
118
|
+
presented = typeof reader.windowMode === 'function' && reader.windowMode() === 'presented';
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return () => 'doubt';
|
|
122
|
+
}
|
|
123
|
+
const head = mark[HEAD];
|
|
124
|
+
const length = mark[LENGTH];
|
|
125
|
+
if (branch !== mark.branch) {
|
|
126
|
+
if (!across || length !== null)
|
|
127
|
+
return () => 'doubt';
|
|
128
|
+
return legacyCover(reader, presented, Math.min(head, across.partAt));
|
|
129
|
+
}
|
|
130
|
+
if (length === null)
|
|
131
|
+
return legacyCover(reader, presented, head);
|
|
132
|
+
if (!presented || typeof reader.ordinalOf !== 'function')
|
|
133
|
+
return () => 'doubt';
|
|
134
|
+
return byOrdinal(reader.ordinalOf.bind(reader), length);
|
|
135
|
+
}
|
|
136
|
+
function byOrdinal(ordinalOf, length) {
|
|
137
|
+
return (row) => {
|
|
138
|
+
const ordinal = ordinalOf(row.id);
|
|
139
|
+
return ordinal !== undefined && ordinal < length ? 'covered' : 'not-covered';
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* How a mark taken in legacy mode covers through `through` (its head, or the
|
|
144
|
+
* lower of its head and a branch point): by sequence against a reader in
|
|
145
|
+
* legacy mode, or one that can't say where its window held a row; against
|
|
146
|
+
* one in presented mode, by ordinal below windowLengthAt(reader, through),
|
|
147
|
+
* read once, at the first row that needs it. A row stored after `through`
|
|
148
|
+
* entered the window after it, wherever it stands, so it is not covered
|
|
149
|
+
* without that read.
|
|
150
|
+
*/
|
|
151
|
+
function legacyCover(reader, presented, through) {
|
|
152
|
+
const bySequence = (row) => (row.sequence <= through ? 'covered' : 'not-covered');
|
|
153
|
+
if (!presented || typeof reader.ordinalOf !== 'function' || typeof reader.getPresentedMessages !== 'function'
|
|
154
|
+
|| typeof reader.branchSequenceOf !== 'function' || typeof reader.indexLength !== 'function') {
|
|
155
|
+
return bySequence;
|
|
156
|
+
}
|
|
157
|
+
let cover;
|
|
158
|
+
return (row) => {
|
|
159
|
+
if (row.sequence > through)
|
|
160
|
+
return 'not-covered';
|
|
161
|
+
if (!cover) {
|
|
162
|
+
const length = windowLengthAt(reader, through);
|
|
163
|
+
cover = length === null ? () => 'doubt' : byOrdinal(reader.ordinalOf.bind(reader), length);
|
|
164
|
+
}
|
|
165
|
+
return cover(row);
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The index length a mark taken in presented mode would hold to cover the
|
|
170
|
+
* rows `reader`'s window (in presented mode) has held, where they stand
|
|
171
|
+
* now, since sequence `through` or before: the ordinal of the window's first
|
|
172
|
+
* row that a branch cut at `through` wouldn't keep in its window, or the
|
|
173
|
+
* index length when such a cut keeps them all. A cut keeps a row when its
|
|
174
|
+
* branchSequenceOf (the sequence a cut has to reach for its window to hold
|
|
175
|
+
* the row) is at or below `through`: a row's own sequence (its body's last
|
|
176
|
+
* shard's) for a row the write-down put in the window, which lists the
|
|
177
|
+
* record in record order, and the write that presented it for any other,
|
|
178
|
+
* which comes after the write-down and after every write that presented a
|
|
179
|
+
* row before it. So that sequence only grows along the window, and the
|
|
180
|
+
* first row past `through` is found by a binary search over it: a few reads
|
|
181
|
+
* per mark, whatever the window's length. Null when a read throws.
|
|
182
|
+
*/
|
|
183
|
+
function windowLengthAt(reader, through) {
|
|
184
|
+
try {
|
|
185
|
+
const window = reader.getPresentedMessages();
|
|
186
|
+
let low = 0;
|
|
187
|
+
let high = window.length;
|
|
188
|
+
while (low < high) {
|
|
189
|
+
const middle = (low + high) >>> 1;
|
|
190
|
+
if (reader.branchSequenceOf(window[middle].id) <= through)
|
|
191
|
+
low = middle + 1;
|
|
192
|
+
else
|
|
193
|
+
high = middle;
|
|
194
|
+
}
|
|
195
|
+
if (low === window.length)
|
|
196
|
+
return reader.indexLength();
|
|
197
|
+
return reader.ordinalOf(window[low].id) ?? null;
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/** Whether `mark` covers `row` in `reader`'s window (see coverTest for the rules). */
|
|
204
|
+
export function covers(mark, reader, row, across) {
|
|
205
|
+
return coverTest(mark, reader, across)(row);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Whether mark `a` was taken at or after mark `b`: on one branch, by the
|
|
209
|
+
* window's index length when both keep one, which only grows there and
|
|
210
|
+
* grows at every presentation, and by the store's head, which only grows
|
|
211
|
+
* there too, where the lengths are equal or either mark keeps none;
|
|
212
|
+
* `'other-branch'` when they are on two. Two marks at one head can keep two
|
|
213
|
+
* lengths: a mark readMarkThrough gives (a redo's) covers less of the window
|
|
214
|
+
* than one taken at the same head, and a double without a store reads its
|
|
215
|
+
* head from its last row, which no presentation moves. The one with the
|
|
216
|
+
* greater length is the later: a publish noted with it (Agent.notePublished)
|
|
217
|
+
* is credited with the rows presented between.
|
|
218
|
+
*/
|
|
219
|
+
export function markAtOrAfter(a, b) {
|
|
220
|
+
if (a.branch !== b.branch)
|
|
221
|
+
return 'other-branch';
|
|
222
|
+
const [aLength, bLength] = [a[LENGTH], b[LENGTH]];
|
|
223
|
+
if (aLength !== null && bLength !== null && aLength !== bLength)
|
|
224
|
+
return aLength > bLength;
|
|
225
|
+
return a[HEAD] >= b[HEAD];
|
|
226
|
+
}
|
|
227
|
+
/** A mark for a log line or a test's message: `main@412` in legacy mode, `main@412#57` with its index length. */
|
|
228
|
+
export function describeReadMark(mark) {
|
|
229
|
+
if (!mark)
|
|
230
|
+
return 'no mark';
|
|
231
|
+
return `${mark.branch}@${mark[HEAD]}${mark[LENGTH] === null ? '' : `#${mark[LENGTH]}`}`;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* A mark built from its parts, for a test that needs one taken at a given
|
|
235
|
+
* place. Production code takes marks with readMarkOf.
|
|
236
|
+
*
|
|
237
|
+
* @internal
|
|
238
|
+
*/
|
|
239
|
+
export function readMarkForTest(branch, head, length) {
|
|
240
|
+
return mark(branch, head, length);
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=read-marks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-marks.js","sourceRo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AClD,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,OAAO;QAAE,OAAO,OAAO,GAAG,OAAO,CAAC;IAC1F,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,gBAAgB,CAAC,IAAqB;IACpD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;AAC1F,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,IAAY,EAAE,MAAqB;IACjF,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** #973: #938 stopped writing these notices, but old stores retain them.
|
|
2
|
+
* Exclude deterministically before selection, compression and thinking binding;
|
|
3
|
+
* never match text or change stored history. */
|
|
4
|
+
export declare function isReasoningLoss(metadata: unknown): boolean;
|
|
5
|
+
//# sourceMappingURL=reasoning-loss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning-loss.d.ts","sourceRoot":"","sources":["../../src/reasoning-loss.ts"],"names":[],"mappings":"AAAA;;iDAEiD;AACjD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAG1D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** #973: #938 stopped writing these notices, but old stores retain them.
|
|
2
|
+
* Exclude deterministically before selection, compression and thinking binding;
|
|
3
|
+
* never match text or change stored history. */
|
|
4
|
+
export function isReasoningLoss(metadata) {
|
|
5
|
+
const mark = metadata;
|
|
6
|
+
return mark?.kind === 'reasoning-loss' && mark.system === true;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=reasoning-loss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning-loss.js","sourceRoot":"","sources":["../../src/reasoning-loss.ts"],"names":[],"mappings":"AAAA;;iDAEiD;AACjD,MAAM,UAAU,eAAe,CAAC,QAAiB;IAC/C,MAAM,IAAI,GAAG,QAAmE,CAAC;IACjF,OAAO,IAAI,EAAE,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC;AACjE,CAAC"}
|
|
@@ -3,12 +3,45 @@ import { type DiscordAwarenessMarks, type DiscordAwarenessRef } from './discord-
|
|
|
3
3
|
export interface OfflineRecoveryBranchOptions {
|
|
4
4
|
storePath: string;
|
|
5
5
|
agentName: string;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Preferred: Discord message that remains as the last visible anchor. On
|
|
8
|
+
* an agent's window that was presented (#291) the branch is cut at the
|
|
9
|
+
* write that presented the anchor, so rows stored after the anchor and
|
|
10
|
+
* before that write stay on the branch: those the window took after the
|
|
11
|
+
* anchor enter it again at the agent's next presentation point, after the
|
|
12
|
+
* anchor, and the rows that one write presented together with the anchor
|
|
13
|
+
* stay after it in the window. Only rows stored after the cut are removed
|
|
14
|
+
* and counted. A
|
|
15
|
+
* suppression may name any row the branch keeps that has a Discord
|
|
16
|
+
* message id, one the cut keeps after the anchor too; one without (an
|
|
17
|
+
* agent's round, a tool row) takes the live suppressMessages, by its row
|
|
18
|
+
* id. A recovery on that window that would change nothing (no
|
|
19
|
+
* row removed, none an arrival again, no suppression) is refused, as the
|
|
20
|
+
* live rollback refuses it.
|
|
21
|
+
*/
|
|
7
22
|
messageId?: string;
|
|
8
|
-
/** Exact internal ContextManager message ID that remains as the anchor. */
|
|
23
|
+
/** Exact internal ContextManager message ID that remains as the anchor (the cut as for `messageId`). */
|
|
9
24
|
contextId?: string;
|
|
10
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Backward-compatible alternative: remove the newest N context entries,
|
|
27
|
+
* counted in the agent's window once it was presented (#291), over the
|
|
28
|
+
* rows of its own slot, and in the record before that; the anchor is the
|
|
29
|
+
* entry before them, cut as for `messageId`.
|
|
30
|
+
*/
|
|
11
31
|
messages?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Remove every row a suppress rule hid (`metadata.suppressed`) on the new
|
|
34
|
+
* branch, which needs no anchor: the branch then starts from the newest row.
|
|
35
|
+
* For rolling back to a release that doesn't read the stamp, where a row
|
|
36
|
+
* hidden between messages a summary covers makes that summary non-contiguous,
|
|
37
|
+
* and the store is refused at open. The source branch keeps them. Once this
|
|
38
|
+
* release has made a window write of two or more rows (the first
|
|
39
|
+
* write-down of a window that holds a row, as at the first boot on a store
|
|
40
|
+
* with history, or a presentation of more than one row: MANIFEST version
|
|
41
|
+
* 2), no earlier release opens the store at all, and only a copy taken
|
|
42
|
+
* before the upgrade goes back.
|
|
43
|
+
*/
|
|
44
|
+
removeSuppressed?: boolean;
|
|
12
45
|
/** Exact Discord messages to suppress on the new branch. */
|
|
13
46
|
suppressMessageIds?: string[];
|
|
14
47
|
/** Inclusive context-order ranges between Discord message endpoints. */
|
|
@@ -38,6 +71,20 @@ export interface OfflineRecoveryBranchResult {
|
|
|
38
71
|
targetBranch: string;
|
|
39
72
|
messagesRemoved: number;
|
|
40
73
|
messagesSuppressed: number;
|
|
74
|
+
/**
|
|
75
|
+
* On a presented window (#291): the rows after the anchor in the agent's
|
|
76
|
+
* window that the cut keeps in the record (stored before the write that
|
|
77
|
+
* presented the anchor, presented after it), as the live rollback counts
|
|
78
|
+
* them, of the agent's own slot: the recovery reads that slot alone, so a
|
|
79
|
+
* row of a slot the agent observes (the residents' rows in a persistent
|
|
80
|
+
* subconscious's window), which the live rollback counts, isn't counted
|
|
81
|
+
* here, and the check of a cut that would change nothing doesn't see it. They leave the window as arrived and not presented, and enter it
|
|
82
|
+
* again at the agent's next presentation point, after the anchor. Not
|
|
83
|
+
* removed, so not counted in `messagesRemoved`, and not marked; a row the
|
|
84
|
+
* same recovery suppresses is counted there instead. 0 for a run with no
|
|
85
|
+
* anchor; absent on a window that is still the record.
|
|
86
|
+
*/
|
|
87
|
+
returnedToArrivals?: number;
|
|
41
88
|
/** Removed messages that carry a Discord address. */
|
|
42
89
|
discordAddressable: number;
|
|
43
90
|
/** The publication scope recorded for this recovery. */
|
|
@@ -63,9 +110,47 @@ export interface OfflineRecoveryBranchResult {
|
|
|
63
110
|
/**
|
|
64
111
|
* Create a safe Chronicle branch while the normal agent host is stopped.
|
|
65
112
|
*
|
|
66
|
-
* History is scanned in bounded windows and blobs are not re-inlined
|
|
67
|
-
*
|
|
68
|
-
* the
|
|
113
|
+
* History is scanned in bounded windows and blobs are not re-inlined, but a
|
|
114
|
+
* presented window (#291) is read whole where its order counts: for a
|
|
115
|
+
* `messages` count, and for the rows after the anchor that the cut returns
|
|
116
|
+
* to the arrivals or keeps (windowAfterCut). The affected messages are never
|
|
117
|
+
* compiled and their content is never written to the recovery outbox; only
|
|
118
|
+
* Discord addressing metadata leaves Chronicle.
|
|
69
119
|
*/
|
|
70
120
|
export declare function createOfflineRecoveryBranch(options: OfflineRecoveryBranchOptions): Promise<OfflineRecoveryBranchResult>;
|
|
121
|
+
/**
|
|
122
|
+
* Of the rows a no-op cut keeps after its anchor (`kept`), those holding a
|
|
123
|
+
* result of a call in a row of the agent's window at or before the anchor,
|
|
124
|
+
* which a suppression would leave without its result: a tool boundary
|
|
125
|
+
* presents a round's reply and its results in one write, and so does a
|
|
126
|
+
* write-down for rows stored together. With them, the earliest such call's
|
|
127
|
+
* row and the window row before it, where a cut keeps the call and its
|
|
128
|
+
* results together. Undefined where no kept row answers such a call, or the
|
|
129
|
+
* anchor isn't in `window`. The live rollback's refusal reads it too.
|
|
130
|
+
*/
|
|
131
|
+
export declare function resultsOfAnchoredCalls<R extends {
|
|
132
|
+
id: unknown;
|
|
133
|
+
content: readonly unknown[];
|
|
134
|
+
}>(window: readonly R[], anchorId: unknown, kept: readonly R[]): {
|
|
135
|
+
rows: R[];
|
|
136
|
+
call: R;
|
|
137
|
+
before?: R;
|
|
138
|
+
} | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* A refusal's advice for the kept rows that answer a call at or before the
|
|
141
|
+
* anchor (resultsOfAnchoredCalls): `verb` (anchor the recovery, roll back)
|
|
142
|
+
* before the call's row, naming the row before it (`to`: at, to), and why
|
|
143
|
+
* they aren't to be suppressed.
|
|
144
|
+
*/
|
|
145
|
+
export declare function anchorBefore(split: {
|
|
146
|
+
rows: ReadonlyArray<{
|
|
147
|
+
id: unknown;
|
|
148
|
+
}>;
|
|
149
|
+
call: {
|
|
150
|
+
id: unknown;
|
|
151
|
+
};
|
|
152
|
+
before?: {
|
|
153
|
+
id: unknown;
|
|
154
|
+
};
|
|
155
|
+
}, verb: string, to: string): string;
|
|
71
156
|
//# sourceMappingURL=offline-branch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offline-branch.d.ts","sourceRoot":"","sources":["../../../src/recovery/offline-branch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"offline-branch.d.ts","sourceRoot":"","sources":["../../../src/recovery/offline-branch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAI/D,OAAO,EAQL,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAEzB,MAAM,+BAA+B,CAAC;AAGvC,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wGAAwG;IACxG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;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