@animalabs/agent-framework 0.27.0 → 0.29.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 +145 -41
- package/dist/src/agent.d.ts +29 -2
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +73 -12
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/mcp-server-core.d.ts.map +1 -1
- package/dist/src/api/mcp-server-core.js +3 -12
- package/dist/src/api/mcp-server-core.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +11 -5
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/auto-continue.d.ts +5 -2
- package/dist/src/auto-continue.d.ts.map +1 -1
- package/dist/src/auto-continue.js +9 -5
- package/dist/src/auto-continue.js.map +1 -1
- package/dist/src/code-execution/isolate/runner.d.ts +7 -5
- package/dist/src/code-execution/isolate/runner.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/runner.js +7 -5
- package/dist/src/code-execution/isolate/runner.js.map +1 -1
- package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/scripts.js +3 -2
- package/dist/src/code-execution/isolate/scripts.js.map +1 -1
- package/dist/src/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 +468 -125
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +3651 -1111
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +133 -13
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +654 -59
- 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/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 +173 -2
- package/dist/src/gate/types.d.ts.map +1 -1
- package/dist/src/heartbeat/heartbeat.d.ts +202 -0
- package/dist/src/heartbeat/heartbeat.d.ts.map +1 -0
- package/dist/src/heartbeat/heartbeat.js +778 -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/held-writes.d.ts +3 -3
- package/dist/src/held-writes.js +3 -3
- package/dist/src/host-presentation.d.ts +170 -0
- package/dist/src/host-presentation.d.ts.map +1 -0
- package/dist/src/host-presentation.js +561 -0
- package/dist/src/host-presentation.js.map +1 -0
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/line-reader.d.ts +4 -0
- package/dist/src/line-reader.d.ts.map +1 -0
- package/dist/src/line-reader.js +59 -0
- package/dist/src/line-reader.js.map +1 -0
- package/dist/src/mcpl/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 +34 -6
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +133 -54
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
- package/dist/src/mcpl/conversation-router.js +2 -1
- package/dist/src/mcpl/conversation-router.js.map +1 -1
- package/dist/src/mcpl/convert-block.d.ts +1 -0
- package/dist/src/mcpl/convert-block.d.ts.map +1 -1
- package/dist/src/mcpl/convert-block.js +16 -4
- package/dist/src/mcpl/convert-block.js.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.js +4 -3
- package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
- package/dist/src/mcpl/inbound-source.d.ts +29 -11
- package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
- package/dist/src/mcpl/inbound-source.js +43 -70
- package/dist/src/mcpl/inbound-source.js.map +1 -1
- package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
- package/dist/src/mcpl/modern-connection.js +11 -7
- package/dist/src/mcpl/modern-connection.js.map +1 -1
- package/dist/src/mcpl/protocol-family.d.ts +3 -2
- package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
- package/dist/src/mcpl/protocol-family.js +25 -3
- package/dist/src/mcpl/protocol-family.js.map +1 -1
- package/dist/src/mcpl/push-handler.js +2 -2
- package/dist/src/mcpl/push-handler.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +12 -40
- package/dist/src/mcpl/references.d.ts.map +1 -1
- package/dist/src/mcpl/references.js +29 -23
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +18 -8
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +70 -30
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/skip-reply-wake.d.ts +25 -0
- package/dist/src/mcpl/skip-reply-wake.d.ts.map +1 -1
- package/dist/src/mcpl/skip-reply-wake.js +25 -0
- package/dist/src/mcpl/skip-reply-wake.js.map +1 -1
- package/dist/src/mcpl/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-presence.d.ts +66 -14
- package/dist/src/mcpl/tool-presence.d.ts.map +1 -1
- package/dist/src/mcpl/tool-presence.js +150 -80
- package/dist/src/mcpl/tool-presence.js.map +1 -1
- package/dist/src/mcpl/tool-signature.d.ts +10 -3
- package/dist/src/mcpl/tool-signature.d.ts.map +1 -1
- package/dist/src/mcpl/tool-signature.js +60 -30
- package/dist/src/mcpl/tool-signature.js.map +1 -1
- package/dist/src/mcpl/toolset-host.d.ts +88 -55
- package/dist/src/mcpl/toolset-host.d.ts.map +1 -1
- package/dist/src/mcpl/toolset-host.js +220 -111
- package/dist/src/mcpl/toolset-host.js.map +1 -1
- package/dist/src/mcpl/toolsets-module.d.ts +27 -35
- package/dist/src/mcpl/toolsets-module.d.ts.map +1 -1
- package/dist/src/mcpl/toolsets-module.js +313 -91
- package/dist/src/mcpl/toolsets-module.js.map +1 -1
- package/dist/src/mcpl/transport.d.ts +1 -1
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +16 -16
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +31 -13
- 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 +10 -8
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +15 -9
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/api/index.d.ts.map +1 -1
- package/dist/src/modules/api/index.js +4 -2
- package/dist/src/modules/api/index.js.map +1 -1
- package/dist/src/modules/discord/index.d.ts.map +1 -1
- package/dist/src/modules/discord/index.js +33 -25
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +30 -17
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/sender-name.d.ts +7 -0
- package/dist/src/modules/sender-name.d.ts.map +1 -0
- package/dist/src/modules/sender-name.js +10 -0
- package/dist/src/modules/sender-name.js.map +1 -0
- package/dist/src/modules/workspace/answers.d.ts +26 -0
- package/dist/src/modules/workspace/answers.d.ts.map +1 -0
- package/dist/src/modules/workspace/answers.js +138 -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 +3 -0
- package/dist/src/modules/workspace/direct-write.d.ts.map +1 -1
- package/dist/src/modules/workspace/direct-write.js +59 -24
- package/dist/src/modules/workspace/direct-write.js.map +1 -1
- 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 +2 -1
- package/dist/src/modules/workspace/edit-text.d.ts.map +1 -1
- package/dist/src/modules/workspace/edit-text.js +4 -2
- package/dist/src/modules/workspace/edit-text.js.map +1 -1
- package/dist/src/modules/workspace/effects.d.ts +4 -2
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/effects.js +67 -50
- package/dist/src/modules/workspace/effects.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +63 -51
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +980 -547
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +125 -82
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +465 -241
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/read-page.d.ts.map +1 -1
- package/dist/src/modules/workspace/read-page.js +7 -1
- package/dist/src/modules/workspace/read-page.js.map +1 -1
- package/dist/src/modules/workspace/reconcile.d.ts +7 -1
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +156 -50
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/modules/workspace/result-text.d.ts +1 -0
- package/dist/src/modules/workspace/result-text.d.ts.map +1 -1
- package/dist/src/modules/workspace/result-text.js.map +1 -1
- 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/types.d.ts +96 -43
- 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/notice-tags.d.ts +79 -0
- package/dist/src/notice-tags.d.ts.map +1 -0
- package/dist/src/notice-tags.js +83 -0
- package/dist/src/notice-tags.js.map +1 -0
- 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 +52 -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.js +1 -1
- package/dist/src/silent-heartbeat.d.ts +1 -53
- package/dist/src/silent-heartbeat.d.ts.map +1 -1
- package/dist/src/silent-heartbeat.js +56 -3
- package/dist/src/silent-heartbeat.js.map +1 -1
- package/dist/src/supplied-text.d.ts +35 -0
- package/dist/src/supplied-text.d.ts.map +1 -0
- package/dist/src/supplied-text.js +141 -0
- package/dist/src/supplied-text.js.map +1 -0
- package/dist/src/thinking-drops.d.ts +4 -11
- package/dist/src/thinking-drops.d.ts.map +1 -1
- package/dist/src/thinking-drops.js +7 -14
- package/dist/src/thinking-drops.js.map +1 -1
- 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 +39 -4
- package/dist/src/tool-args.js.map +1 -1
- package/dist/src/tool-image-ledger.d.ts.map +1 -1
- package/dist/src/tool-image-ledger.js +2 -1
- package/dist/src/tool-image-ledger.js.map +1 -1
- package/dist/src/tool-presentation.d.ts.map +1 -1
- package/dist/src/tool-presentation.js +5 -4
- package/dist/src/tool-presentation.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts +8 -4
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +23 -11
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +3 -2
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +24 -26
- 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 +63 -18
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +18 -8
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +58 -0
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +27 -13
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +34 -1
- package/dist/src/types/trace.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/agent.ts +76 -12
- package/src/api/mcp-server-core.ts +3 -14
- package/src/api/server.ts +11 -5
- package/src/auto-continue.ts +12 -5
- package/src/code-execution/isolate/runner.ts +7 -5
- package/src/code-execution/isolate/scripts.ts +3 -2
- package/src/cut-off-round.ts +98 -0
- package/src/framework.ts +3772 -1138
- package/src/gate/event-gate.ts +705 -60
- package/src/gate/index.ts +9 -1
- package/src/gate/reply-judge.ts +512 -0
- package/src/gate/types.ts +176 -3
- package/src/heartbeat/heartbeat.ts +843 -0
- package/src/heartbeat/reminder-time.ts +107 -0
- package/src/held-writes.ts +3 -3
- package/src/host-presentation.ts +605 -0
- package/src/index.ts +5 -1
- package/src/line-reader.ts +58 -0
- package/src/mcpl/capability-mask.ts +3 -2
- package/src/mcpl/channel-registry.ts +139 -53
- package/src/mcpl/conversation-router.ts +2 -1
- package/src/mcpl/convert-block.ts +17 -4
- package/src/mcpl/hook-orchestrator.ts +4 -3
- package/src/mcpl/inbound-source.ts +45 -70
- package/src/mcpl/modern-connection.ts +11 -7
- package/src/mcpl/protocol-family.ts +24 -3
- package/src/mcpl/push-handler.ts +2 -2
- package/src/mcpl/references.ts +31 -23
- package/src/mcpl/server-connection.ts +76 -34
- package/src/mcpl/skip-reply-wake.ts +35 -0
- package/src/mcpl/tags.ts +13 -2
- package/src/mcpl/tool-presence.ts +149 -82
- package/src/mcpl/tool-signature.ts +64 -32
- package/src/mcpl/toolset-host.ts +212 -110
- package/src/mcpl/toolsets-module.ts +277 -91
- package/src/mcpl/transport.ts +18 -14
- package/src/mcpl/types.ts +32 -13
- package/src/module-registry.ts +14 -9
- package/src/modules/api/index.ts +4 -2
- package/src/modules/discord/index.ts +37 -25
- package/src/modules/history/index.ts +30 -18
- package/src/modules/sender-name.ts +9 -0
- package/src/modules/workspace/answers.ts +151 -0
- package/src/modules/workspace/branch-intent.ts +10 -5
- package/src/modules/workspace/direct-write.ts +59 -23
- package/src/modules/workspace/disk-agreement.ts +52 -21
- package/src/modules/workspace/edit-text.ts +7 -5
- package/src/modules/workspace/effects.ts +69 -50
- package/src/modules/workspace/index.ts +966 -556
- package/src/modules/workspace/observe.ts +497 -242
- package/src/modules/workspace/read-page.ts +7 -1
- package/src/modules/workspace/reconcile.ts +184 -49
- package/src/modules/workspace/result-text.ts +2 -0
- package/src/modules/workspace/sync.ts +16 -0
- package/src/modules/workspace/types.ts +96 -43
- package/src/modules/workspace/watcher.ts +8 -3
- package/src/notice-tags.ts +84 -0
- package/src/prose-drafts.ts +4 -3
- package/src/reasoning-loss-notice.ts +64 -0
- package/src/reasoning-loss.ts +120 -0
- package/src/send-tools.ts +3 -2
- package/src/sent-rows.ts +1 -1
- package/src/silent-heartbeat.ts +4 -3
- package/src/supplied-text.ts +154 -0
- package/src/thinking-drops.ts +10 -16
- package/src/tool-args.ts +38 -4
- package/src/tool-image-ledger.ts +2 -1
- package/src/tool-presentation.ts +5 -4
- package/src/tool-result-guard.ts +26 -11
- package/src/tune-out/coordinator.ts +25 -27
- package/src/tune-out/tools.ts +4 -1
- package/src/types/agent.ts +63 -18
- package/src/types/events.ts +18 -8
- package/src/types/framework.ts +59 -0
- package/src/types/module.ts +28 -13
- package/src/types/trace.ts +36 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ThinkingLossIncidents } from './thinking-drops.js';
|
|
2
|
+
import { reasoningLossNotice, } from './reasoning-loss-notice.js';
|
|
3
|
+
const HEAD_CAUSES = {
|
|
4
|
+
tools: 'tools',
|
|
5
|
+
system: 'system',
|
|
6
|
+
model: 'model',
|
|
7
|
+
};
|
|
8
|
+
export class ReasoningLossTeller {
|
|
9
|
+
told = new Map();
|
|
10
|
+
drops = new ThinkingLossIncidents();
|
|
11
|
+
forStrip(agentName, branch, strip, turn, store) {
|
|
12
|
+
const told = this.toldFor(agentName, branch);
|
|
13
|
+
const taken = strip.newly
|
|
14
|
+
.map((id) => ({ id, sequence: store.getMessage(id)?.sequence }))
|
|
15
|
+
.sort((a, b) => (a.sequence ?? Infinity) - (b.sequence ?? Infinity));
|
|
16
|
+
const replies = taken.filter((r) => !told.has(r.id));
|
|
17
|
+
if (replies.length === 0)
|
|
18
|
+
return undefined;
|
|
19
|
+
const thisTurn = replies.some((r) => isThisTurn(r.sequence, branch, turn));
|
|
20
|
+
if (strip.cause === 'head') {
|
|
21
|
+
const causes = (strip.changed ?? [])
|
|
22
|
+
.map((c) => HEAD_CAUSES[c])
|
|
23
|
+
.filter((c) => c !== undefined);
|
|
24
|
+
const newest = taken.filter((r) => r.sequence !== undefined).at(-1);
|
|
25
|
+
const through = newest ? anchorOf(store.getMessage(newest.id)?.content) : undefined;
|
|
26
|
+
const amongThisTurn = taken.some((r) => isThisTurn(r.sequence, branch, turn));
|
|
27
|
+
for (const r of replies)
|
|
28
|
+
told.add(r.id);
|
|
29
|
+
return reasoningLossNotice({ agentName, scope: { kind: 'all', ...(through ? { through } : {}), thisTurn: amongThisTurn }, causes });
|
|
30
|
+
}
|
|
31
|
+
if (strip.cause !== 'first' && !taken.some((r) => isThisTurn(r.sequence, branch, turn)))
|
|
32
|
+
return undefined;
|
|
33
|
+
const first = anchorOf(store.getMessage(replies[0].id)?.content);
|
|
34
|
+
for (const r of replies)
|
|
35
|
+
told.add(r.id);
|
|
36
|
+
return reasoningLossNotice({
|
|
37
|
+
agentName,
|
|
38
|
+
scope: { kind: 'some', count: replies.length, ...(first ? { first } : {}), thisTurn },
|
|
39
|
+
causes: [],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
forDrops(agentName, branch, placed, turn, store) {
|
|
43
|
+
const replies = new Map();
|
|
44
|
+
const rounds = new Set();
|
|
45
|
+
let blocks = 0;
|
|
46
|
+
for (const drop of placed) {
|
|
47
|
+
if (drop.kind === 'unplaced')
|
|
48
|
+
continue;
|
|
49
|
+
blocks++;
|
|
50
|
+
if (drop.kind === 'round')
|
|
51
|
+
rounds.add(drop.round);
|
|
52
|
+
else
|
|
53
|
+
for (const body of drop.bodies)
|
|
54
|
+
replies.set(body.messageId, body.sequence);
|
|
55
|
+
}
|
|
56
|
+
const unplaced = blocks < placed.length;
|
|
57
|
+
const count = replies.size + rounds.size;
|
|
58
|
+
const ordered = [...replies].sort((a, b) => a[1] - b[1]);
|
|
59
|
+
const thisTurn = rounds.size > 0 || ordered.some(([, sequence]) => isThisTurn(sequence, branch, turn));
|
|
60
|
+
const first = ordered.length > 0 && !unplaced ? anchorOf(store.getMessage(ordered[0][0])?.content) : undefined;
|
|
61
|
+
if (this.drops.observe(agentName, blocks, branch) === undefined)
|
|
62
|
+
return undefined;
|
|
63
|
+
const told = this.toldFor(agentName, branch);
|
|
64
|
+
for (const id of replies.keys())
|
|
65
|
+
told.add(id);
|
|
66
|
+
return reasoningLossNotice({
|
|
67
|
+
agentName,
|
|
68
|
+
scope: { kind: 'some', count, ...(first ? { first } : {}), ...(unplaced ? { unplaced: true } : {}), thisTurn },
|
|
69
|
+
causes: [],
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
forget(agentName) {
|
|
73
|
+
this.told.delete(agentName);
|
|
74
|
+
this.drops.forget(agentName);
|
|
75
|
+
}
|
|
76
|
+
toldFor(agentName, branch) {
|
|
77
|
+
let branches = this.told.get(agentName);
|
|
78
|
+
if (!branches)
|
|
79
|
+
this.told.set(agentName, (branches = new Map()));
|
|
80
|
+
let told = branches.get(branch);
|
|
81
|
+
if (!told)
|
|
82
|
+
branches.set(branch, (told = new Set()));
|
|
83
|
+
return told;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function isThisTurn(sequence, branch, turn) {
|
|
87
|
+
return sequence !== undefined && turn.start?.branch === branch && sequence > turn.start.sequence;
|
|
88
|
+
}
|
|
89
|
+
function anchorOf(content) {
|
|
90
|
+
if (!content)
|
|
91
|
+
return undefined;
|
|
92
|
+
for (const block of content) {
|
|
93
|
+
if (block.type === 'text' && typeof block.text === 'string' && block.text.trim() !== '')
|
|
94
|
+
return { text: block.text };
|
|
95
|
+
}
|
|
96
|
+
for (const block of content) {
|
|
97
|
+
if (block.type === 'tool_use' && typeof block.name === 'string' && block.name !== '')
|
|
98
|
+
return { toolCall: block.name };
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=reasoning-loss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning-loss.js","sourceRoot":"","sources":["../../src/reasoning-loss.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAmB,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EACL,mBAAmB,GAGpB,MAAM,4BAA4B,CAAC;AAUpC,MAAM,WAAW,GAAuF;IACtG,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,OAAO,mBAAmB;IACb,IAAI,GAAG,IAAI,GAAG,EAAuC,CAAC;IACtD,KAAK,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAErD,QAAQ,CACN,SAAiB,EACjB,MAAc,EACd,KAAoB,EACpB,IAAuB,EACvB,KAAwB;QAExB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK;aACtB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;aAC/D,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC;QACvE,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACrD,IAAI,OAAO,CAAC,MAAM,KAAK,C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AC;QAC5B,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IACvH,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,EAAE;YAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IACxH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/src/send-tools.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Tools whose call delivers the resident's message to a channel or person,
|
|
3
3
|
* by bare name (an MCPL server's `<prefix>--` stripped). The framework reads
|
|
4
4
|
* a call of one as an explicit send that silences the round's auto-routed
|
|
5
|
-
* prose; the history module's semantic index reads
|
|
6
|
-
* what the resident wrote to someone, whether or not
|
|
5
|
+
* prose where it may have posted; the history module's semantic index reads
|
|
6
|
+
* its message argument as what the resident wrote to someone, whether or not
|
|
7
|
+
* it was delivered.
|
|
7
8
|
*/
|
|
8
9
|
export declare const SEND_TOOLS: Set<string>;
|
|
9
10
|
/** Strip the `server--` MCPL prefix from a tool name. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-tools.d.ts","sourceRoot":"","sources":["../../src/send-tools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"send-tools.d.ts","sourceRoot":"","sources":["../../src/send-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,aAA2E,CAAC;AAEnG,yDAAyD;AACzD,eAAO,MAAM,YAAY,MAAO,MAAM,KAAG,MAA8B,CAAC"}
|
package/dist/src/send-tools.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Tools whose call delivers the resident's message to a channel or person,
|
|
3
3
|
* by bare name (an MCPL server's `<prefix>--` stripped). The framework reads
|
|
4
4
|
* a call of one as an explicit send that silences the round's auto-routed
|
|
5
|
-
* prose; the history module's semantic index reads
|
|
6
|
-
* what the resident wrote to someone, whether or not
|
|
5
|
+
* prose where it may have posted; the history module's semantic index reads
|
|
6
|
+
* its message argument as what the resident wrote to someone, whether or not
|
|
7
|
+
* it was delivered.
|
|
7
8
|
*/
|
|
8
9
|
export const SEND_TOOLS = new Set(['channel_publish', 'send_message', 'reply_message', 'send_dm']);
|
|
9
10
|
/** Strip the `server--` MCPL prefix from a tool name. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-tools.js","sourceRoot":"","sources":["../../src/send-tools.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"send-tools.js","sourceRoot":"","sources":["../../src/send-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC;AAEnG,yDAAyD;AACzD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAG,CAAC"}
|
package/dist/src/sent-rows.js
CHANGED
|
@@ -133,7 +133,7 @@ export function roundRows(rows, carried) {
|
|
|
133
133
|
* the two alike (read from the provider on 2026-10-23: Haiku 5.5 with the drop control, on an enforcing API-key
|
|
134
134
|
* organization and on a subscription account, reported no drop for either, and dropped both replies' blocks when an
|
|
135
135
|
* earlier user message changed). The store's own fields beside them, such as
|
|
136
|
-
* `toolName`, don't reach the provider on membrane's native path, the only one noted (membrane 0.
|
|
136
|
+
* `toolName`, don't reach the provider on membrane's native path, the only one noted (membrane 0.8.0's XML
|
|
137
137
|
* formatter reads `toolName`, and an XML stream is never noted).
|
|
138
138
|
*/
|
|
139
139
|
function normalizedResult(block) {
|
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Request-only rows: user turns a request carries before a stored response
|
|
3
|
-
* that the store never holds, rendered again by every later compile.
|
|
4
|
-
*
|
|
5
|
-
* Two kinds exist, and both are anchored to the response they prompted:
|
|
6
|
-
*
|
|
7
|
-
* - A silent heartbeat tick stores no prompt row (#216): its reply is written
|
|
8
|
-
* straight after whatever the window held before it — often the previous
|
|
9
|
-
* assistant message, since a suppressed tick leaves no delivery receipt
|
|
10
|
-
* behind. Every row the tick's reply writes is stamped with
|
|
11
|
-
* `metadata.silentHeartbeat`, and a separator carrying the tick's
|
|
12
|
-
* instruction is rendered before the first of those rows that survives
|
|
13
|
-
* compilation. A context injection its start stores (stored-injections.ts)
|
|
14
|
-
* is unstamped: it's history the agent saw, not the tick's speech, so a
|
|
15
|
-
* policy that drops a tick's rows leaves it.
|
|
16
|
-
* - A compile that ends on the agent's own message gets a trailing
|
|
17
|
-
* `[Continue]` turn (some models reject a trailing assistant message). The
|
|
18
|
-
* reply it prompts is stored straight after that message, so the reply's
|
|
19
|
-
* rows are stamped `metadata.promptedBy` (`RequestOnlyPrompt`), and the turn
|
|
20
|
-
* is rendered before the first of them that survives. A reply follows the
|
|
21
|
-
* prompt when what it was sent ends on that `[Continue]`, or on the tool
|
|
22
|
-
* results of a reply that followed it (`toolLoopPrompt`), stored context
|
|
23
|
-
* injections after those results aside: a stream start and each round of
|
|
24
|
-
* a stream alike. A reply sent anything else after the results (a message
|
|
25
|
-
* that arrived meanwhile) follows that, and carries no prompt.
|
|
26
|
-
*
|
|
27
|
-
* Without the row, the wire formatter merges consecutive same-role messages:
|
|
28
|
-
* the reply would read as an unprompted continuation of the earlier response,
|
|
29
|
-
* and one assistant message would carry signed thinking from two separate
|
|
30
|
-
* responses (a provider 400 when it is the latest assistant message; see
|
|
31
|
-
* `Agent.addAssistantResponse`). And the request that minted the reply held
|
|
32
|
-
* the row: a provider that binds signed thinking to the prefix it was minted
|
|
33
|
-
* under (context-manager #155) refuses that thinking once a later request
|
|
34
|
-
* drops it. Each row's text is read from the stamp (what the request that
|
|
35
|
-
* minted the reply rendered, so a later change to the constant changes no
|
|
36
|
-
* stored reply's prefix) and its position is a function of the stamped rows
|
|
37
|
-
* alone, so every compile renders it in the same place (the request that
|
|
38
|
-
* minted the reply ends on that same turn), which keeps the prompt-cache
|
|
39
|
-
* prefix and the binding stable — unlike a per-compile injection that
|
|
40
|
-
* re-anchors to the newest user message, or a system prompt that changes for
|
|
41
|
-
* one turn.
|
|
42
|
-
*
|
|
43
|
-
* Known limit: compiled messages carry no store provenance, so a stored row
|
|
44
|
-
* is recognised only by structural identity the provider made unique
|
|
45
|
-
* (tool_use ids, thinking signatures). A reply with neither — unsigned and
|
|
46
|
-
* tool-free — gets no row and still merges as before. Without signed thinking
|
|
47
|
-
* that merge carries no provider-rejection risk; it is only a misreading.
|
|
48
|
-
* Reply text is deliberately never used as identity: identical replies ("all
|
|
49
|
-
* quiet") would collide, and an ordinary reply with the same text could take
|
|
50
|
-
* another reply's row and rewrite cached history. Exact matching for every
|
|
51
|
-
* row would need the compile result to expose each message's source rows.
|
|
52
|
-
*/
|
|
53
1
|
import type { ContentBlock, NormalizedMessage } from '@animalabs/membrane';
|
|
54
2
|
/** Request-only separator a silent tick's request ends on. It carries the
|
|
55
3
|
* tick's instruction, so the tick's own request reads it as its prompt, and
|
|
@@ -59,7 +7,7 @@ import type { ContentBlock, NormalizedMessage } from '@animalabs/membrane';
|
|
|
59
7
|
* this constant changes only ticks that open afterwards. */
|
|
60
8
|
export declare const SILENT_HEARTBEAT_SEPARATOR: string;
|
|
61
9
|
/** Request-only turn a compile that ends on the agent's own message gets. */
|
|
62
|
-
export declare const CONTINUE_ROW
|
|
10
|
+
export declare const CONTINUE_ROW: string;
|
|
63
11
|
/** Identity of one authenticated silent heartbeat tick. */
|
|
64
12
|
export interface SilentHeartbeatTick {
|
|
65
13
|
/** The MCPL push event that woke the tick. A broadcast tick reaches every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"silent-heartbeat.d.ts","sourceRoot":"","sources":["../../src/silent-heartbeat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"silent-heartbeat.d.ts","sourceRoot":"","sources":["../../src/silent-heartbeat.ts"],"names":[],"mappings":"AAqDA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE3E;;;;;4DAK4D;AAC5D,eAAO,MAAM,0BAA0B,QAEiF,CAAC;AAMzH,6EAA6E;AAC7E,eAAO,MAAM,YAAY,QAAsC,CAAC;AAEhE,2DAA2D;AAC3D,MAAM,WAAW,mBAAmB;IAClC;oCACgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;4BAM4B;AAC5B,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB;;iDAE6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;6DAC6D;AAC7D,wBAAgB,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAEzD;AAED,yDAAyD;AACzD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAOrF;AAED;;oEAEoE;AACpE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;sCAGsC;AACtC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAEF,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,iBAAiB,GAAG,SAAS,CAK7E;AAED,wBAAgB,4BAA4B,IAAI,iBAAiB,CAEhE;AAED,wBAAgB,YAAY,IAAI,iBAAiB,CAEhD;AA8BD,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC;;mCAE+B;IAC/B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD;6CACyC;IACzC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CACzC;AAED;;;yDAGyD;AACzD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,mBAAmB,CAiB7G;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,iBAAiB,GAAG,SAAS,EACnC,KAAK,EAAE,mBAAmB,GACzB,iBAAiB,GAAG,SAAS,CAQ/B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B;0DACsD;IACtD,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,KAAK,EAAE,mBAAmB,EAC1B,SAAS,EAAE,MAAM,GAChB,uBAAuB,CAsBzB"}
|
|
@@ -1,16 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request-only rows: user turns a request carries before a stored response
|
|
3
|
+
* that the store never holds, rendered again by every later compile.
|
|
4
|
+
*
|
|
5
|
+
* Two kinds exist, and both are anchored to the response they prompted:
|
|
6
|
+
*
|
|
7
|
+
* - A silent heartbeat tick stores no prompt row (#216): its reply is written
|
|
8
|
+
* straight after whatever the window held before it — often the previous
|
|
9
|
+
* assistant message, since a suppressed tick leaves no delivery receipt
|
|
10
|
+
* behind. Every row the tick's reply writes is stamped with
|
|
11
|
+
* `metadata.silentHeartbeat`, and a separator carrying the tick's
|
|
12
|
+
* instruction is rendered before the first of those rows that survives
|
|
13
|
+
* compilation. A context injection its start stores (stored-injections.ts)
|
|
14
|
+
* is unstamped: it's history the agent saw, not the tick's speech, so a
|
|
15
|
+
* policy that drops a tick's rows leaves it.
|
|
16
|
+
* - A compile that ends on the agent's own message gets a trailing
|
|
17
|
+
* `[Continue]` turn (some models reject a trailing assistant message). The
|
|
18
|
+
* reply it prompts is stored straight after that message, so the reply's
|
|
19
|
+
* rows are stamped `metadata.promptedBy` (`RequestOnlyPrompt`), and the turn
|
|
20
|
+
* is rendered before the first of them that survives. A reply follows the
|
|
21
|
+
* prompt when what it was sent ends on that `[Continue]`, or on the tool
|
|
22
|
+
* results of a reply that followed it (`toolLoopPrompt`), stored context
|
|
23
|
+
* injections after those results aside: a stream start and each round of
|
|
24
|
+
* a stream alike. A reply sent anything else after the results (a message
|
|
25
|
+
* that arrived meanwhile) follows that, and carries no prompt.
|
|
26
|
+
*
|
|
27
|
+
* Without the row, the wire formatter merges consecutive same-role messages:
|
|
28
|
+
* the reply would read as an unprompted continuation of the earlier response,
|
|
29
|
+
* and one assistant message would carry signed thinking from two separate
|
|
30
|
+
* responses (a provider 400 when it is the latest assistant message; see
|
|
31
|
+
* `Agent.addAssistantResponse`). And the request that minted the reply held
|
|
32
|
+
* the row: a provider that binds signed thinking to the prefix it was minted
|
|
33
|
+
* under (context-manager #155) refuses that thinking once a later request
|
|
34
|
+
* drops it. Each row's text is read from the stamp (what the request that
|
|
35
|
+
* minted the reply rendered, so a later change to the constant changes no
|
|
36
|
+
* stored reply's prefix) and its position is a function of the stamped rows
|
|
37
|
+
* alone, so every compile renders it in the same place (the request that
|
|
38
|
+
* minted the reply ends on that same turn), which keeps the prompt-cache
|
|
39
|
+
* prefix and the binding stable — unlike a per-compile injection that
|
|
40
|
+
* re-anchors to the newest user message, or a system prompt that changes for
|
|
41
|
+
* one turn.
|
|
42
|
+
*
|
|
43
|
+
* Known limit: compiled messages carry no store provenance, so a stored row
|
|
44
|
+
* is recognised only by structural identity the provider made unique
|
|
45
|
+
* (tool_use ids, thinking signatures). A reply with neither — unsigned and
|
|
46
|
+
* tool-free — gets no row and still merges as before. Without signed thinking
|
|
47
|
+
* that merge carries no provider-rejection risk; it is only a misreading.
|
|
48
|
+
* Reply text is deliberately never used as identity: identical replies ("all
|
|
49
|
+
* quiet") would collide, and an ordinary reply with the same text could take
|
|
50
|
+
* another reply's row and rewrite cached history. Exact matching for every
|
|
51
|
+
* row would need the compile result to expose each message's source rows.
|
|
52
|
+
*/
|
|
53
|
+
import { NOTICE_TAG } from './notice-tags.js';
|
|
1
54
|
/** Request-only separator a silent tick's request ends on. It carries the
|
|
2
55
|
* tick's instruction, so the tick's own request reads it as its prompt, and
|
|
3
56
|
* every later compile renders it again before the tick's first surviving row.
|
|
4
57
|
* Constant on purpose: it carries no time or id. Each tick's rows record the
|
|
5
58
|
* text their request rendered (`SilentHeartbeatStamp.separator`), so changing
|
|
6
59
|
* this constant changes only ticks that open afterwards. */
|
|
7
|
-
export const SILENT_HEARTBEAT_SEPARATOR =
|
|
60
|
+
export const SILENT_HEARTBEAT_SEPARATOR = `[${NOTICE_TAG.silentHeartbeat}] Scheduled private self-check. Review pending matters privately. ` +
|
|
8
61
|
'Do not narrate or publish plain prose; use an explicit send tool only if you deliberately choose to contact someone.';
|
|
9
62
|
/** The separator ticks rendered before their rows recorded its text: rows
|
|
10
63
|
* stamped without `separator` still render it, byte for byte. */
|
|
11
|
-
const LEGACY_SILENT_HEARTBEAT_SEPARATOR =
|
|
64
|
+
const LEGACY_SILENT_HEARTBEAT_SEPARATOR = `[${NOTICE_TAG.heartbeatTick}]`;
|
|
12
65
|
/** Request-only turn a compile that ends on the agent's own message gets. */
|
|
13
|
-
export const CONTINUE_ROW =
|
|
66
|
+
export const CONTINUE_ROW = `[${NOTICE_TAG.heartbeatContinue}]`;
|
|
14
67
|
/** One tick's key in an index or a rendered window: the server and its event
|
|
15
68
|
* id together, since two servers' events can share an id. */
|
|
16
69
|
export function tickKey(tick) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"silent-heartbeat.js","sourceRoot":"","sources":["../../src/silent-heartbeat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"silent-heartbeat.js","sourceRoot":"","sources":["../../src/silent-heartbeat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;;;;4DAK4D;AAC5D,MAAM,CAAC,MAAM,0BAA0B,GACrC,IAAI,UAAU,CAAC,eAAe,oEAAoE;IAClG,sHAAsH,CAAC;AAEzH;iEACiE;AACjE,MAAM,iCAAiC,GAAG,IAAI,UAAU,CAAC,aAAa,GAAG,CAAC;AAE1E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,UAAU,CAAC,iBAAiB,GAAG,CAAC;AA0BhE;6DAC6D;AAC7D,MAAM,UAAU,OAAO,CAAC,IAAyB;IAC/C,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,iBAAiB,CAAC,QAAiB;IACjD,MAAM,KAAK,GAAI,QAAsD,EAAE,eAAe,CAAC;IACvF,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS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C,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text the framework didn't write (what a participant or a server supplied),
|
|
3
|
+
* put beside structure of the framework's own: the reply judge's document,
|
|
4
|
+
* and notices the framework writes. A value that can end its line can start
|
|
5
|
+
* a line that reads as the framework's own.
|
|
6
|
+
*/
|
|
7
|
+
/** Text with each line break, in whatever form, as `\n`. */
|
|
8
|
+
export declare function normalizeLineBreaks(text: string): string;
|
|
9
|
+
/** A value kept to one line: each run of line breaks, in whatever form, as one
|
|
10
|
+
* space, so it can't end the line it's put in or start one of its own. */
|
|
11
|
+
export declare function oneLine(text: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Texts read as one string, joined by line breaks, with a backslash put
|
|
14
|
+
* before the bracket of each opening of a listed tag (NOTICE_TAG,
|
|
15
|
+
* CONTEXT_MANAGER_TAGS, MEMBRANE_TAGS) that hasn't one before it in its own
|
|
16
|
+
* text. A text `marks` says false of is read and never changed.
|
|
17
|
+
*
|
|
18
|
+
* Every opening, not only one that starts a line: membrane's XML formatter
|
|
19
|
+
* writes `participant: ` before each message, so the framework's own
|
|
20
|
+
* openings stand mid-line there too. It joins a message's text blocks with
|
|
21
|
+
* line breaks and sets its images apart from that text, while the native
|
|
22
|
+
* formatter sends each block on its own, so an opening split across a
|
|
23
|
+
* message's text blocks is one either way. In any case, by Unicode's case folding, and
|
|
24
|
+
* through whitespace, control and invisible characters anywhere inside the
|
|
25
|
+
* bracket, which a model reads past.
|
|
26
|
+
*/
|
|
27
|
+
export declare function markedTexts(texts: readonly string[], marks?: readonly boolean[]): string[];
|
|
28
|
+
export declare function markedText(text: string): string;
|
|
29
|
+
export declare function markNoticeOpenings<T extends object>(blocks: readonly T[], marks?: (index: number) => boolean): T[];
|
|
30
|
+
export declare function suppliedValue(value: unknown): string;
|
|
31
|
+
export declare function cutToFit(text: string, length: number): string;
|
|
32
|
+
export declare function showsAsItself(value: string): boolean;
|
|
33
|
+
export declare function quotedValue(value: unknown, space?: number): string;
|
|
34
|
+
export declare function nameToTypeBack(name: string): string;
|
|
35
|
+
//# sourceMappingURL=supplied-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supplied-text.d.ts","sourceRoot":"","sources":["../../src/supplied-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,4DAA4D;AAC5D,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;2EAC2E;AAC3E,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,GAAE,SAAS,OAAO,EAAO,GAAG,MAAM,EAAE,CAe9F;AAyBD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAoB,GAAG,CAAC,EAAE,CAa9H;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAc7D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAElE;AAgBD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text the framework didn't write (what a participant or a server supplied),
|
|
3
|
+
* put beside structure of the framework's own: the reply judge's document,
|
|
4
|
+
* and notices the framework writes. A value that can end its line can start
|
|
5
|
+
* a line that reads as the framework's own.
|
|
6
|
+
*/
|
|
7
|
+
import { CONTEXT_MANAGER_TAGS, MEMBRANE_TAGS, NOTICE_TAG } from './notice-tags.js';
|
|
8
|
+
/** Every form of line break a reader might take for one: CR LF, CR, LF,
|
|
9
|
+
* vertical tab, form feed, NEL, and the Unicode line and paragraph separators. */
|
|
10
|
+
const LINE_BREAK = /\r\n|[\r\n\u000b\u000c\u0085\u2028\u2029]/g;
|
|
11
|
+
/** Text with each line break, in whatever form, as `\n`. */
|
|
12
|
+
export function normalizeLineBreaks(text) {
|
|
13
|
+
return text.replace(LINE_BREAK, '\n');
|
|
14
|
+
}
|
|
15
|
+
/** A value kept to one line: each run of line breaks, in whatever form, as one
|
|
16
|
+
* space, so it can't end the line it's put in or start one of its own. */
|
|
17
|
+
export function oneLine(text) {
|
|
18
|
+
return normalizeLineBreaks(text).replace(/\n+/g, ' ');
|
|
19
|
+
}
|
|
20
|
+
const INVISIBLE = '\\p{Cf}\\p{Default_Ignorable_Code_Point}';
|
|
21
|
+
const SKIPPED = `[\\s\\p{Cc}${INVISIBLE}]`;
|
|
22
|
+
const tagWord = (word) => [...word].map((c) => (/[\\^$.*+?()[\]{}|/]/.test(c) ? `\\${c}` : c)).join(`${SKIPPED}*`);
|
|
23
|
+
const NOTICE_OPENING = new RegExp(`\\[(?=${SKIPPED}*(?:${[...Object.values(NOTICE_TAG), ...CONTEXT_MANAGER_TAGS, ...MEMBRANE_TAGS].map((tag) => tag.split(' ').map(tagWord).join(`${SKIPPED}+`)).join('|')})(?![\\p{L}\\p{N}]))`, 'giu');
|
|
24
|
+
/**
|
|
25
|
+
* Texts read as one string, joined by line breaks, with a backslash put
|
|
26
|
+
* before the bracket of each opening of a listed tag (NOTICE_TAG,
|
|
27
|
+
* CONTEXT_MANAGER_TAGS, MEMBRANE_TAGS) that hasn't one before it in its own
|
|
28
|
+
* text. A text `marks` says false of is read and never changed.
|
|
29
|
+
*
|
|
30
|
+
* Every opening, not only one that starts a line: membrane's XML formatter
|
|
31
|
+
* writes `participant: ` before each message, so the framework's own
|
|
32
|
+
* openings stand mid-line there too. It joins a message's text blocks with
|
|
33
|
+
* line breaks and sets its images apart from that text, while the native
|
|
34
|
+
* formatter sends each block on its own, so an opening split across a
|
|
35
|
+
* message's text blocks is one either way. In any case, by Unicode's case folding, and
|
|
36
|
+
* through whitespace, control and invisible characters anywhere inside the
|
|
37
|
+
* bracket, which a model reads past.
|
|
38
|
+
*/
|
|
39
|
+
export function markedTexts(texts, marks = []) {
|
|
40
|
+
const starts = [];
|
|
41
|
+
let at = 0;
|
|
42
|
+
for (const text of texts) {
|
|
43
|
+
starts.push(at);
|
|
44
|
+
at += text.length + 1;
|
|
45
|
+
}
|
|
46
|
+
const offsets = texts.map(() => []);
|
|
47
|
+
for (const match of texts.join('\n').matchAll(NOTICE_OPENING)) {
|
|
48
|
+
let holder = texts.length - 1;
|
|
49
|
+
while (starts[holder] > match.index)
|
|
50
|
+
holder--;
|
|
51
|
+
const offset = match.index - starts[holder];
|
|
52
|
+
if (marks[holder] !== false && texts[holder][offset - 1] !== '\\')
|
|
53
|
+
offsets[holder].push(offset);
|
|
54
|
+
}
|
|
55
|
+
return texts.map((text, i) => withMarks(text, offsets[i]));
|
|
56
|
+
}
|
|
57
|
+
function withMarks(text, offsets) {
|
|
58
|
+
let marked = '';
|
|
59
|
+
let from = 0;
|
|
60
|
+
for (const offset of offsets) {
|
|
61
|
+
marked += `${text.slice(from, offset)}\\`;
|
|
62
|
+
from = offset;
|
|
63
|
+
}
|
|
64
|
+
return marked + text.slice(from);
|
|
65
|
+
}
|
|
66
|
+
function closedWithin(text, at) {
|
|
67
|
+
let depth = 0;
|
|
68
|
+
for (let i = at; i < text.length; i++) {
|
|
69
|
+
if (text[i] === '[')
|
|
70
|
+
depth++;
|
|
71
|
+
else if (text[i] === ']' && --depth === 0)
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
function unmarkedOpenings(text) {
|
|
77
|
+
return [...text.matchAll(NOTICE_OPENING)].map((match) => match.index).filter((at) => text[at - 1] !== '\\');
|
|
78
|
+
}
|
|
79
|
+
export function markedText(text) {
|
|
80
|
+
return markedTexts([text])[0];
|
|
81
|
+
}
|
|
82
|
+
export function markNoticeOpenings(blocks, marks = () => true) {
|
|
83
|
+
const at = [];
|
|
84
|
+
blocks.forEach((block, index) => {
|
|
85
|
+
const { type, text } = (block ?? {});
|
|
86
|
+
if (type === 'text' && typeof text === 'string')
|
|
87
|
+
at.push(index);
|
|
88
|
+
});
|
|
89
|
+
const textOf = (index) => blocks[index].text;
|
|
90
|
+
const marked = markedTexts(at.map(textOf), at.map(marks));
|
|
91
|
+
const out = [...blocks];
|
|
92
|
+
at.forEach((index, i) => {
|
|
93
|
+
if (marked[i] !== textOf(index))
|
|
94
|
+
out[index] = { ...blocks[index], text: marked[i] };
|
|
95
|
+
});
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
export function suppliedValue(value) {
|
|
99
|
+
return markedText(oneLine(String(value)));
|
|
100
|
+
}
|
|
101
|
+
export function cutToFit(text, length) {
|
|
102
|
+
let end = Math.max(0, Math.floor(length));
|
|
103
|
+
if (end >= text.length)
|
|
104
|
+
return text;
|
|
105
|
+
for (;;) {
|
|
106
|
+
const last = text.charCodeAt(end - 1);
|
|
107
|
+
if (end < text.length && last >= 0xd800 && last <= 0xdbff)
|
|
108
|
+
end--;
|
|
109
|
+
else if (text[end - 1] === '\\' && text[end] === '[')
|
|
110
|
+
end--;
|
|
111
|
+
else {
|
|
112
|
+
const cut = text.slice(0, end);
|
|
113
|
+
const open = unmarkedOpenings(cut).find((at) => !closedWithin(cut, at));
|
|
114
|
+
if (open === undefined)
|
|
115
|
+
return cut;
|
|
116
|
+
end = open;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export function showsAsItself(value) {
|
|
121
|
+
return value !== '' && suppliedValue(value) === value && value.isWellFormed() && !EDGE_OR_QUOTE.test(value);
|
|
122
|
+
}
|
|
123
|
+
const EDGE_OR_QUOTE = /^\s|\s$|["\\]/;
|
|
124
|
+
export function quotedValue(value, space) {
|
|
125
|
+
return (JSON.stringify(value, null, space) ?? 'null').replace(/"(?:[^"\\]|\\.)*"/g, (literal) => quotedString(JSON.parse(literal)));
|
|
126
|
+
}
|
|
127
|
+
function quotedString(text) {
|
|
128
|
+
let quoted = '';
|
|
129
|
+
let from = 0;
|
|
130
|
+
for (const match of text.matchAll(NOTICE_OPENING)) {
|
|
131
|
+
quoted += `${jsonText(text.slice(from, match.index))}\\u005b`;
|
|
132
|
+
from = match.index + 1;
|
|
133
|
+
}
|
|
134
|
+
return `"${quoted}${jsonText(text.slice(from))}"`;
|
|
135
|
+
}
|
|
136
|
+
// JSON.stringify leaves NEL, U+2028 and U+2029 as they are.
|
|
137
|
+
const jsonText = (text) => JSON.stringify(text).slice(1, -1).replace(/[\u0085\u2028\u2029]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`);
|
|
138
|
+
export function nameToTypeBack(name) {
|
|
139
|
+
return showsAsItself(name) ? name : quotedValue(name);
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=supplied-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supplied-text.js","sourceRoot":"","sources":["../../src/supplied-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnF;mFACmF;AACn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,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC;QAC9D,IAAI,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;AACpD,CAAC;AAED,4DAA4D;AAC5D,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAU,EAAE,CACxC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAEnI,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -37,10 +37,11 @@ export interface CompiledForRequest {
|
|
|
37
37
|
provenance?: CompileProvenance;
|
|
38
38
|
recordedAfter?: number;
|
|
39
39
|
}
|
|
40
|
-
/** What a stream's driver reads a call's dropped blocks against (`StartStreamResult`'s
|
|
40
|
+
/** What a stream's driver reads a call's dropped blocks against (`StartStreamResult`'s fields, together). */
|
|
41
41
|
export interface StreamThinkingDrops {
|
|
42
42
|
place: (entries: readonly ThinkingBindingEntry[]) => PlacedDrop[];
|
|
43
43
|
recordedAfter?: number;
|
|
44
|
+
branch?: string;
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
47
|
* Place each dropped entry of one call. membrane places a block by the request's message and the block's
|
|
@@ -63,18 +64,10 @@ export declare function splitThinkingDrops(placed: readonly PlacedDrop[], record
|
|
|
63
64
|
expected: PlacedDrop[];
|
|
64
65
|
unexpected: PlacedDrop[];
|
|
65
66
|
};
|
|
66
|
-
/**
|
|
67
|
-
* When an agent's unexpected drops call for an operator alert: at the first call that shows any, and again only
|
|
68
|
-
* when a call shows more than the alert last counted. Each call of a stream, and each stream until a strip takes
|
|
69
|
-
* them out, drops the same blocks again, so an unchanged count isn't news. A call that shows no unexpected drop, its
|
|
70
|
-
* report empty, absent or naming only expected ones, ends the incident: the blocks it counted no longer drop. The next
|
|
71
|
-
* one alerts afresh. It's held in memory, so a restart mid-incident alerts once more, and an agent's removal ends its
|
|
72
|
-
* incident (`forget`).
|
|
73
|
-
*/
|
|
74
67
|
export declare class ThinkingLossIncidents {
|
|
75
68
|
private readonly alerted;
|
|
76
|
-
/** A call's report of `
|
|
77
|
-
observe(agent: string,
|
|
69
|
+
/** A call's report of `count` drops for `agent` in `scope`: the count to alert with, or undefined for no alert. */
|
|
70
|
+
observe(agent: string, count: number, scope?: string): number | undefined;
|
|
78
71
|
/** The agent is gone: its incident, if one is open, ends with it. */
|
|
79
72
|
forget(agent: string): void;
|
|
80
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking-drops.d.ts","sourceRoot":"","sources":["../../src/thinking-drops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,SAAS,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,KAAK,EAAE,oBAAoB,CAAA;CAAE,GACzG;IAAE,IAAI,EAAE,OAAO,CA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oBAAoB,EAAE,KAAK,UAAU,EAAE,CAAC;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAUD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,SAAS,oBAAoB,EAAE,EACxC,IAAI,EAAE,SAAS,iBAAiB,EAAE,EAClC,QAAQ,EAAE,kBAAkB,GAC3B,UAAU,EAAE,CA+Bd;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,aAAa,EAAE,MAAM,GACpB;IAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAAC,UAAU,EAAE,UAAU,EAAE,CAAA;CAAE,CAQtD;AAKD,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmE;IAE3F,mHAAmH;IACnH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASxE;IAED,qEAAqE;IACrE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE1B;CACF"}
|
|
@@ -74,26 +74,19 @@ export function splitThinkingDrops(placed, recordedAfter) {
|
|
|
74
74
|
}
|
|
75
75
|
/** Binding failures the context manager's record doesn't track: the account's, not the conversation's. */
|
|
76
76
|
const UNTRACKED_REASONS = new Set(['organization_binding_mismatch', 'end_user_binding_mismatch']);
|
|
77
|
-
/**
|
|
78
|
-
* When an agent's unexpected drops call for an operator alert: at the first call that shows any, and again only
|
|
79
|
-
* when a call shows more than the alert last counted. Each call of a stream, and each stream until a strip takes
|
|
80
|
-
* them out, drops the same blocks again, so an unchanged count isn't news. A call that shows no unexpected drop, its
|
|
81
|
-
* report empty, absent or naming only expected ones, ends the incident: the blocks it counted no longer drop. The next
|
|
82
|
-
* one alerts afresh. It's held in memory, so a restart mid-incident alerts once more, and an agent's removal ends its
|
|
83
|
-
* incident (`forget`).
|
|
84
|
-
*/
|
|
85
77
|
export class ThinkingLossIncidents {
|
|
86
78
|
alerted = new Map();
|
|
87
|
-
/** A call's report of `
|
|
88
|
-
observe(agent,
|
|
89
|
-
|
|
79
|
+
/** A call's report of `count` drops for `agent` in `scope`: the count to alert with, or undefined for no alert. */
|
|
80
|
+
observe(agent, count, scope) {
|
|
81
|
+
const open = this.alerted.get(agent);
|
|
82
|
+
if (count === 0) {
|
|
90
83
|
this.alerted.delete(agent);
|
|
91
84
|
return undefined;
|
|
92
85
|
}
|
|
93
|
-
if (
|
|
86
|
+
if (open && open.scope === scope && count <= open.count)
|
|
94
87
|
return undefined;
|
|
95
|
-
this.alerted.set(agent,
|
|
96
|
-
return
|
|
88
|
+
this.alerted.set(agent, { count, scope });
|
|
89
|
+
return count;
|
|
97
90
|
}
|
|
98
91
|
/** The agent is gone: its incident, if one is open, ends with it. */
|
|
99
92
|
forget(agent) {
|