@nomadop/session-watcher-dsh 0.11.1 → 0.11.2

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/dist/client.js CHANGED
@@ -175,6 +175,7 @@ var en = {
175
175
  "monitor.warning.verbatim-recall": "Read target includes verbatim text carried by compaction",
176
176
  "monitor.warning.handoff-recall": "Direct handoff payload read",
177
177
  "monitor.warning.carrier-recall": "Direct compaction carrier read",
178
+ "monitor.warning.old-attribution": "High share of old attribution in file reads",
178
179
  "monitor.filter.collapseAll": "Collapse all",
179
180
  "monitor.filter.empty": "No events match the filter",
180
181
  "monitor.object.attempt": "Segment #{epoch} Compaction #{ordinal}",
@@ -379,6 +380,22 @@ var en = {
379
380
  "monitor.slot.earlier": "Earlier original source (not received by the call)",
380
381
  "monitor.slot.noBlocks": "This event has no content blocks.",
381
382
  "monitor.slot.raw": "Raw JSON",
383
+ "monitor.slotPage.tools": "Tools",
384
+ "monitor.tool.input": "Input",
385
+ "monitor.tool.output": "Output",
386
+ "monitor.tool.noInput": "Input not recorded",
387
+ "monitor.tool.noResult": "Result not recorded",
388
+ "monitor.tool.emptyResult": "Result is empty",
389
+ "monitor.tool.failed": "Tool failed",
390
+ "monitor.tool.pruned": "The summary call saw the pruned version",
391
+ "monitor.tool.openPruned": "Open event {seq} in Source text",
392
+ "monitor.tool.stateQuery": "State query",
393
+ "monitor.tool.stateWrite": "State write",
394
+ "monitor.tool.attempt.handoff-recall": "Attempted a direct read of the handoff payload",
395
+ "monitor.tool.attempt.carrier-recall": "Attempted a direct read of the compaction carrier",
396
+ "monitor.tool.attempt.verbatim-recall": "Attempted a read-back: the target includes verbatim text carried by compaction",
397
+ "monitor.tool.oldAttribution": "{label} \xB7 {percent} (old {oldLines} lines, new {newLines} lines)",
398
+ "monitor.tool.oldNote": `"Old" means attributed before the step began, which is not necessarily text still in the model's context.`,
382
399
  "monitor.overview.status": "Status",
383
400
  "monitor.overview.payback": "Payback progress",
384
401
  "monitor.overview.callState": "Call",
@@ -419,7 +436,6 @@ var en = {
419
436
  "monitor.drawer.settlement": "Compaction settlement of segment #{epoch}",
420
437
  "monitor.settlement.current.through": "Through step {step}",
421
438
  "monitor.settlement.current.empty": "No compactions have committed in this segment.",
422
- "monitor.settlement.current.pending": "Awaiting measurement: no compaction has complete readings yet.",
423
439
  "monitor.settlement.current.partial": "Awaiting measurement: totals include only compactions with complete readings.",
424
440
  "monitor.settlement.current.stockUnavailable": "This snapshot does not have enough call readings to draw the input stock chart.",
425
441
  "monitor.settlement.count": "Compactions {count}",
@@ -436,7 +452,8 @@ var en = {
436
452
  "monitor.settlement.payback.title": "Saved as a share of cost",
437
453
  "monitor.settlement.unit": "Unit: read-price tokens, converted at the cache write-to-read price ratio of this session; not a bill.",
438
454
  "monitor.settlement.recall.pending": "Loading recall adjustments\u2026",
439
- "monitor.settlement.recall.unavailable": "Could not load the settlement detail. Showing unadjusted estimates.",
455
+ "monitor.settlement.recall.unavailable": "Recall-adjusted settlement is unavailable.",
456
+ "monitor.settlement.recall.unpriced": "Awaiting measurement: no compaction has complete readings yet.",
440
457
  "monitor.settlement.recall.partial": "Some recall adjustments could not be calculated.",
441
458
  "monitor.handoffPage.overview": "Overview",
442
459
  "monitor.handoffPage.summary": "Summary",
@@ -529,9 +546,6 @@ var en = {
529
546
  "monitor.context.legend.assumption": "Assumes growth is unchanged apart from the seals",
530
547
  "monitor.context.note": "Note",
531
548
  "monitor.context.note.line": 'Deepening line: the input stock position fitted from the measurements at the end of this segment; once the actual stock passes it, the segment is in the "Deepening" zone.',
532
- "monitor.context.cache": "Cache rebuild",
533
- "monitor.context.cache.share": "Cache rebuild share of cost",
534
- "monitor.context.cache.net": "Net",
535
549
  "monitor.context.cache.slider": "Rebuild overpay",
536
550
  "monitor.context.cache.read.actual": "Rebuild overpay counted as it is",
537
551
  "monitor.context.cache.read.none": "Rebuild overpay not counted",
@@ -547,6 +561,42 @@ var en = {
547
561
  "monitor.context.cache.rows.share": "Share",
548
562
  "monitor.context.cache.row.label": "Compaction #{ordinal}, rebuild overpay {rebuild}, share {share}, go to call {at} on the chart",
549
563
  "monitor.context.cache.row.labelNone": "Compaction #{ordinal}, no data, go to call {at} on the chart",
564
+ "monitor.recall.name.user": "User message",
565
+ "monitor.recall.name.assistant": "Assistant message",
566
+ "monitor.recall.name.toolResult": "Tool result",
567
+ "monitor.recall.name.toolCall": "Tool call",
568
+ "monitor.recall.name.system": "System message",
569
+ "monitor.recall.name.developer": "Developer message",
570
+ "monitor.recall.row.label": "Event #{seq} {name}, read back in {count} steps",
571
+ "monitor.recall.title": "Event #{seq} {name}",
572
+ "monitor.recall.landing.zero": "Original at step {at} (#0, before the first seal)",
573
+ "monitor.recall.landing.at": "Original at step {at} (#{zone})",
574
+ "monitor.recall.landing.unknown": "Original position unknown",
575
+ "monitor.recall.read": "Step {at}",
576
+ "monitor.recall.heading": "Recall targets",
577
+ "monitor.recall.count": "{count} targets",
578
+ "monitor.recall.repeated": "{count} read after more than one seal",
579
+ "monitor.recall.none": "No recall target observed",
580
+ "monitor.recall.row.count": "Read back in {count} steps",
581
+ "monitor.recall.legend.original": "Original",
582
+ "monitor.recall.legend.read": "Read back",
583
+ "monitor.recall.legend.seal": "Seal",
584
+ "monitor.recall.legend.zero": "#0 before the first seal",
585
+ "monitor.recall.reads": "Steps that read this event",
586
+ "monitor.recall.read.call": "Step {at}, go to call {call} on the chart",
587
+ "monitor.recall.text.loading": "Loading the text\u2026",
588
+ "monitor.recall.text.failed": "Could not read the text: {message}",
589
+ "monitor.recall.text.none": "This event has no text.",
590
+ "monitor.recall.text.expand": "Show the whole text ({count} characters)",
591
+ "monitor.recall.text.collapse": "Show the excerpt",
592
+ "monitor.context.comp": "Settlement cost",
593
+ "monitor.context.comp.total": "Total {value}",
594
+ "monitor.context.comp.summary": "Compaction summaries",
595
+ "monitor.context.comp.rebuild": "Cache rebuild",
596
+ "monitor.context.comp.recall": "Recall requests, net",
597
+ "monitor.context.trial": "Rebuild overpay trial",
598
+ "monitor.payback.share": "Pure recall steps {percent} ({pure} of {judged})",
599
+ "monitor.payback.share.none": "Pure recall step share \u2014",
550
600
  "monitor.handoff.overview.type": "Type",
551
601
  "monitor.handoff.overview.token": "Handoff code",
552
602
  "monitor.handoff.overview.createdAt": "Prepared at",
@@ -694,6 +744,7 @@ var zh = {
694
744
  "monitor.warning.verbatim-recall": "\u56DE\u8BFB\u76EE\u6807\u542B\u5C01\u5B58\u5DF2\u643A\u5E26\u7684\u539F\u6587",
695
745
  "monitor.warning.handoff-recall": "\u76F4\u8BFB\u4EA4\u63A5\u8F7D\u8377",
696
746
  "monitor.warning.carrier-recall": "\u76F4\u8BFB\u538B\u7F29\u8F7D\u4F53",
747
+ "monitor.warning.old-attribution": "\u6587\u4EF6\u8BFB\u53D6\u7684\u65E7\u5F52\u56E0\u5360\u6BD4\u9AD8",
697
748
  "monitor.filter.collapseAll": "\u5168\u90E8\u6298\u53E0",
698
749
  "monitor.filter.empty": "\u6CA1\u6709\u7B26\u5408\u7B5B\u9009\u6761\u4EF6\u7684\u4E8B\u4EF6",
699
750
  "monitor.object.attempt": "\u5206\u6BB5 #{epoch} \u538B\u7F29 #{ordinal}",
@@ -898,6 +949,22 @@ var zh = {
898
949
  "monitor.slot.earlier": "\u66F4\u65E9\u7684\u539F\u59CB\u6765\u6E90\uFF08\u8C03\u7528\u672A\u6536\u5230\uFF09",
899
950
  "monitor.slot.noBlocks": "\u6B64\u4E8B\u4EF6\u6CA1\u6709\u5185\u5BB9\u5757\u3002",
900
951
  "monitor.slot.raw": "\u539F\u59CB JSON",
952
+ "monitor.slotPage.tools": "\u5DE5\u5177",
953
+ "monitor.tool.input": "\u8F93\u5165",
954
+ "monitor.tool.output": "\u8F93\u51FA",
955
+ "monitor.tool.noInput": "\u672A\u8BB0\u5F55\u8F93\u5165",
956
+ "monitor.tool.noResult": "\u672A\u8BB0\u5F55\u7ED3\u679C",
957
+ "monitor.tool.emptyResult": "\u7ED3\u679C\u4E3A\u7A7A",
958
+ "monitor.tool.failed": "\u5DE5\u5177\u5931\u8D25",
959
+ "monitor.tool.pruned": "\u538B\u7F29\u6240\u89C1\u4E3A\u526A\u679D\u7248",
960
+ "monitor.tool.openPruned": "\u5728\u539F\u6587\u4E2D\u6253\u5F00\u4E8B\u4EF6 {seq}",
961
+ "monitor.tool.stateQuery": "\u72B6\u6001\u67E5\u8BE2",
962
+ "monitor.tool.stateWrite": "\u72B6\u6001\u5199\u5165",
963
+ "monitor.tool.attempt.handoff-recall": "\u5C1D\u8BD5\u76F4\u8BFB\u4EA4\u63A5\u8F7D\u8377",
964
+ "monitor.tool.attempt.carrier-recall": "\u5C1D\u8BD5\u76F4\u8BFB\u538B\u7F29\u8F7D\u4F53",
965
+ "monitor.tool.attempt.verbatim-recall": "\u5C1D\u8BD5\u56DE\u8BFB\uFF1A\u76EE\u6807\u542B\u5C01\u5B58\u5DF2\u643A\u5E26\u7684\u539F\u6587",
966
+ "monitor.tool.oldAttribution": "{label} \xB7 {percent}\uFF08\u65E7 {oldLines} \u884C\uFF0C\u65B0 {newLines} \u884C\uFF09",
967
+ "monitor.tool.oldNote": "\u201C\u65E7\u201D\u6307\u8BE5\u6B65\u5F00\u59CB\u524D\u5DF2\u88AB\u5F52\u56E0\uFF0C\u4E0D\u4E00\u5B9A\u4ECD\u662F\u6A21\u578B\u5F53\u524D\u4E0A\u4E0B\u6587\u4E2D\u7684\u6587\u672C\u3002",
901
968
  "monitor.overview.status": "\u72B6\u6001",
902
969
  "monitor.overview.payback": "\u56DE\u672C\u8FDB\u5EA6",
903
970
  "monitor.overview.callState": "\u8C03\u7528",
@@ -938,7 +1005,6 @@ var zh = {
938
1005
  "monitor.drawer.settlement": "\u5206\u6BB5#{epoch}\u538B\u7F29\u7ED3\u7B97",
939
1006
  "monitor.settlement.current.through": "\u622A\u81F3\u7B2C {step} \u6B65",
940
1007
  "monitor.settlement.current.empty": "\u672C\u6BB5\u6682\u65E0\u5DF2\u63D0\u4EA4\u7684\u538B\u7F29",
941
- "monitor.settlement.current.pending": "\u5F85\u6D4B\u91CF\uFF1A\u672C\u6BB5\u8FD8\u6CA1\u6709\u8BFB\u6570\u5B8C\u6574\u7684\u538B\u7F29\u3002",
942
1008
  "monitor.settlement.current.partial": "\u90E8\u5206\u538B\u7F29\u5F85\u6D4B\u91CF\uFF1B\u5408\u8BA1\u4EC5\u7EB3\u5165\u8BFB\u6570\u5B8C\u6574\u7684\u538B\u7F29\u3002",
943
1009
  "monitor.settlement.current.stockUnavailable": "\u6B64\u5FEB\u7167\u7684\u8C03\u7528\u8BFB\u6570\u4E0D\u8DB3\uFF0C\u65E0\u6CD5\u7ED8\u5236\u8F93\u5165\u5B58\u91CF\u56FE\u3002",
944
1010
  "monitor.settlement.count": "\u538B\u7F29 {count} \u6B21",
@@ -955,7 +1021,8 @@ var zh = {
955
1021
  "monitor.settlement.payback.title": "\u8282\u7701\u5360\u6210\u672C\u7684\u6BD4\u4F8B",
956
1022
  "monitor.settlement.unit": "\u5355\u4F4D\uFF1A\u8BFB\u4EF7 token\uFF0C\u6309\u672C\u4F1A\u8BDD\u7684\u7F13\u5B58\u5199\u8BFB\u4EF7\u6BD4\u6298\u7B97\uFF0C\u4E0D\u662F\u8D26\u5355\u3002",
957
1023
  "monitor.settlement.recall.pending": "\u6B63\u5728\u8BFB\u53D6\u53EC\u56DE\u4FEE\u6B63\u2026",
958
- "monitor.settlement.recall.unavailable": "\u7ED3\u7B97\u660E\u7EC6\u8BFB\u53D6\u5931\u8D25\uFF0C\u5F53\u524D\u663E\u793A\u672A\u4FEE\u6B63\u7684\u4F30\u7B97\u3002",
1024
+ "monitor.settlement.recall.unavailable": "\u8BA1\u5165\u53EC\u56DE\u7684\u7ED3\u7B97\u6682\u4E0D\u53EF\u7528\u3002",
1025
+ "monitor.settlement.recall.unpriced": "\u5F85\u6D4B\u91CF\uFF1A\u672C\u6BB5\u8FD8\u6CA1\u6709\u8BFB\u6570\u5B8C\u6574\u7684\u538B\u7F29\u3002",
959
1026
  "monitor.settlement.recall.partial": "\u90E8\u5206\u53EC\u56DE\u4FEE\u6B63\u7F3A\u5C11\u8BA1\u7B97\u4F9D\u636E\u3002",
960
1027
  "monitor.handoffPage.overview": "\u6982\u89C8",
961
1028
  "monitor.handoffPage.summary": "\u6458\u8981",
@@ -1048,9 +1115,6 @@ var zh = {
1048
1115
  "monitor.context.legend.assumption": "\u5047\u8BBE\uFF1A\u9664\u5C01\u5B58\u5916\u589E\u957F\u4E0D\u53D8",
1049
1116
  "monitor.context.note": "\u8BF4\u660E",
1050
1117
  "monitor.context.note.line": "\u6E10\u6DF1\u7EBF\uFF1A\u6309\u672C\u6BB5\u672B\u7684\u6D4B\u91CF\u62DF\u5408\u51FA\u7684\u8F93\u5165\u5B58\u91CF\u4F4D\u7F6E\uFF1B\u5B9E\u9645\u5B58\u91CF\u8D8A\u8FC7\u5B83\uFF0C\u5C31\u8FDB\u5165\u300C\u6E10\u6DF1\u300D\u533A\u3002",
1051
- "monitor.context.cache": "\u7F13\u5B58\u91CD\u5EFA",
1052
- "monitor.context.cache.share": "\u7F13\u5B58\u91CD\u5EFA\u5360\u6210\u672C",
1053
- "monitor.context.cache.net": "\u76C8\u4E8F",
1054
1118
  "monitor.context.cache.slider": "\u91CD\u5EFA\u591A\u4ED8",
1055
1119
  "monitor.context.cache.read.actual": "\u91CD\u5EFA\u591A\u4ED8\u6309\u5B9E\u9645\u8BA1",
1056
1120
  "monitor.context.cache.read.none": "\u91CD\u5EFA\u591A\u4ED8\u4E0D\u8BA1",
@@ -1066,6 +1130,42 @@ var zh = {
1066
1130
  "monitor.context.cache.rows.share": "\u5360\u6BD4",
1067
1131
  "monitor.context.cache.row.label": "\u538B\u7F29 #{ordinal}\uFF0C\u91CD\u5EFA\u591A\u4ED8 {rebuild}\uFF0C\u5360\u6BD4 {share}\uFF0C\u5B9A\u4F4D\u5230\u56FE\u4E0A\u7B2C {at} \u6B21\u8C03\u7528",
1068
1132
  "monitor.context.cache.row.labelNone": "\u538B\u7F29 #{ordinal}\uFF0C\u65E0\u6570\u636E\uFF0C\u5B9A\u4F4D\u5230\u56FE\u4E0A\u7B2C {at} \u6B21\u8C03\u7528",
1133
+ "monitor.recall.name.user": "\u7528\u6237\u6D88\u606F",
1134
+ "monitor.recall.name.assistant": "\u52A9\u624B\u6D88\u606F",
1135
+ "monitor.recall.name.toolResult": "\u5DE5\u5177\u7ED3\u679C",
1136
+ "monitor.recall.name.toolCall": "\u5DE5\u5177\u8C03\u7528",
1137
+ "monitor.recall.name.system": "\u7CFB\u7EDF\u6D88\u606F",
1138
+ "monitor.recall.name.developer": "\u5F00\u53D1\u8005\u6D88\u606F",
1139
+ "monitor.recall.row.label": "\u4E8B\u4EF6 #{seq} {name}\uFF0C\u56DE\u8BFB {count} \u6B65",
1140
+ "monitor.recall.title": "\u4E8B\u4EF6 #{seq} {name}",
1141
+ "monitor.recall.landing.zero": "\u539F\u4E8B\u4EF6\u5728\u7B2C {at} \u6B65\uFF08#0 \u9996\u5C01\u5B58\u524D\uFF09",
1142
+ "monitor.recall.landing.at": "\u539F\u4E8B\u4EF6\u5728\u7B2C {at} \u6B65\uFF08#{zone}\uFF09",
1143
+ "monitor.recall.landing.unknown": "\u539F\u4E8B\u4EF6\u4F4D\u7F6E\u4E0D\u660E",
1144
+ "monitor.recall.read": "\u7B2C {at} \u6B65",
1145
+ "monitor.recall.heading": "\u53EC\u56DE\u76EE\u6807",
1146
+ "monitor.recall.count": "{count} \u4E2A\u76EE\u6807",
1147
+ "monitor.recall.repeated": "{count} \u4E2A\u8DE8\u5C01\u5B58\u91CD\u590D",
1148
+ "monitor.recall.none": "\u672A\u89C2\u5BDF\u5230\u53EC\u56DE\u76EE\u6807",
1149
+ "monitor.recall.row.count": "\u56DE\u8BFB {count} \u6B65",
1150
+ "monitor.recall.legend.original": "\u539F\u4E8B\u4EF6",
1151
+ "monitor.recall.legend.read": "\u56DE\u8BFB",
1152
+ "monitor.recall.legend.seal": "\u5C01\u5B58",
1153
+ "monitor.recall.legend.zero": "#0 \u9996\u5C01\u5B58\u524D",
1154
+ "monitor.recall.reads": "\u56DE\u8BFB\u8BE5\u4E8B\u4EF6\u7684\u6B65",
1155
+ "monitor.recall.read.call": "\u7B2C {at} \u6B65\uFF0C\u5B9A\u4F4D\u5230\u56FE\u4E0A\u7B2C {call} \u6B21\u8C03\u7528",
1156
+ "monitor.recall.text.loading": "\u6B63\u5728\u8BFB\u53D6\u539F\u6587\u2026",
1157
+ "monitor.recall.text.failed": "\u539F\u6587\u8BFB\u53D6\u5931\u8D25\uFF1A{message}",
1158
+ "monitor.recall.text.none": "\u8BE5\u4E8B\u4EF6\u6CA1\u6709\u6587\u5B57",
1159
+ "monitor.recall.text.expand": "\u5C55\u5F00\u5168\u6587\uFF08{count} \u5B57\uFF09",
1160
+ "monitor.recall.text.collapse": "\u6536\u8D77",
1161
+ "monitor.context.comp": "\u7ED3\u7B97\u6210\u672C\u6784\u6210",
1162
+ "monitor.context.comp.total": "\u5408\u8BA1 {value}",
1163
+ "monitor.context.comp.summary": "\u538B\u7F29\u6458\u8981",
1164
+ "monitor.context.comp.rebuild": "\u7F13\u5B58\u91CD\u5EFA",
1165
+ "monitor.context.comp.recall": "\u53EC\u56DE\u8BF7\u6C42\u51C0\u589E",
1166
+ "monitor.context.trial": "\u91CD\u5EFA\u8BD5\u7B97",
1167
+ "monitor.payback.share": "\u7EAF\u53EC\u56DE\u6B65\u5360\u6BD4 {percent}\uFF08{pure}/{judged} \u6B65\uFF09",
1168
+ "monitor.payback.share.none": "\u7EAF\u53EC\u56DE\u6B65\u5360\u6BD4 \u2014",
1069
1169
  "monitor.handoff.overview.type": "\u7C7B\u578B",
1070
1170
  "monitor.handoff.overview.token": "\u4EA4\u63A5\u7801",
1071
1171
  "monitor.handoff.overview.createdAt": "\u51C6\u5907\u65F6\u95F4",
@@ -18058,10 +18158,10 @@ var RESIDUAL_FAMILIES = [
18058
18158
  ["tool", (t) => t.name]
18059
18159
  ];
18060
18160
  var RESIDUAL_KINDS = new Set(RESIDUAL_FAMILIES.map(([kind]) => kind));
18061
- function foldResidual(kind, list, nameOf) {
18161
+ function foldResidual(kind, list, nameOf2) {
18062
18162
  if (!list || list.length === 0) return [];
18063
18163
  function makeLeaf(item, indent) {
18064
- const name = nameOf(item);
18164
+ const name = nameOf2(item);
18065
18165
  const isBash = kind === "bash";
18066
18166
  const id = kind + ":" + name;
18067
18167
  const displayName = isBash ? redactCmd(name) : name;
@@ -18158,9 +18258,9 @@ function buildTree(bucketData) {
18158
18258
  }
18159
18259
  tree.push(...foldPaths(bucketData.paths || []));
18160
18260
  let sumResidual = 0;
18161
- for (const [kind, nameOf] of RESIDUAL_FAMILIES) {
18261
+ for (const [kind, nameOf2] of RESIDUAL_FAMILIES) {
18162
18262
  const list = bucketData.residual?.[kind] || [];
18163
- tree.push(...foldResidual(kind, list, nameOf));
18263
+ tree.push(...foldResidual(kind, list, nameOf2));
18164
18264
  sumResidual += list.reduce((s, item) => s + (item.tokens ?? 0), 0);
18165
18265
  }
18166
18266
  const totalRaw = bucketData.totalResidualRaw ?? bucketData.totalResidual ?? 0;
@@ -19596,197 +19696,6 @@ function createModeReaders({ call }) {
19596
19696
  };
19597
19697
  }
19598
19698
 
19599
- // public/lib/compactionEconomics.js
19600
- var segmentOf = ({ epoch }) => epoch ?? 0;
19601
- var countOf = (value) => Number.isFinite(value) ? value : 0;
19602
- function ordinalsOf(attempts) {
19603
- const counts = /* @__PURE__ */ new Map();
19604
- return Object.fromEntries(attempts.map((attempt) => {
19605
- const { id } = attempt;
19606
- const segment = segmentOf(attempt) + 1;
19607
- const ordinal = (counts.get(segment) ?? 0) + 1;
19608
- counts.set(segment, ordinal);
19609
- return [id, { epoch: segment, ordinal }];
19610
- }));
19611
- }
19612
- var PAID_BACK_PERCENT = 100;
19613
- var PERCENT = 100;
19614
- var paybackPercent = (saved, cost) => Math.floor(saved * PERCENT / cost);
19615
- function clearingsOf(handoffs) {
19616
- const seen = /* @__PURE__ */ new Set();
19617
- return [...handoffs].sort((a, b) => a.id - b.id).flatMap(({ id, type, epoch, tailCalls }) => {
19618
- const segment = epoch - 1;
19619
- if (type !== "continue" || seen.has(segment)) return [];
19620
- seen.add(segment);
19621
- return [{ id, epoch, segment, tailCalls: countOf(tailCalls) }];
19622
- });
19623
- }
19624
- function followOf(committed, at, tail) {
19625
- const segment = segmentOf(committed[at]);
19626
- const later = committed.slice(at + 1).filter((next) => segmentOf(next) === segment).reduce((sum, { stepN }) => sum + countOf(stepN), 0);
19627
- return later + tail;
19628
- }
19629
- function requestCostOf(usage, ratio) {
19630
- const { input, cacheRead, cacheWrite } = usage ?? {};
19631
- if (![input, cacheRead, cacheWrite, ratio].every(Number.isFinite)) return null;
19632
- return cacheRead + ratio * (input + cacheWrite);
19633
- }
19634
- var neededOf = (cut, cost) => cost === null || cut === null ? null : cut > 0 ? Math.ceil(Math.round(cost) / cut) : Infinity;
19635
- var gapOf = (needed, follow) => Number.isFinite(needed) ? needed - follow : null;
19636
- function figuresOf({ contextChange, call, cRatio }, follow, cut) {
19637
- const { miss } = contextChange ?? {};
19638
- const summary = requestCostOf(call.usage, cRatio);
19639
- if (!Number.isFinite(cut) || !Number.isFinite(miss) || summary === null) return null;
19640
- const rebuild = (cRatio - 1) * miss;
19641
- const cost = summary + rebuild;
19642
- return cost > 0 ? { saved: Math.max(0, follow * cut), cost, rebuild } : null;
19643
- }
19644
- function paybackOf(attempts, handoffs = []) {
19645
- const committed = attempts.filter(({ status }) => status === "committed").sort((a, b) => a.id - b.id);
19646
- const tails = new Map(clearingsOf(handoffs).map(({ segment, tailCalls }) => [segment, tailCalls]));
19647
- return new Map(committed.map((attempt, at) => {
19648
- const follow = followOf(committed, at, tails.get(segmentOf(attempt)) ?? 0);
19649
- const delta = attempt.contextChange?.delta;
19650
- const figures = figuresOf(attempt, follow, Number.isFinite(delta) ? -delta : null);
19651
- return [attempt.id, figures === null ? null : paybackPercent(figures.saved, figures.cost)];
19652
- }));
19653
- }
19654
- function settlementsOf(attempts, handoffs) {
19655
- const ordinals = ordinalsOf(attempts);
19656
- const settlements = /* @__PURE__ */ new Map();
19657
- for (const { id, epoch, tailCalls } of clearingsOf(handoffs)) {
19658
- const settlement = settlementForSegment(attempts, { epoch, tailCalls }, ordinals);
19659
- if (settlement.rows.some(({ saved }) => saved !== null)) settlements.set(id, settlement);
19660
- }
19661
- return settlements;
19662
- }
19663
- function settlementForSegment(attempts, { epoch, tailCalls }, ordinals = ordinalsOf(attempts)) {
19664
- const compactions = attempts.filter((attempt) => attempt.status === "committed" && segmentOf(attempt) === epoch - 1).sort((a, b) => a.id - b.id);
19665
- const steps2 = compactions.reduce((sum, { stepN }) => sum + countOf(stepN), tailCalls);
19666
- const rows = compactions.map((attempt, at) => {
19667
- const { before: rawBefore, after, delta } = attempt.contextChange ?? {};
19668
- const estimated = rawBefore === null && Number.isFinite(attempt.estimatedBefore);
19669
- const before = estimated ? attempt.estimatedBefore : rawBefore;
19670
- const cut = Number.isFinite(before) && Number.isFinite(after) ? before - after : null;
19671
- const follow = followOf(compactions, at, tailCalls);
19672
- const figures = figuresOf(attempt, follow, estimated ? cut : Number.isFinite(delta) ? -delta : null);
19673
- const needed = neededOf(cut, figures?.cost ?? null);
19674
- return {
19675
- id: attempt.id,
19676
- ordinal: ordinals[attempt.id].ordinal,
19677
- saved: figures?.saved ?? null,
19678
- cost: figures?.cost ?? null,
19679
- before: Number.isFinite(before) ? before : null,
19680
- after: Number.isFinite(after) ? after : null,
19681
- cut,
19682
- follow,
19683
- sealAt: steps2 - follow,
19684
- costRebuild: figures?.rebuild ?? null,
19685
- needed,
19686
- gap: gapOf(needed, follow)
19687
- };
19688
- });
19689
- const known = rows.filter(({ saved }) => saved !== null);
19690
- return { epoch, count: rows.length, steps: steps2, saved: known.reduce((sum, row2) => sum + row2.saved, 0), cost: known.reduce((sum, row2) => sum + row2.cost, 0), rows };
19691
- }
19692
- function settlementWithRecall(settlement, recall) {
19693
- if (recall === void 0) return settlement;
19694
- const cuts = new Map(recall.cuts.map(({ id, tokens }) => [id, tokens]));
19695
- let cutCredit = 0;
19696
- const rows = settlement.rows.map((row2) => {
19697
- if (!cuts.has(row2.id) || row2.cut === null) return row2;
19698
- const cut = row2.cut - cuts.get(row2.id);
19699
- const saved = row2.saved === null ? null : row2.follow * Math.max(0, cut);
19700
- cutCredit += (row2.saved ?? 0) - (saved ?? 0);
19701
- const needed = neededOf(cut, row2.cost);
19702
- return { ...row2, cut, saved, needed, gap: gapOf(needed, row2.follow) };
19703
- });
19704
- const known = rows.filter((row2) => row2.saved !== null);
19705
- const byId = new Map(known.map((row2) => [row2.id, row2]));
19706
- const adjustments = /* @__PURE__ */ new Map();
19707
- let requests = 0;
19708
- let overlap = 0;
19709
- let withdrawn = 0;
19710
- let residence = 0;
19711
- let partial = Boolean(recall.partial);
19712
- for (const step of recall.steps) {
19713
- if ("resident" in step) {
19714
- residence += step.resident;
19715
- adjustments.set(step.at, { saving: step.resident, cost: 0 });
19716
- continue;
19717
- }
19718
- const saving = known.reduce((sum, row2) => sum + (row2.sealAt < step.at ? Math.max(0, row2.cut ?? 0) : 0), 0);
19719
- const cost = requestCostOf(step.usage, step.ratio);
19720
- const rebuild = cost === null ? 0 : byId.get(step.post)?.costRebuild ?? 0;
19721
- if (cost === null) partial = true;
19722
- requests += cost ?? 0;
19723
- overlap += rebuild;
19724
- withdrawn += saving;
19725
- adjustments.set(step.at, { saving, cost: (cost ?? 0) - rebuild });
19726
- }
19727
- return {
19728
- ...settlement,
19729
- rows,
19730
- adjustments,
19731
- saved: settlement.saved - cutCredit - withdrawn - residence,
19732
- cost: settlement.cost + requests - overlap,
19733
- recall: { requests, overlap, withdrawn, residence, cutCredit, partial }
19734
- };
19735
- }
19736
- var MEDIAN_MIN_COUNT = 3;
19737
- function paybackCurveOf({ steps: steps2, rows, adjustments }) {
19738
- const known = rows.filter(({ saved }) => saved !== null).sort((a, b) => a.sealAt - b.sealAt);
19739
- const net = [];
19740
- let earnedPerStep = 0;
19741
- let earned = 0;
19742
- let spent = 0;
19743
- let next = 0;
19744
- for (let step = 0; step <= steps2; step += 1) {
19745
- earned += earnedPerStep;
19746
- while (next < known.length && known[next].sealAt <= step) {
19747
- spent += known[next].cost;
19748
- earnedPerStep += Math.max(0, known[next].cut ?? 0);
19749
- next += 1;
19750
- }
19751
- const adjustment = adjustments?.get(step);
19752
- earned -= adjustment?.saving ?? 0;
19753
- spent += adjustment?.cost ?? 0;
19754
- net.push(earned - spent);
19755
- }
19756
- let lowest = { value: net[0], at: 0 };
19757
- const below = [];
19758
- let first = null;
19759
- net.forEach((value, step) => {
19760
- if (value < lowest.value) lowest = { value, at: step };
19761
- if (value < 0) first ??= step;
19762
- else if (first !== null) {
19763
- below.push([first, step - 1]);
19764
- first = null;
19765
- }
19766
- });
19767
- if (first !== null) below.push([first, steps2]);
19768
- const needed = rows.map((row2) => row2.needed).filter(Number.isFinite).sort((a, b) => a - b);
19769
- const middle = Math.floor(needed.length / 2);
19770
- const medianNeeded = needed.length < MEDIAN_MIN_COUNT ? null : needed.length % 2 === 1 ? needed[middle] : (needed[middle - 1] + needed[middle]) / 2;
19771
- return { steps: steps2, net, seals: rows.map((row2) => row2.sealAt).sort((a, b) => a - b), lowest, below, medianNeeded };
19772
- }
19773
- var UNEXPECTED_MISS_PERCENT = 30;
19774
- function unexpectedMissOf(attempts) {
19775
- const committed = attempts.filter(({ status }) => status === "committed").sort((a, b) => a.id - b.id);
19776
- const previousAfter = /* @__PURE__ */ new Map();
19777
- const unexpected = /* @__PURE__ */ new Set();
19778
- for (const attempt of committed) {
19779
- const { id, contextChange } = attempt;
19780
- const segment = segmentOf(attempt);
19781
- const { after, miss } = contextChange ?? {};
19782
- const previous = previousAfter.get(segment);
19783
- if (previous > 0 && Number.isFinite(after) && Number.isFinite(miss) && (miss - (after - previous)) * PERCENT > UNEXPECTED_MISS_PERCENT * previous) unexpected.add(id);
19784
- previousAfter.set(segment, Number.isFinite(after) ? after : null);
19785
- }
19786
- return unexpected;
19787
- }
19788
- var shownStatusOf = (attempt, payback) => attempt.status === "committed" && payback.get(attempt.id) >= PAID_BACK_PERCENT ? "paid" : attempt.status;
19789
-
19790
19699
  // dsh/src/client/monitor-store.js
19791
19700
  var ACTIVE_STATUSES = ["generating", "validating"];
19792
19701
  var ROWS_ENDPOINT = "inner-monitor";
@@ -19807,14 +19716,11 @@ function foldRows(reply) {
19807
19716
  var foldResource = (reply) => fold3(reply, (value) => ({ kind: "ready", value }));
19808
19717
  function foldCurrentSettlement(reply) {
19809
19718
  return fold3(reply, (value) => {
19810
- const { epoch, tailCalls, attempts, calls, recall } = value ?? {};
19719
+ const { epoch, tailCalls, attempts, calls } = value ?? {};
19811
19720
  if (!Number.isSafeInteger(epoch) || epoch < 1 || !Number.isSafeInteger(tailCalls) || tailCalls < 0 || !Array.isArray(attempts) || !Array.isArray(calls)) {
19812
19721
  throw new Error("the inner monitor answered an incomplete settlement snapshot");
19813
19722
  }
19814
- const base = settlementForSegment(attempts, { epoch, tailCalls });
19815
- const report = base.rows.some((row2) => row2.saved !== null) ? settlementWithRecall(base, recall) : null;
19816
- const curve = report === null ? null : paybackCurveOf(report);
19817
- return { kind: "ready", value: { snapshot: { kind: "ready", value: { calls } }, base, report, curve } };
19723
+ return { kind: "ready", value };
19818
19724
  });
19819
19725
  }
19820
19726
  async function settle(send, foldReply) {
@@ -19857,6 +19763,36 @@ function createReadLoop({ pull, apply: apply2, repeat }) {
19857
19763
  }
19858
19764
  };
19859
19765
  }
19766
+ function createTargetReader(read) {
19767
+ let state = { selected: null, result: null };
19768
+ let turn = 0;
19769
+ const listeners = /* @__PURE__ */ new Set();
19770
+ const move = (next) => {
19771
+ state = next;
19772
+ for (const listener of [...listeners]) listener();
19773
+ };
19774
+ return {
19775
+ get state() {
19776
+ return state;
19777
+ },
19778
+ select(seq) {
19779
+ if (seq === state.selected) return;
19780
+ turn += 1;
19781
+ const mine = turn;
19782
+ move({ selected: seq, result: null });
19783
+ if (seq === null) return;
19784
+ void read(seq).then((result) => {
19785
+ if (mine === turn) move({ selected: seq, result });
19786
+ });
19787
+ },
19788
+ subscribe(listener) {
19789
+ listeners.add(listener);
19790
+ return () => {
19791
+ listeners.delete(listener);
19792
+ };
19793
+ }
19794
+ };
19795
+ }
19860
19796
  function createMonitorStores({ call }) {
19861
19797
  const stores = /* @__PURE__ */ new Map();
19862
19798
  function createStore(sessionId) {
@@ -19948,6 +19884,9 @@ function createMonitorStores({ call }) {
19948
19884
  readCurrentSettlement() {
19949
19885
  return settle(() => call("inner-monitor/settlement/current", { sessionId }), foldCurrentSettlement);
19950
19886
  },
19887
+ settlementTarget({ segment, through }) {
19888
+ return createTargetReader((seq) => settle(() => call("inner-monitor/settlement/target", { sessionId, segment, through, seq }), foldResource));
19889
+ },
19951
19890
  resource({ endpoint, attempt, handoff, slot }) {
19952
19891
  const identity = JSON.stringify([endpoint, attempt ?? handoff, slot ?? null]);
19953
19892
  let entry = resources.get(identity);
@@ -20336,6 +20275,197 @@ var import_react10 = __toESM(require("react"), 1);
20336
20275
  // dsh/src/client/monitor-drawer.js
20337
20276
  var import_react9 = __toESM(require("react"), 1);
20338
20277
 
20278
+ // public/lib/compactionEconomics.js
20279
+ var segmentOf = ({ epoch }) => epoch ?? 0;
20280
+ var countOf = (value) => Number.isFinite(value) ? value : 0;
20281
+ function ordinalsOf(attempts) {
20282
+ const counts = /* @__PURE__ */ new Map();
20283
+ return Object.fromEntries(attempts.map((attempt) => {
20284
+ const { id } = attempt;
20285
+ const segment = segmentOf(attempt) + 1;
20286
+ const ordinal = (counts.get(segment) ?? 0) + 1;
20287
+ counts.set(segment, ordinal);
20288
+ return [id, { epoch: segment, ordinal }];
20289
+ }));
20290
+ }
20291
+ var PAID_BACK_PERCENT = 100;
20292
+ var PERCENT = 100;
20293
+ var paybackPercent = (saved, cost) => Math.floor(saved * PERCENT / cost);
20294
+ function clearingsOf(handoffs) {
20295
+ const seen = /* @__PURE__ */ new Set();
20296
+ return [...handoffs].sort((a, b) => a.id - b.id).flatMap(({ id, type, epoch, tailCalls }) => {
20297
+ const segment = epoch - 1;
20298
+ if (type !== "continue" || seen.has(segment)) return [];
20299
+ seen.add(segment);
20300
+ return [{ id, epoch, segment, tailCalls: countOf(tailCalls) }];
20301
+ });
20302
+ }
20303
+ function followOf(committed, at, tail) {
20304
+ const segment = segmentOf(committed[at]);
20305
+ const later = committed.slice(at + 1).filter((next) => segmentOf(next) === segment).reduce((sum, { stepN }) => sum + countOf(stepN), 0);
20306
+ return later + tail;
20307
+ }
20308
+ function requestCostOf(usage, ratio) {
20309
+ const { input, cacheRead, cacheWrite } = usage ?? {};
20310
+ if (![input, cacheRead, cacheWrite, ratio].every(Number.isFinite)) return null;
20311
+ return cacheRead + ratio * (input + cacheWrite);
20312
+ }
20313
+ var neededOf = (cut, cost) => cost === null || cut === null ? null : cut > 0 ? Math.ceil(Math.round(cost) / cut) : Infinity;
20314
+ var gapOf = (needed, follow) => Number.isFinite(needed) ? needed - follow : null;
20315
+ function figuresOf({ contextChange, call, cRatio }, follow, cut) {
20316
+ const { miss } = contextChange ?? {};
20317
+ const summary = requestCostOf(call.usage, cRatio);
20318
+ if (!Number.isFinite(cut) || !Number.isFinite(miss) || summary === null) return null;
20319
+ const rebuild = (cRatio - 1) * miss;
20320
+ const cost = summary + rebuild;
20321
+ return cost > 0 ? { saved: Math.max(0, follow * cut), cost, rebuild } : null;
20322
+ }
20323
+ function paybackOf(attempts, handoffs = []) {
20324
+ const committed = attempts.filter(({ status }) => status === "committed").sort((a, b) => a.id - b.id);
20325
+ const tails = new Map(clearingsOf(handoffs).map(({ segment, tailCalls }) => [segment, tailCalls]));
20326
+ return new Map(committed.map((attempt, at) => {
20327
+ const follow = followOf(committed, at, tails.get(segmentOf(attempt)) ?? 0);
20328
+ const delta = attempt.contextChange?.delta;
20329
+ const figures = figuresOf(attempt, follow, Number.isFinite(delta) ? -delta : null);
20330
+ return [attempt.id, figures === null ? null : paybackPercent(figures.saved, figures.cost)];
20331
+ }));
20332
+ }
20333
+ function settlementsOf(attempts, handoffs) {
20334
+ const ordinals = ordinalsOf(attempts);
20335
+ const settlements = /* @__PURE__ */ new Map();
20336
+ for (const { id, epoch, tailCalls } of clearingsOf(handoffs)) {
20337
+ const settlement = settlementForSegment(attempts, { epoch, tailCalls }, ordinals);
20338
+ if (settlement.rows.some(({ saved }) => saved !== null)) settlements.set(id, settlement);
20339
+ }
20340
+ return settlements;
20341
+ }
20342
+ function settlementForSegment(attempts, { epoch, tailCalls }, ordinals = ordinalsOf(attempts)) {
20343
+ const compactions = attempts.filter((attempt) => attempt.status === "committed" && segmentOf(attempt) === epoch - 1).sort((a, b) => a.id - b.id);
20344
+ const steps2 = compactions.reduce((sum, { stepN }) => sum + countOf(stepN), tailCalls);
20345
+ const rows = compactions.map((attempt, at) => {
20346
+ const { before: rawBefore, after, delta } = attempt.contextChange ?? {};
20347
+ const estimated = rawBefore === null && Number.isFinite(attempt.estimatedBefore);
20348
+ const before = estimated ? attempt.estimatedBefore : rawBefore;
20349
+ const cut = Number.isFinite(before) && Number.isFinite(after) ? before - after : null;
20350
+ const follow = followOf(compactions, at, tailCalls);
20351
+ const figures = figuresOf(attempt, follow, estimated ? cut : Number.isFinite(delta) ? -delta : null);
20352
+ const needed = neededOf(cut, figures?.cost ?? null);
20353
+ return {
20354
+ id: attempt.id,
20355
+ ordinal: ordinals[attempt.id].ordinal,
20356
+ saved: figures?.saved ?? null,
20357
+ cost: figures?.cost ?? null,
20358
+ before: Number.isFinite(before) ? before : null,
20359
+ after: Number.isFinite(after) ? after : null,
20360
+ cut,
20361
+ follow,
20362
+ sealAt: steps2 - follow,
20363
+ costRebuild: figures?.rebuild ?? null,
20364
+ needed,
20365
+ gap: gapOf(needed, follow)
20366
+ };
20367
+ });
20368
+ const known = rows.filter(({ saved }) => saved !== null);
20369
+ return { epoch, count: rows.length, steps: steps2, saved: known.reduce((sum, row2) => sum + row2.saved, 0), cost: known.reduce((sum, row2) => sum + row2.cost, 0), rows };
20370
+ }
20371
+ function settlementWithRecall(settlement, recall) {
20372
+ if (recall === void 0) return settlement;
20373
+ const cuts = new Map(recall.cuts.map(({ id, tokens }) => [id, tokens]));
20374
+ let cutCredit = 0;
20375
+ const rows = settlement.rows.map((row2) => {
20376
+ if (!cuts.has(row2.id) || row2.cut === null) return row2;
20377
+ const cut = row2.cut - cuts.get(row2.id);
20378
+ const saved = row2.saved === null ? null : row2.follow * Math.max(0, cut);
20379
+ cutCredit += (row2.saved ?? 0) - (saved ?? 0);
20380
+ const needed = neededOf(cut, row2.cost);
20381
+ return { ...row2, cut, saved, needed, gap: gapOf(needed, row2.follow) };
20382
+ });
20383
+ const known = rows.filter((row2) => row2.saved !== null);
20384
+ const byId = new Map(known.map((row2) => [row2.id, row2]));
20385
+ const adjustments = /* @__PURE__ */ new Map();
20386
+ let requests = 0;
20387
+ let overlap = 0;
20388
+ let withdrawn = 0;
20389
+ let residence = 0;
20390
+ let partial = Boolean(recall.partial);
20391
+ for (const step of recall.steps) {
20392
+ if ("resident" in step) {
20393
+ residence += step.resident;
20394
+ adjustments.set(step.at, { saving: step.resident, cost: 0 });
20395
+ continue;
20396
+ }
20397
+ const saving = known.reduce((sum, row2) => sum + (row2.sealAt < step.at ? Math.max(0, row2.cut ?? 0) : 0), 0);
20398
+ const cost = requestCostOf(step.usage, step.ratio);
20399
+ const rebuild = cost === null ? 0 : byId.get(step.post)?.costRebuild ?? 0;
20400
+ if (cost === null) partial = true;
20401
+ requests += cost ?? 0;
20402
+ overlap += rebuild;
20403
+ withdrawn += saving;
20404
+ adjustments.set(step.at, { saving, cost: (cost ?? 0) - rebuild });
20405
+ }
20406
+ return {
20407
+ ...settlement,
20408
+ rows,
20409
+ adjustments,
20410
+ saved: settlement.saved - cutCredit - withdrawn - residence,
20411
+ cost: settlement.cost + requests - overlap,
20412
+ recall: { requests, overlap, withdrawn, residence, cutCredit, partial }
20413
+ };
20414
+ }
20415
+ var MEDIAN_MIN_COUNT = 3;
20416
+ function paybackCurveOf({ steps: steps2, rows, adjustments }) {
20417
+ const known = rows.filter(({ saved }) => saved !== null).sort((a, b) => a.sealAt - b.sealAt);
20418
+ const net = [];
20419
+ let earnedPerStep = 0;
20420
+ let earned = 0;
20421
+ let spent = 0;
20422
+ let next = 0;
20423
+ for (let step = 0; step <= steps2; step += 1) {
20424
+ earned += earnedPerStep;
20425
+ while (next < known.length && known[next].sealAt <= step) {
20426
+ spent += known[next].cost;
20427
+ earnedPerStep += Math.max(0, known[next].cut ?? 0);
20428
+ next += 1;
20429
+ }
20430
+ const adjustment = adjustments?.get(step);
20431
+ earned -= adjustment?.saving ?? 0;
20432
+ spent += adjustment?.cost ?? 0;
20433
+ net.push(earned - spent);
20434
+ }
20435
+ let lowest = { value: net[0], at: 0 };
20436
+ const below = [];
20437
+ let first = null;
20438
+ net.forEach((value, step) => {
20439
+ if (value < lowest.value) lowest = { value, at: step };
20440
+ if (value < 0) first ??= step;
20441
+ else if (first !== null) {
20442
+ below.push([first, step - 1]);
20443
+ first = null;
20444
+ }
20445
+ });
20446
+ if (first !== null) below.push([first, steps2]);
20447
+ const needed = rows.map((row2) => row2.needed).filter(Number.isFinite).sort((a, b) => a - b);
20448
+ const middle = Math.floor(needed.length / 2);
20449
+ const medianNeeded = needed.length < MEDIAN_MIN_COUNT ? null : needed.length % 2 === 1 ? needed[middle] : (needed[middle - 1] + needed[middle]) / 2;
20450
+ return { steps: steps2, net, seals: rows.map((row2) => row2.sealAt).sort((a, b) => a - b), lowest, below, medianNeeded };
20451
+ }
20452
+ var UNEXPECTED_MISS_PERCENT = 30;
20453
+ function unexpectedMissOf(attempts) {
20454
+ const committed = attempts.filter(({ status }) => status === "committed").sort((a, b) => a.id - b.id);
20455
+ const previousAfter = /* @__PURE__ */ new Map();
20456
+ const unexpected = /* @__PURE__ */ new Set();
20457
+ for (const attempt of committed) {
20458
+ const { id, contextChange } = attempt;
20459
+ const segment = segmentOf(attempt);
20460
+ const { after, miss } = contextChange ?? {};
20461
+ const previous = previousAfter.get(segment);
20462
+ if (previous > 0 && Number.isFinite(after) && Number.isFinite(miss) && (miss - (after - previous)) * PERCENT > UNEXPECTED_MISS_PERCENT * previous) unexpected.add(id);
20463
+ previousAfter.set(segment, Number.isFinite(after) ? after : null);
20464
+ }
20465
+ return unexpected;
20466
+ }
20467
+ var shownStatusOf = (attempt, payback) => attempt.status === "committed" && payback.get(attempt.id) >= PAID_BACK_PERCENT ? "paid" : attempt.status;
20468
+
20339
20469
  // dsh/src/client/monitor-state.js
20340
20470
  var DRAWER_DEFAULT_WIDTH = 420;
20341
20471
  var DRAWER_MIN_WIDTH = 320;
@@ -21187,8 +21317,8 @@ var h6 = import_react5.default.createElement;
21187
21317
  function Notice({ state, children }) {
21188
21318
  return h6("p", { className: "sw-mon-notice", "data-sw-monitor-notice": state, role: "status" }, children);
21189
21319
  }
21190
- function RecallNotice({ result, partial, pending = false, t }) {
21191
- const state = result === null ? pending ? "pending" : null : result.kind !== "ready" ? "unavailable" : partial ? "partial" : null;
21320
+ function RecallNotice({ evidence, partial, priced = true, pending = false, t }) {
21321
+ const state = evidence.state === "pending" ? pending ? "pending" : null : evidence.state !== "ready" ? "unavailable" : !priced ? "unpriced" : partial ? "partial" : null;
21192
21322
  return state === null ? null : h6(Notice, { state: `recall-${state}` }, t(`monitor.settlement.recall.${state}`));
21193
21323
  }
21194
21324
 
@@ -21212,13 +21342,153 @@ function useElementWidth() {
21212
21342
  return [ref, width];
21213
21343
  }
21214
21344
 
21215
- // dsh/src/client/monitor-settlement-model.js
21345
+ // dsh/src/client/monitor-recall-model.js
21216
21346
  var PERCENT3 = 100;
21347
+ var percentText = (ratio) => `${(Math.round(ratio * PERCENT3 * 10) / 10).toFixed(1)}%`;
21348
+ var isCount = (value) => Number.isSafeInteger(value) && value >= 0;
21349
+ var isRead = (value) => value !== null && typeof value === "object" && isCount(value.at) && isCount(value.seq);
21350
+ var isTarget = (value) => value !== null && typeof value === "object" && isCount(value.seq) && typeof value.type === "string" && (value.at === null || isCount(value.at)) && Array.isArray(value.reads) && value.reads.every(isRead);
21351
+ var isActivity = (value) => value !== null && typeof value === "object" && typeof value.covered === "boolean" && isCount(value.judged) && isCount(value.pure) && Array.isArray(value.targets) && value.targets.every(isTarget);
21352
+ function evidenceOf(result) {
21353
+ if (result === null || result === void 0) return { state: "pending" };
21354
+ if (result.kind !== "ready") return { state: "unavailable" };
21355
+ const { activity, recall } = result.value ?? {};
21356
+ return isActivity(activity) ? { state: "ready", activity, recall } : { state: "old" };
21357
+ }
21358
+ var hasFigures = (settlement) => settlement.rows.some((row2) => row2.saved !== null);
21359
+ var isPricing = (response2) => Array.isArray(response2?.attempts) && Number.isSafeInteger(response2.epoch) && response2.epoch >= 1 && isCount(response2.tailCalls);
21360
+ function settlementViewOf(listed, result) {
21361
+ const evidence = evidenceOf(result);
21362
+ const response2 = result?.kind === "ready" ? result.value : void 0;
21363
+ const base = isPricing(response2) ? settlementForSegment(response2.attempts, { epoch: response2.epoch, tailCalls: response2.tailCalls }) : listed ?? null;
21364
+ const priced = base !== null && hasFigures(base);
21365
+ const adjusted = priced && evidence.state === "ready";
21366
+ const report = adjusted ? settlementWithRecall(base, evidence.recall) : base;
21367
+ return {
21368
+ base,
21369
+ evidence,
21370
+ report,
21371
+ priced,
21372
+ adjusted,
21373
+ curve: adjusted ? paybackCurveOf(report) : null,
21374
+ response: response2 ?? null
21375
+ };
21376
+ }
21377
+ function compositionOf(report, adjusted) {
21378
+ const known = report.rows.filter((row2) => row2.saved !== null);
21379
+ const rebuild = known.reduce((sum, row2) => sum + row2.costRebuild, 0);
21380
+ const summary = known.reduce((sum, row2) => sum + row2.cost - row2.costRebuild, 0);
21381
+ const recall = adjusted ? (report.recall?.requests ?? 0) - (report.recall?.overlap ?? 0) : null;
21382
+ const total = adjusted ? report.cost : null;
21383
+ const trusted = adjusted && Number.isFinite(total) && total > 0 && !report.recall?.partial;
21384
+ const shown = { rebuild: Math.round(rebuild), recall: recall === null ? null : Math.round(recall) };
21385
+ shown.summary = total === null ? Math.round(summary) : Math.round(total) - shown.rebuild - shown.recall;
21386
+ const item = (key, value) => ({
21387
+ key,
21388
+ value,
21389
+ text: value === null ? null : formatTokenCount(shown[key]),
21390
+ share: value === null || !trusted ? null : value / total,
21391
+ percent: value === null || !trusted ? null : percentText(value / total)
21392
+ });
21393
+ return {
21394
+ total: total === null ? null : { value: total, text: formatTokenCount(Math.round(total)) },
21395
+ items: [item("summary", summary), item("rebuild", rebuild), item("recall", recall)]
21396
+ };
21397
+ }
21398
+ function shareOf(evidence) {
21399
+ if (evidence.state !== "ready") return null;
21400
+ const { covered, judged, pure } = evidence.activity;
21401
+ return covered && judged > 0 ? { pure, judged, percent: percentText(pure / judged) } : null;
21402
+ }
21403
+ var PAD = 12;
21404
+ var PLOT_WIDTH_MIN = 150;
21405
+ var CHAR_PX = 6.2;
21406
+ var LABEL_PAD = 6;
21407
+ var round12 = (value) => Math.round(value * 10) / 10;
21408
+ var NAME_KEYS = {
21409
+ "user/message": "user",
21410
+ "assistant/message": "assistant",
21411
+ "tool/result": "toolResult",
21412
+ "tool/call": "toolCall",
21413
+ "system/message": "system",
21414
+ "developer/message": "developer"
21415
+ };
21416
+ var nameOf = (type, t) => Object.hasOwn(NAME_KEYS, type) ? t(`monitor.recall.name.${NAME_KEYS[type]}`) : type;
21417
+ function linkOf(read, series) {
21418
+ return series?.calls.find((call) => call.seq === read.seq && call.stock !== null)?.at ?? null;
21419
+ }
21420
+ function targetGraphOf({ evidence, report }, series, width, t) {
21421
+ if (evidence.state !== "ready" || report === null || report.rows.length === 0) return null;
21422
+ const plotWidth = Math.max(PLOT_WIDTH_MIN, width - 2 * PAD);
21423
+ const span = Math.max(1, report.steps);
21424
+ const stepX = (step) => round12(PAD + Math.max(step - 0.5, 0) / span * plotWidth);
21425
+ const lineX = (step) => round12(PAD + Math.min(step, span) / span * plotWidth);
21426
+ const seals = report.rows.map((row2) => ({ ordinal: row2.ordinal, at: row2.sealAt, x: lineX(row2.sealAt) })).sort((a, b) => a.at - b.at);
21427
+ const firstEnd = seals[0]?.at ?? 0;
21428
+ const zoneOf = (at) => seals.filter((seal) => seal.at < at).length;
21429
+ const zones = [];
21430
+ for (const zone of [{ label: "#0", x: PAD }, ...seals.map((seal) => ({ label: `#${seal.ordinal}`, x: seal.x }))]) {
21431
+ const last = zones.at(-1);
21432
+ if (last === void 0 || zone.x - last.x >= last.label.length * CHAR_PX + LABEL_PAD) zones.push(zone);
21433
+ }
21434
+ const rows = evidence.activity.targets.map((target) => {
21435
+ const name = nameOf(target.type, t);
21436
+ return {
21437
+ seq: target.seq,
21438
+ type: target.type,
21439
+ name,
21440
+ count: target.reads.length,
21441
+ ring: target.at === null ? null : { at: target.at, x: stepX(target.at), zero: target.at <= firstEnd },
21442
+ dots: target.reads.map((read) => ({ at: read.at, seq: read.seq, x: stepX(read.at), call: linkOf(read, series) })),
21443
+ label: t("monitor.recall.row.label", { seq: target.seq, name, count: target.reads.length })
21444
+ };
21445
+ });
21446
+ const repeated = evidence.activity.targets.filter((target) => new Set(target.reads.map((read) => zoneOf(read.at))).size > 1).length;
21447
+ return {
21448
+ count: rows.length,
21449
+ repeated,
21450
+ width: plotWidth + 2 * PAD,
21451
+ plotLeft: PAD,
21452
+ plotWidth,
21453
+ seals,
21454
+ zero: { x0: PAD, x1: lineX(firstEnd), label: "#0" },
21455
+ zones,
21456
+ rows
21457
+ };
21458
+ }
21459
+ function selectionOf(graph, seq, t) {
21460
+ const row2 = graph?.rows.find((each2) => each2.seq === seq);
21461
+ if (row2 === void 0) return null;
21462
+ let landing = t("monitor.recall.landing.unknown");
21463
+ if (row2.ring !== null) {
21464
+ const { at } = row2.ring;
21465
+ const zone = graph.seals.filter((seal) => seal.at < at).length;
21466
+ landing = row2.ring.zero ? t("monitor.recall.landing.zero", { at }) : t("monitor.recall.landing.at", { at, zone: graph.seals[zone - 1].ordinal });
21467
+ }
21468
+ return { seq, title: t("monitor.recall.title", { seq, name: row2.name }), landing, reads: row2.dots.map(({ at, call }) => ({ at, label: t("monitor.recall.read", { at }), call })) };
21469
+ }
21470
+ function excerptOf(text, limit) {
21471
+ if (typeof text !== "string" || text === "") return null;
21472
+ if (text.length <= limit) return { text, hidden: 0 };
21473
+ let end = 0;
21474
+ let kept = 0;
21475
+ for (const character of text) {
21476
+ if (kept === limit) break;
21477
+ end += character.length;
21478
+ kept += 1;
21479
+ }
21480
+ let hidden = 0;
21481
+ for (const _ of text.slice(end)) hidden += 1;
21482
+ return { text: text.slice(0, end), hidden };
21483
+ }
21484
+
21485
+ // dsh/src/client/monitor-settlement-model.js
21486
+ var PERCENT4 = 100;
21217
21487
  var UNBOUNDED = "\u221E";
21218
21488
  var ARROW = "\u2192";
21219
21489
  var UP = "\u2191";
21220
21490
  var roundTo = (value, places) => Math.round(value * 10 ** places) / 10 ** places;
21221
- var round12 = (value) => roundTo(value, 1);
21491
+ var round13 = (value) => roundTo(value, 1);
21222
21492
  var compactSigned = (value) => signedText(Math.round(value), compactCount);
21223
21493
  var compactTokens = (value) => {
21224
21494
  const whole = Math.round(value);
@@ -21242,7 +21512,7 @@ function chartLabelOf({ steps: steps2, net, lowest, below }, recall, t, current)
21242
21512
  ].join(t("monitor.payback.chart.separator"));
21243
21513
  }
21244
21514
  function plotOf(row2, steps2) {
21245
- const share = (value) => roundTo(Math.min(value, steps2) / steps2 * PERCENT3, 3);
21515
+ const share = (value) => roundTo(Math.min(value, steps2) / steps2 * PERCENT4, 3);
21246
21516
  const end = share(row2.follow);
21247
21517
  const plot = { end, diamond: null, surplus: null, missing: null, beyond: null, unbounded: false };
21248
21518
  const { needed } = row2;
@@ -21322,11 +21592,14 @@ function formulaRowsOf(base, { saved, cost, recall }, t, format) {
21322
21592
  );
21323
21593
  return rows;
21324
21594
  }
21325
- function settlementPageOf(base, t, evidence) {
21326
- const report = settlementWithRecall(base, evidence);
21327
- return paybackModelOf(base, report, paybackCurveOf(report), t);
21595
+ function settlementPageOf(listed, t, result = null) {
21596
+ return paybackPageOf(settlementViewOf(listed, result), t);
21597
+ }
21598
+ function paybackPageOf(view, t, current = false) {
21599
+ if (!view.adjusted) return { adjusted: false, evidence: view.evidence, priced: view.priced, share: shareOf(view.evidence) };
21600
+ return paybackModelOf(view.base, view.report, view.curve, t, current, view.evidence);
21328
21601
  }
21329
- function paybackModelOf(base, settlement, curve, t, current = false) {
21602
+ function paybackModelOf(base, settlement, curve, t, current, evidence) {
21330
21603
  const { steps: steps2, net, lowest, below, medianNeeded } = curve;
21331
21604
  const { recall } = settlement;
21332
21605
  const equations = formulaRowsOf(base, settlement, t, formatTokenCount);
@@ -21335,9 +21608,13 @@ function paybackModelOf(base, settlement, curve, t, current = false) {
21335
21608
  return `${left} ${left === wholeLeft && right === wholeRight ? sign2 : "\u2248"} ${right}`;
21336
21609
  });
21337
21610
  return {
21611
+ adjusted: true,
21612
+ priced: true,
21338
21613
  epoch: settlement.epoch,
21339
21614
  curve,
21340
21615
  current,
21616
+ evidence,
21617
+ share: shareOf(evidence),
21341
21618
  header: settlementMetaParts(settlement, t, compactTokens).map(({ text }) => text),
21342
21619
  recallPartial: recall?.partial,
21343
21620
  facts: [
@@ -21363,8 +21640,8 @@ function sortRows(rows, sort) {
21363
21640
  var GUTTER_MIN = 34;
21364
21641
  var RIGHT_MARGIN = 6;
21365
21642
  var LABEL_GAP = 5;
21366
- var CHAR_PX = 6.2;
21367
- var LABEL_PAD = 4;
21643
+ var CHAR_PX2 = 6.2;
21644
+ var LABEL_PAD2 = 4;
21368
21645
  var PLOT_TOP = 16;
21369
21646
  var PLOT_BOTTOM = 8;
21370
21647
  var PLOT_HEIGHTS = [[620, 200], [380, 170]];
@@ -21378,7 +21655,7 @@ var STEP_SIZES = [1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500];
21378
21655
  var TICK_MIN_PX = 34;
21379
21656
  var END_TICK_MIN_PX = 30;
21380
21657
  var plotHeightOf = (width) => PLOT_HEIGHTS.find(([from2]) => width >= from2)?.[1] ?? PLOT_HEIGHT_MIN;
21381
- var textWidth = (text) => text.length * CHAR_PX + LABEL_PAD;
21658
+ var textWidth = (text) => text.length * CHAR_PX2 + LABEL_PAD2;
21382
21659
  var point = (x, y) => `${x.toFixed(1)},${y.toFixed(1)}`;
21383
21660
  function curveGeometryOf(curve, width, clipped, t, current = false) {
21384
21661
  const { steps: steps2, net, lowest: lowestNet, seals } = curve;
@@ -21388,12 +21665,12 @@ function curveGeometryOf(curve, width, clipped, t, current = false) {
21388
21665
  const top = clipped ? CLIP_TOP_RATIO * -low : high === low ? low + 1 : high;
21389
21666
  const values = [.../* @__PURE__ */ new Set([0, low, top])];
21390
21667
  const labels = values.map(compactSigned);
21391
- const gutter = Math.max(GUTTER_MIN, Math.ceil(Math.max(...labels.map((label2) => label2.length)) * CHAR_PX) + LABEL_GAP);
21668
+ const gutter = Math.max(GUTTER_MIN, Math.ceil(Math.max(...labels.map((label2) => label2.length)) * CHAR_PX2) + LABEL_GAP);
21392
21669
  const plotWidth = Math.max(0, width - gutter - RIGHT_MARGIN);
21393
21670
  const plotHeight = plotHeightOf(width);
21394
21671
  const y = (value) => PLOT_TOP + (top - value) / (top - low) * (plotHeight - PLOT_TOP - PLOT_BOTTOM);
21395
21672
  const x = (step) => gutter + step / span * plotWidth;
21396
- const zeroY = round12(y(0));
21673
+ const zeroY = round13(y(0));
21397
21674
  const line = net.map((value, step) => `${step === 0 ? "M" : "L"}${point(x(step), y(value))}`).join("");
21398
21675
  const laneY = plotHeight + LANE_GAP;
21399
21676
  const stepsY = laneY + LANE_HEIGHT + LANE_BELOW;
@@ -21406,20 +21683,20 @@ function curveGeometryOf(curve, width, clipped, t, current = false) {
21406
21683
  const box = { x0, x1: x0 + w, y0: atY - 10, y1: atY + 3 };
21407
21684
  if (boxes.some((other) => !(box.x1 < other.x0 || box.x0 > other.x1 || box.y1 < other.y0 || box.y0 > other.y1))) return null;
21408
21685
  boxes.push(box);
21409
- return { text, x: round12(anchor === "end" ? x0 + w : x0), y: round12(atY), anchor };
21686
+ return { text, x: round13(anchor === "end" ? x0 + w : x0), y: round13(atY), anchor };
21410
21687
  };
21411
21688
  const lowestX = x(lowestNet.at);
21412
21689
  const lowestY = y(lowestNet.value);
21413
21690
  const lowRight = lowestX > gutter + plotWidth * 0.5;
21414
21691
  const lowest = {
21415
- x: round12(lowestX),
21416
- y: round12(lowestY),
21692
+ x: round13(lowestX),
21693
+ y: round13(lowestY),
21417
21694
  label: label(t("monitor.payback.lowestLabel", { value: compactSigned(lowestNet.value) }), lowRight ? lowestX - 7 : lowestX + 7, Math.min(lowestY + 4, plotHeight), lowRight ? "end" : "start")
21418
21695
  };
21419
21696
  const final = net[steps2];
21420
21697
  const endText = t(current ? "monitor.payback.snapshotEndLabel" : "monitor.payback.endLabel", { value: compactSigned(final) });
21421
21698
  const endX = x(steps2);
21422
- const end = final <= top ? { x: round12(endX), y: round12(y(final)), above: false, label: label(endText, endX - 7, final >= net[Math.max(0, steps2 - 1)] ? Math.max(y(final) - 7, 11) : Math.min(y(final) + 14, plotHeight - 2), "end") } : { x: round12(endX), y: null, above: true, arrow: `M${round12(endX - 4)},${PLOT_TOP + 5}h8l-4,-7z`, label: label(`${endText} ${UP}`, endX - 7, PLOT_TOP + 10, "end") };
21699
+ const end = final <= top ? { x: round13(endX), y: round13(y(final)), above: false, label: label(endText, endX - 7, final >= net[Math.max(0, steps2 - 1)] ? Math.max(y(final) - 7, 11) : Math.min(y(final) + 14, plotHeight - 2), "end") } : { x: round13(endX), y: null, above: true, arrow: `M${round13(endX - 4)},${PLOT_TOP + 5}h8l-4,-7z`, label: label(`${endText} ${UP}`, endX - 7, PLOT_TOP + 10, "end") };
21423
21700
  const tickStep = STEP_SIZES.find((size) => size / span * plotWidth >= TICK_MIN_PX) ?? STEP_SIZES.at(-1);
21424
21701
  const marks = [];
21425
21702
  for (let step = 0; step <= steps2; step += tickStep) marks.push(step);
@@ -21438,13 +21715,13 @@ function curveGeometryOf(curve, width, clipped, t, current = false) {
21438
21715
  clips: {
21439
21716
  plot: { x: gutter, y: 0, width: plotWidth, height: plotHeight },
21440
21717
  above: { x: 0, y: 0, width, height: zeroY },
21441
- below: { x: 0, y: zeroY, width, height: round12(plotHeight - zeroY) }
21718
+ below: { x: 0, y: zeroY, width, height: round13(plotHeight - zeroY) }
21442
21719
  },
21443
- ticks: values.map((value, at) => ({ value, label: labels[at], y: round12(y(value)), grid: value !== 0, clip: clipped && value === top })),
21444
- lane: { y: laneY, height: LANE_HEIGHT, label: t("monitor.payback.seal"), labelY: laneY + 9, seals: seals.map((step) => round12(x(step))) },
21720
+ ticks: values.map((value, at) => ({ value, label: labels[at], y: round13(y(value)), grid: value !== 0, clip: clipped && value === top })),
21721
+ lane: { y: laneY, height: LANE_HEIGHT, label: t("monitor.payback.seal"), labelY: laneY + 9, seals: seals.map((step) => round13(x(step))) },
21445
21722
  lowest,
21446
21723
  end,
21447
- steps: { unit: t("monitor.payback.stepUnit"), unitX: 0, y: stepsY + STEPS_BASELINE, ticks: marks.map((step) => ({ x: round12(x(step)), label: String(step) })) },
21724
+ steps: { unit: t("monitor.payback.stepUnit"), unitX: 0, y: stepsY + STEPS_BASELINE, ticks: marks.map((step) => ({ x: round13(x(step)), label: String(step) })) },
21448
21725
  clipNote: over < 0 ? null : t("monitor.payback.clipNote", { top: compactSigned(top), step: over })
21449
21726
  };
21450
21727
  }
@@ -21615,12 +21892,15 @@ function Appendix({ appendix: { equations, head, rows }, t }) {
21615
21892
  );
21616
21893
  }
21617
21894
  function PaybackView({ model, state, dispatch, width, chartRef, notice: notice2, t }) {
21895
+ const share = model.evidence.state !== "ready" ? null : h8("p", { className: "sw-pb-share" }, model.share === null ? t("monitor.payback.share.none") : t("monitor.payback.share", { percent: model.share.percent, pure: model.share.pure, judged: model.share.judged }));
21896
+ if (!model.adjusted) return h8("div", { className: "sw-pb" }, notice2, share);
21618
21897
  const geometry = curveGeometryOf(model.curve, width, model.chart.clippable && !state.full, t, model.current);
21619
21898
  return h8(
21620
21899
  "div",
21621
21900
  { className: "sw-pb" },
21622
21901
  h8("p", { className: "sw-pb-head" }, model.header.map((text, at) => h8("span", { key: at }, at < model.header.length - 1 ? `${text}${PART_SEPARATOR.trimEnd()}` : text))),
21623
21902
  notice2,
21903
+ share,
21624
21904
  h8("div", { className: "sw-pb-facts" }, model.facts.map((text, at) => h8("p", { key: at }, text))),
21625
21905
  h8(Curve, { model, geometry, state, dispatch, chartRef, t }),
21626
21906
  h8(Rows, { model, state, dispatch, t }),
@@ -21630,13 +21910,12 @@ function PaybackView({ model, state, dispatch, width, chartRef, notice: notice2,
21630
21910
  }
21631
21911
  function PaybackPage({ settlement, monitor, handoffId, t }) {
21632
21912
  const result = useSettlementResult(monitor, handoffId);
21633
- const model = settlementPageOf(settlement, t, result?.kind === "ready" ? result.value.recall : void 0);
21634
- return h8(PaybackReport, { model, result, t });
21913
+ return h8(PaybackReport, { model: settlementPageOf(settlement, t, result), t });
21635
21914
  }
21636
- function PaybackReport({ model, result, t }) {
21915
+ function PaybackReport({ model, t }) {
21637
21916
  const [state, dispatch] = import_react7.default.useReducer(reducePayback, void 0, createPaybackState);
21638
21917
  const [chartRef, width] = useElementWidth();
21639
- const notice2 = h8(RecallNotice, { result, partial: model.recallPartial, pending: true, t });
21918
+ const notice2 = h8(RecallNotice, { evidence: model.evidence, partial: model.recallPartial, priced: model.priced, pending: true, t });
21640
21919
  return h8(PaybackView, { model, state, dispatch, width, chartRef, notice: notice2, t });
21641
21920
  }
21642
21921
 
@@ -21644,12 +21923,11 @@ function PaybackReport({ model, result, t }) {
21644
21923
  var import_react8 = __toESM(require("react"), 1);
21645
21924
 
21646
21925
  // dsh/src/client/monitor-context-model.js
21647
- var PERCENT4 = 100;
21648
- var round13 = (value) => Math.round(value * 10) / 10;
21926
+ var PERCENT5 = 100;
21927
+ var round14 = (value) => Math.round(value * 10) / 10;
21649
21928
  var compact = (value) => compactCount(Math.round(value));
21650
21929
  var signedWhole = (value) => signedText(Math.round(value), formatTokenCount);
21651
21930
  var signedCompact = (value) => signedText(Math.round(value), compactCount);
21652
- var percentText = (ratio) => `${(Math.round(ratio * PERCENT4 * 10) / 10).toFixed(1)}%`;
21653
21931
  function amberLineOf(result, epoch) {
21654
21932
  if (result?.kind !== "live") return null;
21655
21933
  const history = result.snapshot.history ?? [];
@@ -21699,22 +21977,22 @@ var LEFT = 40;
21699
21977
  var RIGHT = 10;
21700
21978
  var TOP = 14;
21701
21979
  var FOOT = 30;
21702
- var PLOT_WIDTH_MIN = 150;
21980
+ var PLOT_WIDTH_MIN2 = 150;
21703
21981
  var NARROW_BELOW = 340;
21704
21982
  var WIDE_FROM = 600;
21705
21983
  var PLOT_HEIGHTS2 = { narrow: 150, normal: 180, wide: 210 };
21706
21984
  var WIDE_CHAR_PX = 11;
21707
- var CHAR_PX2 = 6.2;
21985
+ var CHAR_PX3 = 6.2;
21708
21986
  var WIDE_FROM_CODE_POINT = 11904;
21709
21987
  var SEAL_TICK = 11;
21710
21988
  var SEAL_HIT = { width: 7, height: 14 };
21711
21989
  var X_AXIS = { tick: 3, label: 14, unit: 25 };
21712
21990
  var X_TICK_TARGET = 7;
21713
21991
  var MARK_RADIUS = 5;
21714
- var textWidth2 = (text) => [...text].reduce((sum, char) => sum + (char.codePointAt(0) >= WIDE_FROM_CODE_POINT ? WIDE_CHAR_PX : CHAR_PX2), 0);
21715
- function stockGeometryOf(series, line, width, t) {
21992
+ var textWidth2 = (text) => [...text].reduce((sum, char) => sum + (char.codePointAt(0) >= WIDE_FROM_CODE_POINT ? WIDE_CHAR_PX : CHAR_PX3), 0);
21993
+ function stockGeometryOf(series, line, width, t, ringAts = []) {
21716
21994
  const scale = stockScaleOf(series);
21717
- const plotWidth = Math.max(PLOT_WIDTH_MIN, width - LEFT - RIGHT);
21995
+ const plotWidth = Math.max(PLOT_WIDTH_MIN2, width - LEFT - RIGHT);
21718
21996
  const total = LEFT + plotWidth + RIGHT;
21719
21997
  const plotHeight = width < NARROW_BELOW ? PLOT_HEIGHTS2.narrow : width >= WIDE_FROM ? PLOT_HEIGHTS2.wide : PLOT_HEIGHTS2.normal;
21720
21998
  const foot = TOP + plotHeight;
@@ -21728,28 +22006,28 @@ function stockGeometryOf(series, line, width, t) {
21728
22006
  let anchor = prefer;
21729
22007
  if (prefer === "end" && x - reach < LEFT + 2) anchor = "start";
21730
22008
  else if (prefer === "start" && x + reach > total - 2) anchor = "end";
21731
- return { text, x: round13(x), y: round13(y), anchor };
22009
+ return { text, x: round14(x), y: round14(y), anchor };
21732
22010
  };
21733
22011
  const points = series.drawn.map(({ at, stock, uncompressed }) => ({
21734
22012
  at,
21735
- x: round13(xOf(at)),
21736
- y: round13(yOf(stock)),
22013
+ x: round14(xOf(at)),
22014
+ y: round14(yOf(stock)),
21737
22015
  uncompressedY: yOf(uncompressed)
21738
22016
  }));
21739
- const pathOf = (key) => `M${points.map((point2) => `${point2.x.toFixed(1)},${round13(point2[key]).toFixed(1)}`).join(" L")}`;
22017
+ const pathOf = (key) => `M${points.map((point2) => `${point2.x.toFixed(1)},${round14(point2[key]).toFixed(1)}`).join(" L")}`;
21740
22018
  const crossing = (call, kind) => {
21741
22019
  if (call === null || !inPlot(call[kind])) return null;
21742
- const x = round13(xOf(call.at));
21743
- const y = round13(yOf(call[kind]));
22020
+ const x = round14(xOf(call.at));
22021
+ const y = round14(yOf(call[kind]));
21744
22022
  if (kind === "uncompressed") {
21745
- const d = `M${x},${round13(y - MARK_RADIUS)} L${round13(x + MARK_RADIUS)},${y} L${x},${round13(y + MARK_RADIUS)} L${round13(x - MARK_RADIUS)},${y} Z`;
22023
+ const d = `M${x},${round14(y - MARK_RADIUS)} L${round14(x + MARK_RADIUS)},${y} L${x},${round14(y + MARK_RADIUS)} L${round14(x - MARK_RADIUS)},${y} Z`;
21746
22024
  return { at: call.at, x, y, d, label: label(t("monitor.context.mark.uncompressed", { n: call.at }), x + 8, y - 7, "start") };
21747
22025
  }
21748
22026
  return { at: call.at, x, y, label: label(t("monitor.context.mark.actual", { n: call.at }), x - 6, y + 20, "end") };
21749
22027
  };
21750
22028
  const step = Math.max(1, niceStep(series.count / X_TICK_TARGET));
21751
22029
  const xTicks = [];
21752
- for (let at = step; at <= series.count; at += step) xTicks.push({ x: round13(xOf(at)), label: String(at) });
22030
+ for (let at = step; at <= series.count; at += step) xTicks.push({ x: round14(xOf(at)), label: String(at) });
21753
22031
  return {
21754
22032
  width: total,
21755
22033
  height: foot + FOOT,
@@ -21757,9 +22035,9 @@ function stockGeometryOf(series, line, width, t) {
21757
22035
  plotWidth,
21758
22036
  plotTop: TOP,
21759
22037
  plotHeight,
21760
- ticks: scale.ticks.map((value) => ({ value, label: value === 0 ? "0" : compact(value), y: round13(yOf(value)) })),
21761
- seals: series.seals.map(({ at, ordinal, land }) => ({ at, x: round13(xOf(at)), ordinal, land })),
21762
- line: plotLine === null ? null : { y: round13(yOf(plotLine)), label: { text: t("monitor.context.line", { value: compact(plotLine) }), x: LEFT + 4, y: round13(yOf(plotLine) + 13), anchor: "start" } },
22038
+ ticks: scale.ticks.map((value) => ({ value, label: value === 0 ? "0" : compact(value), y: round14(yOf(value)) })),
22039
+ seals: series.seals.map(({ at, ordinal, land }) => ({ at, x: round14(xOf(at)), ordinal, land })),
22040
+ line: plotLine === null ? null : { y: round14(yOf(plotLine)), label: { text: t("monitor.context.line", { value: compact(plotLine) }), x: LEFT + 4, y: round14(yOf(plotLine) + 13), anchor: "start" } },
21763
22041
  actual: pathOf("y"),
21764
22042
  uncompressed: pathOf("uncompressedY"),
21765
22043
  uncompressedCross: crossing(crossings.uncompressed, "uncompressed"),
@@ -21769,6 +22047,7 @@ function stockGeometryOf(series, line, width, t) {
21769
22047
  axisPath: `M${LEFT},${TOP} V${foot} H${LEFT + plotWidth}`,
21770
22048
  hit: { x: LEFT, y: TOP, width: plotWidth, height: plotHeight - SEAL_HIT.height },
21771
22049
  points,
22050
+ rings: points.filter(({ at }) => ringAts.includes(at)).map(({ at, x, y }) => ({ at, x, y })),
21772
22051
  foot,
21773
22052
  sealTickTop: foot - SEAL_TICK,
21774
22053
  sealHit: { ...SEAL_HIT, y: foot - SEAL_HIT.height },
@@ -21784,7 +22063,7 @@ function cursorOf(geometry, at) {
21784
22063
  const point2 = geometry.points.find((each2) => each2.at === at);
21785
22064
  if (point2 === void 0) return null;
21786
22065
  const { x, y, uncompressedY } = point2;
21787
- return { x, y, uncompressedY: uncompressedY >= geometry.plotTop && uncompressedY <= geometry.foot ? round13(uncompressedY) : null };
22066
+ return { x, y, uncompressedY: uncompressedY >= geometry.plotTop && uncompressedY <= geometry.foot ? round14(uncompressedY) : null };
21788
22067
  }
21789
22068
  function sealStepAt(series, current, direction) {
21790
22069
  const lands = series.seals.map(({ land }) => land);
@@ -21827,7 +22106,6 @@ function cacheOf(rows, totals) {
21827
22106
  rebuild,
21828
22107
  net0: net + rebuild,
21829
22108
  net1: net,
21830
- share: rebuild / cost,
21831
22109
  rows: [
21832
22110
  ...ranked.map((each2) => ({ ordinal: each2.ordinal, known: true, rebuild: each2.costRebuild, share: each2.costRebuild / rebuild })),
21833
22111
  ...rows.filter((each2) => !known.includes(each2)).map((each2) => ({ ordinal: each2.ordinal, known: false, rebuild: null, share: null }))
@@ -21838,7 +22116,7 @@ function cacheOf(rows, totals) {
21838
22116
  var netAt = (cache, share) => cache.net0 - share * cache.rebuild;
21839
22117
  var crossingShareOf = (cache) => cache.rebuild > 0 && cache.net0 > 0 && cache.net1 < 0 ? cache.net0 / cache.rebuild : null;
21840
22118
  function shareReadoutOf(cache, share, t) {
21841
- const lead = share >= 1 ? t("monitor.context.cache.read.actual") : share <= 0 ? t("monitor.context.cache.read.none") : t("monitor.context.cache.read.at", { percent: Math.round(share * PERCENT4) });
22119
+ const lead = share >= 1 ? t("monitor.context.cache.read.actual") : share <= 0 ? t("monitor.context.cache.read.none") : t("monitor.context.cache.read.at", { percent: Math.round(share * PERCENT5) });
21842
22120
  return t("monitor.context.cache.read", { lead, net: signedWhole(netAt(cache, share)) });
21843
22121
  }
21844
22122
  var LAM = { height: 156, left: 10, right: 10, top: 14, foot: 34, plotMin: 60, headroom: 0.2, gridShares: [0, 0.25, 0.5, 0.75, 1], cursorFrom: 4e-3, cursorTo: 0.996 };
@@ -21859,20 +22137,20 @@ function lamGeometryOf(cache, share, width) {
21859
22137
  const segment = (from2, to2, tone) => ({ tone, points: `${pointOf(from2)} ${pointOf(to2)}` });
21860
22138
  const end = (kind, at, anchor, radius) => {
21861
22139
  const value = netAt(cache, at);
21862
- return { kind, x: round13(xOf(at)), y: round13(yOf(value)), r: radius, label: { text: signedCompact(value), x: round13(xOf(at)), y: round13(value < 0 ? yOf(value) + 16 : yOf(value) - 8), anchor } };
22140
+ return { kind, x: round14(xOf(at)), y: round14(yOf(value)), r: radius, label: { text: signedCompact(value), x: round14(xOf(at)), y: round14(value < 0 ? yOf(value) + 16 : yOf(value) - 8), anchor } };
21863
22141
  };
21864
- const x = round13(xOf(crossShare ?? 0));
21865
- const y0 = round13(zeroY);
22142
+ const x = round14(xOf(crossShare ?? 0));
22143
+ const y0 = round14(zeroY);
21866
22144
  return {
21867
22145
  width: left + plotWidth + right,
21868
22146
  height,
21869
- grid: LAM.gridShares.map((at) => ({ x: round13(xOf(at)), label: `${Math.round(at * PERCENT4)}%`, anchor: at === 0 ? "start" : at === 1 ? "end" : "middle" })),
21870
- title: { x: round13(left + plotWidth / 2), y: height - 2 },
21871
- zero: { x1: left, x2: left + plotWidth, y: y0, labelX: left + 2, labelY: round13(zeroY + (cache.net0 >= 0 && cache.net1 >= 0 ? -3 : 11)) },
22147
+ grid: LAM.gridShares.map((at) => ({ x: round14(xOf(at)), label: `${Math.round(at * PERCENT5)}%`, anchor: at === 0 ? "start" : at === 1 ? "end" : "middle" })),
22148
+ title: { x: round14(left + plotWidth / 2), y: height - 2 },
22149
+ zero: { x1: left, x2: left + plotWidth, y: y0, labelX: left + 2, labelY: round14(zeroY + (cache.net0 >= 0 && cache.net1 >= 0 ? -3 : 11)) },
21872
22150
  segments: crossShare === null ? [segment(0, 1, (cache.net0 + cache.net1) / 2 < 0 ? "neg" : "pos")] : [segment(0, crossShare, "pos"), segment(crossShare, 1, "neg")],
21873
- crossing: crossShare === null ? null : { x, y: y0, d: `M${x} ${round13(y0 - 5)}l5 5l-5 5l-5-5z` },
22151
+ crossing: crossShare === null ? null : { x, y: y0, d: `M${x} ${round14(y0 - 5)}l5 5l-5 5l-5-5z` },
21874
22152
  ends: [end("none", 0, "start", 4), end("all", 1, "end", 4.5)],
21875
- cursor: share > LAM.cursorFrom && share < LAM.cursorTo ? { x: round13(xOf(share)), y: round13(yOf(netAt(cache, share))) } : null,
22153
+ cursor: share > LAM.cursorFrom && share < LAM.cursorTo ? { x: round14(xOf(share)), y: round14(yOf(netAt(cache, share))) } : null,
21876
22154
  guide: { top, bottom: top + plotHeight }
21877
22155
  };
21878
22156
  }
@@ -21895,12 +22173,9 @@ function chartLabelOf2(series, line, crossings, t) {
21895
22173
  function cacheTextsOf(sums, series, t) {
21896
22174
  const crossShare = crossingShareOf(sums);
21897
22175
  const crossing = crossShare === null ? null : t("monitor.context.cache.crossing", { percent: percentText(crossShare) });
21898
- const net = Math.round(sums.net1);
21899
22176
  const sealOf = (ordinal) => series?.seals.find((seal) => seal.ordinal === ordinal);
21900
22177
  return {
21901
22178
  sums,
21902
- share: percentText(sums.share),
21903
- net: { text: net === 0 ? "0" : `${signedCompact(net)} ${net > 0 ? "\u25B2" : "\u25BC"}`, tone: net > 0 ? "pos" : net < 0 ? "neg" : "zero" },
21904
22179
  crossing,
21905
22180
  chart: sums.rebuild > 0 ? { label: t(crossing === null ? "monitor.context.cache.chart" : "monitor.context.cache.chart.crossing", { none: signedCompact(sums.net0), actual: signedCompact(sums.net1), sentence: crossing }) } : null,
21906
22181
  list: sums.rebuild > 0 ? sums.rows.map(({ ordinal, known, rebuild, share }) => {
@@ -21910,7 +22185,7 @@ function cacheTextsOf(sums, series, t) {
21910
22185
  return {
21911
22186
  ordinal,
21912
22187
  known,
21913
- bar: known ? (rebuild / sums.max * PERCENT4).toFixed(2) : null,
22188
+ bar: known ? (rebuild / sums.max * PERCENT5).toFixed(2) : null,
21914
22189
  ...text,
21915
22190
  jump,
21916
22191
  label: jump === null ? null : t(known ? "monitor.context.cache.row.label" : "monitor.context.cache.row.labelNone", params)
@@ -21919,22 +22194,32 @@ function cacheTextsOf(sums, series, t) {
21919
22194
  };
21920
22195
  }
21921
22196
  function contextPageOf(settlement, result, line, t) {
21922
- const recall = result?.kind === "ready" ? result.value.recall : void 0;
21923
- return contextModelOf(settlement, settlementWithRecall(settlement, recall), result, line, t);
22197
+ return contextModelOf(settlementViewOf(settlement, result), line, t);
21924
22198
  }
21925
- function contextModelOf(settlement, report, result, line, t) {
21926
- const series = result?.kind === "ready" ? seriesOf(settlement.rows, result.value.calls) : null;
22199
+ function contextModelOf(view, line, t) {
22200
+ const { base, report, evidence, response: response2 } = view;
22201
+ const series = Array.isArray(response2?.calls) ? seriesOf(base.rows, response2.calls) : null;
21927
22202
  const crossings = series === null ? null : crossingsOf(series, line);
21928
22203
  return {
21929
- count: t("monitor.settlement.count", { count: settlement.count }),
22204
+ count: t("monitor.settlement.count", { count: base.count }),
21930
22205
  calls: series === null ? null : t("monitor.context.calls", { count: series.count }),
21931
- loading: result === null,
22206
+ loading: evidence.state === "pending",
21932
22207
  stock: series === null ? null : { series, line, facts: factsOf(series, line, crossings, t), label: chartLabelOf2(series, line, crossings, t) },
21933
- cache: cacheTextsOf(cacheOf(settlement.rows, report === settlement ? void 0 : report), series, t),
21934
- recallPartial: report.recall?.partial
22208
+ composition: view.priced ? compositionOf(report, view.adjusted) : null,
22209
+ cache: cacheTextsOf(cacheOf(base.rows, report === base ? void 0 : report), series, t),
22210
+ recallPartial: report.recall?.partial,
22211
+ priced: view.priced,
22212
+ view
21935
22213
  };
21936
22214
  }
21937
- var createContextState = () => ({ cursor: null, hover: null, share: 1, folds: { rows: false, note: false } });
22215
+ var createContextState = () => ({
22216
+ cursor: null,
22217
+ hover: null,
22218
+ target: null,
22219
+ expanded: false,
22220
+ share: 1,
22221
+ folds: { rows: false, trial: false, note: false }
22222
+ });
21938
22223
  var isFoldOpen = (state, name) => state.folds[name];
21939
22224
  function reduceContext(state, action) {
21940
22225
  switch (action.type) {
@@ -21944,6 +22229,10 @@ function reduceContext(state, action) {
21944
22229
  return state.hover === null ? state : { ...state, hover: null };
21945
22230
  case "cursor":
21946
22231
  return { ...state, cursor: action.at, hover: null };
22232
+ case "target":
22233
+ return { ...state, target: action.seq === state.target ? null : action.seq, expanded: false };
22234
+ case "expand":
22235
+ return { ...state, expanded: !state.expanded };
21947
22236
  case "share":
21948
22237
  return { ...state, share: action.value };
21949
22238
  case "fold":
@@ -21955,7 +22244,11 @@ function reduceContext(state, action) {
21955
22244
 
21956
22245
  // dsh/src/client/monitor-context.js
21957
22246
  var h9 = import_react8.default.createElement;
22247
+ var PERCENT6 = 100;
21958
22248
  var SHARE_INPUT_ID = "sw-cx-share";
22249
+ var TRACK_HEIGHT = 20;
22250
+ var AXIS_HEIGHT = 18;
22251
+ var EXCERPT_CHARS = 280;
21959
22252
  var MarkLabel2 = ({ label, className }) => h9(Label, { className: `sw-cx-halo ${className}`, x: label.x, y: label.y, anchor: label.anchor }, label.text);
21960
22253
  function StockChart({ stock, geometry: g, cursor, shown, dispatch, t }) {
21961
22254
  const { series } = stock;
@@ -22026,6 +22319,7 @@ function StockChart({ stock, geometry: g, cursor, shown, dispatch, t }) {
22026
22319
  h9("circle", { className: "sw-cx-actualcross", cx: g.actualCross.x, cy: g.actualCross.y, r: 3.5 }),
22027
22320
  h9(MarkLabel2, { label: g.actualCross.label, className: "sw-cx-ink" })
22028
22321
  ),
22322
+ g.rings.map((ring2) => h9("circle", { key: ring2.at, className: "sw-cx-ring", cx: ring2.x, cy: ring2.y, r: 6, "aria-hidden": "true" })),
22029
22323
  h9("path", { className: "sw-cx-axis", d: g.axisPath }),
22030
22324
  g.xTicks.map((tick) => h9(
22031
22325
  import_react8.default.Fragment,
@@ -22135,15 +22429,32 @@ function RebuildList({ list, state, dispatch, t }) {
22135
22429
  )
22136
22430
  );
22137
22431
  }
22138
- var Figure = ({ name, value, tone }) => h9("div", { className: "sw-cx-kv" }, h9("div", { className: "sw-cx-t" }, name), h9("div", { className: tone === void 0 || tone === "zero" ? "sw-cx-v" : `sw-cx-v sw-cx-${tone}` }, value));
22139
- function CacheSection({ cache, state, dispatch, lamWidth, lamRef, t }) {
22140
- const readout = shareReadoutOf(cache.sums, state.share, t);
22432
+ function CompositionSection({ composition, t }) {
22433
+ const { total, items } = composition;
22434
+ const bar = items.every(({ share }) => share !== null);
22141
22435
  return h9(
22142
22436
  "section",
22143
- { className: "sw-cx-cache", "aria-label": t("monitor.context.cache") },
22144
- h9("div", { className: "sw-cx-h" }, h9("h3", null, t("monitor.context.cache"))),
22145
- h9("div", { className: "sw-cx-sum" }, h9(Figure, { name: t("monitor.context.cache.share"), value: cache.share }), h9(Figure, { name: t("monitor.context.cache.net"), value: cache.net.text, tone: cache.net.tone })),
22146
- cache.chart === null ? null : h9(
22437
+ { className: "sw-cx-comp", "aria-label": t("monitor.context.comp") },
22438
+ h9("div", { className: "sw-cx-h" }, h9("h3", null, t("monitor.context.comp"))),
22439
+ total === null ? null : h9("p", { className: "sw-cx-comp-total" }, t("monitor.context.comp.total", { value: total.text })),
22440
+ bar ? h9("div", { className: "sw-cx-stack", "aria-hidden": "true" }, items.map(({ key, share }) => h9("i", { key, className: "sw-cx-seg", "data-key": key, style: { width: `${(Math.max(0, share) * PERCENT6).toFixed(2)}%` } }))) : null,
22441
+ h9("ul", { className: "sw-cx-comp-list" }, items.map(({ key, text, percent: percent2 }) => h9(
22442
+ "li",
22443
+ { key, className: "sw-cx-comp-row", "data-key": key },
22444
+ h9("i", { className: "sw-cx-swatch", "data-key": key, "aria-hidden": "true" }),
22445
+ h9("span", { className: "sw-cx-comp-name" }, t(`monitor.context.comp.${key}`)),
22446
+ h9("span", { className: "sw-cx-comp-value" }, text ?? NOT_AVAILABLE),
22447
+ h9("span", { className: "sw-cx-comp-percent" }, percent2 ?? NOT_AVAILABLE)
22448
+ )))
22449
+ );
22450
+ }
22451
+ function TrialSection({ cache, state, dispatch, lamWidth, lamRef, t }) {
22452
+ const readout = shareReadoutOf(cache.sums, state.share, t);
22453
+ return h9(
22454
+ "details",
22455
+ { className: "sw-cx-trial", open: isFoldOpen(state, "trial"), onToggle: (event) => dispatch({ type: "fold", name: "trial", open: event.currentTarget.open }) },
22456
+ h9("summary", null, t("monitor.context.trial")),
22457
+ h9(
22147
22458
  "div",
22148
22459
  { className: "sw-cx-card" },
22149
22460
  h9("div", { className: "sw-cx-lamchart", role: "img", "aria-label": cache.chart.label, ref: lamRef }, h9(LamChart, { geometry: lamGeometryOf(cache.sums, state.share, lamWidth), t })),
@@ -22165,8 +22476,102 @@ function CacheSection({ cache, state, dispatch, lamWidth, lamRef, t }) {
22165
22476
  ),
22166
22477
  h9("p", { className: "sw-cx-rd" }, readout),
22167
22478
  cache.crossing === null ? null : h9("p", { className: "sw-cx-thr" }, cache.crossing)
22479
+ )
22480
+ );
22481
+ }
22482
+ function TargetTrack({ graph: g, row: row2 }) {
22483
+ return h9(
22484
+ "svg",
22485
+ { className: "sw-rc-track", width: g.width, height: TRACK_HEIGHT, viewBox: `0 0 ${g.width} ${TRACK_HEIGHT}`, "aria-hidden": "true" },
22486
+ h9("rect", { className: "sw-rc-zero", x: g.zero.x0, y: 0, width: Math.max(0, g.zero.x1 - g.zero.x0), height: TRACK_HEIGHT }),
22487
+ g.seals.map((seal) => h9("line", { key: seal.ordinal, className: "sw-rc-seal", x1: seal.x, y1: 0, x2: seal.x, y2: TRACK_HEIGHT })),
22488
+ h9("line", { className: "sw-rc-rail", x1: g.plotLeft, y1: TRACK_HEIGHT / 2, x2: g.plotLeft + g.plotWidth, y2: TRACK_HEIGHT / 2 }),
22489
+ row2.dots.map((dot) => h9("circle", { key: dot.at, className: "sw-rc-dot", cx: dot.x, cy: TRACK_HEIGHT / 2, r: 3 })),
22490
+ row2.ring === null ? null : h9("circle", { className: "sw-rc-ring", cx: row2.ring.x, cy: TRACK_HEIGHT / 2, r: 4.5 })
22491
+ );
22492
+ }
22493
+ function TargetAxis({ graph: g, t }) {
22494
+ return h9(
22495
+ "svg",
22496
+ { className: "sw-rc-axis", width: g.width, height: AXIS_HEIGHT, viewBox: `0 0 ${g.width} ${AXIS_HEIGHT}`, "aria-hidden": "true" },
22497
+ h9("rect", { className: "sw-rc-zero", x: g.zero.x0, y: 0, width: Math.max(0, g.zero.x1 - g.zero.x0), height: AXIS_HEIGHT }),
22498
+ g.seals.map((seal) => h9("line", { key: seal.ordinal, className: "sw-rc-seal", x1: seal.x, y1: 0, x2: seal.x, y2: AXIS_HEIGHT })),
22499
+ g.zones.map((zone) => h9(Label, { key: zone.label, className: "sw-rc-lbl", x: zone.x + 3, y: AXIS_HEIGHT - 5 }, zone.label))
22500
+ );
22501
+ }
22502
+ function TargetText({ text, expanded, dispatch, t }) {
22503
+ if (text === null) return h9(Notice, { state: "recall-text-loading" }, t("monitor.recall.text.loading"));
22504
+ if (text.kind !== "ready") return h9(Notice, { state: "recall-text-failed" }, text.kind === "unavailable" ? t("monitor.detail.unavailable") : t("monitor.recall.text.failed", { message: text.message }));
22505
+ const excerpt = excerptOf(text.value.text, EXCERPT_CHARS);
22506
+ if (excerpt === null) return h9("p", { className: "sw-mon-note", "data-sw-recall-text": "none" }, t("monitor.recall.text.none"));
22507
+ const count = Array.from(excerpt.text).length + excerpt.hidden;
22508
+ return h9(
22509
+ import_react8.default.Fragment,
22510
+ null,
22511
+ h9("pre", { className: "sw-rc-text", "data-sw-recall-text": expanded || excerpt.hidden === 0 ? "whole" : "excerpt" }, expanded || excerpt.hidden === 0 ? text.value.text : `${excerpt.text}\u2026`),
22512
+ excerpt.hidden === 0 ? null : h9("button", { type: "button", className: "sw-rc-more", "aria-expanded": expanded, onClick: () => dispatch({ type: "expand" }) }, t(expanded ? "monitor.recall.text.collapse" : "monitor.recall.text.expand", { count }))
22513
+ );
22514
+ }
22515
+ function TargetPanel({ selection, state, text, dispatch, t }) {
22516
+ return h9(
22517
+ "div",
22518
+ { className: "sw-rc-panel", "data-sw-target": selection.seq },
22519
+ h9("h4", { className: "sw-rc-title" }, selection.title),
22520
+ h9("p", { className: "sw-rc-landing" }, selection.landing),
22521
+ h9(TargetText, { text, expanded: state.expanded, dispatch, t }),
22522
+ selection.reads.length === 0 ? null : h9("ul", { className: "sw-rc-reads", "aria-label": t("monitor.recall.reads") }, selection.reads.map((read) => h9(
22523
+ "li",
22524
+ { key: read.at },
22525
+ read.call === null ? h9("span", { className: "sw-rc-read" }, read.label) : h9("button", { type: "button", className: "sw-rc-read", "aria-label": t("monitor.recall.read.call", { at: read.at, call: read.call }), onClick: () => dispatch({ type: "cursor", at: read.call }) }, read.label)
22526
+ )))
22527
+ );
22528
+ }
22529
+ function TargetSection({ graph, state, text, dispatch, graphRef, t }) {
22530
+ const selection = selectionOf(graph, state.target, t);
22531
+ return h9(
22532
+ "section",
22533
+ { className: "sw-rc", "aria-label": t("monitor.recall.heading") },
22534
+ h9(
22535
+ "div",
22536
+ { className: "sw-cx-h" },
22537
+ h9("h3", null, t("monitor.recall.heading")),
22538
+ h9("span", { className: "sw-cx-tag" }, [t("monitor.recall.count", { count: graph.count }), ...graph.repeated > 0 ? [t("monitor.recall.repeated", { count: graph.repeated })] : []].join(PART_SEPARATOR))
22539
+ ),
22540
+ graph.rows.length === 0 ? h9("p", { className: "sw-mon-note", "data-sw-recall": "none" }, t("monitor.recall.none")) : h9(
22541
+ "div",
22542
+ { className: "sw-rc-chart", ref: graphRef },
22543
+ h9(TargetAxis, { graph, t }),
22544
+ h9("ul", { className: "sw-rc-list", "aria-label": t("monitor.recall.heading") }, graph.rows.map((row2) => h9(
22545
+ "li",
22546
+ { key: row2.seq },
22547
+ h9(
22548
+ "button",
22549
+ {
22550
+ type: "button",
22551
+ className: "sw-rc-row",
22552
+ "data-seq": row2.seq,
22553
+ "aria-pressed": state.target === row2.seq,
22554
+ "aria-label": row2.label,
22555
+ onClick: () => dispatch({ type: "target", seq: row2.seq })
22556
+ },
22557
+ h9("span", { className: "sw-rc-name" }, t("monitor.recall.title", { seq: row2.seq, name: row2.name }), h9("small", null, t("monitor.recall.row.count", { count: row2.count }))),
22558
+ h9(TargetTrack, { graph, row: row2 })
22559
+ )
22560
+ ))),
22561
+ h9(
22562
+ "p",
22563
+ { className: "sw-rc-keys", "aria-hidden": "true" },
22564
+ h9("i", { className: "sw-rc-key sw-rc-ring-key" }),
22565
+ t("monitor.recall.legend.original"),
22566
+ h9("i", { className: "sw-rc-key sw-rc-dot-key" }),
22567
+ t("monitor.recall.legend.read"),
22568
+ h9("i", { className: "sw-rc-key sw-rc-seal-key" }),
22569
+ t("monitor.recall.legend.seal"),
22570
+ h9("i", { className: "sw-rc-key sw-rc-zero-key" }),
22571
+ t("monitor.recall.legend.zero")
22572
+ )
22168
22573
  ),
22169
- cache.list === null ? null : h9(RebuildList, { list: cache.list, state, dispatch, t })
22574
+ selection === null ? null : h9(TargetPanel, { selection, state, text, dispatch, t })
22170
22575
  );
22171
22576
  }
22172
22577
  function Note({ state, dispatch, t }) {
@@ -22177,18 +22582,23 @@ function Note({ state, dispatch, t }) {
22177
22582
  h9("div", { className: "sw-cx-in" }, h9("p", null, t("monitor.context.note.line")))
22178
22583
  );
22179
22584
  }
22180
- function ContextView({ model, state, dispatch, width, lamWidth, chartRef, lamRef, notice: notice2, t }) {
22585
+ function ContextView({ model, state, dispatch, width, lamWidth, graphWidth, chartRef, lamRef, graphRef, notice: notice2, text = null, t }) {
22181
22586
  const { stock } = model;
22182
22587
  const shown = state.hover ?? state.cursor;
22588
+ const graph = targetGraphOf(model.view, stock === null ? null : stock.series, graphWidth, t);
22589
+ const rings = selectionOf(graph, state.target, t)?.reads.flatMap(({ call }) => call === null ? [] : [call]) ?? [];
22183
22590
  return h9(
22184
22591
  "div",
22185
22592
  { className: "sw-cx" },
22186
22593
  stock === null ? null : h9(Readout, { lines: readoutOf(stock.series, stock.line, shown, t), t }),
22187
- h9("p", { className: "sw-cx-ctx" }, [model.count, model.calls].filter((text) => text !== null).join(PART_SEPARATOR)),
22594
+ h9("p", { className: "sw-cx-ctx" }, [model.count, model.calls].filter((value) => value !== null).join(PART_SEPARATOR)),
22188
22595
  model.loading ? h9(Notice, { state: "context-loading" }, t("monitor.detail.loading")) : null,
22189
- stock === null ? null : h9(StockBlock, { stock, geometry: stockGeometryOf(stock.series, stock.line, width, t), state, shown, chartRef, dispatch, t }),
22596
+ stock === null ? null : h9(StockBlock, { stock, geometry: stockGeometryOf(stock.series, stock.line, width, t, rings), state, shown, chartRef, dispatch, t }),
22190
22597
  notice2,
22191
- h9(CacheSection, { cache: model.cache, state, dispatch, lamWidth, lamRef, t }),
22598
+ model.composition === null ? null : h9(CompositionSection, { composition: model.composition, t }),
22599
+ model.cache.list === null ? null : h9(RebuildList, { list: model.cache.list, state, dispatch, t }),
22600
+ graph === null ? null : h9(TargetSection, { graph, state, text, dispatch, graphRef, t }),
22601
+ model.cache.chart === null ? null : h9(TrialSection, { cache: model.cache, state, dispatch, lamWidth, lamRef, t }),
22192
22602
  stock === null || stock.line === null ? null : h9(Note, { state, dispatch, t }),
22193
22603
  h9("div", { className: "sw-cx-pin" }, h9("p", { className: "sw-cx-unit" }, t("monitor.settlement.unit")))
22194
22604
  );
@@ -22197,22 +22607,40 @@ function useAmberLine(session, epoch) {
22197
22607
  const read = () => amberLineOf(session.result, epoch);
22198
22608
  return import_react8.default.useSyncExternalStore(session.subscribe, read, read);
22199
22609
  }
22610
+ var NO_TARGET = Object.freeze({ selected: null, result: null });
22611
+ var noSubscription = () => () => {
22612
+ };
22613
+ function useTargetReader(monitor, cut) {
22614
+ const reader = import_react8.default.useMemo(
22615
+ () => monitor === void 0 || !Number.isSafeInteger(cut?.segment) || !Number.isSafeInteger(cut?.through) ? null : monitor.settlementTarget({ segment: cut.segment, through: cut.through }),
22616
+ [monitor, cut?.segment, cut?.through]
22617
+ );
22618
+ const read = () => reader?.state ?? NO_TARGET;
22619
+ return { reader, read: import_react8.default.useSyncExternalStore(reader?.subscribe ?? noSubscription, read, read) };
22620
+ }
22200
22621
  function ContextPage({ settlement, handoffId, monitor, session, t }) {
22201
22622
  const result = useSettlementResult(monitor, handoffId);
22202
22623
  const line = useAmberLine(session, settlement.epoch);
22203
- return h9(ContextReport, { model: contextPageOf(settlement, result, line, t), result, t });
22624
+ return h9(ContextReport, { model: contextPageOf(settlement, result, line, t), monitor, t });
22204
22625
  }
22205
- function ContextReport({ model, result, current, t }) {
22626
+ function ContextReport({ model, current, monitor, t }) {
22206
22627
  const [state, dispatch] = import_react8.default.useReducer(reduceContext, void 0, createContextState);
22207
22628
  const [chartRef, width] = useElementWidth();
22208
22629
  const [lamRef, lamWidth] = useElementWidth();
22630
+ const [graphRef, graphWidth] = useElementWidth();
22631
+ const { reader, read } = useTargetReader(monitor, model.view.response?.cut);
22632
+ const graph = targetGraphOf(model.view, model.stock === null ? null : model.stock.series, graphWidth, t);
22633
+ const chosen = selectionOf(graph, state.target, t) === null ? null : state.target;
22634
+ import_react8.default.useEffect(() => {
22635
+ reader?.select(chosen);
22636
+ }, [reader, chosen]);
22209
22637
  const notice2 = h9(
22210
22638
  import_react8.default.Fragment,
22211
22639
  null,
22212
22640
  current && model.stock === null ? h9(Notice, { state: "current-stock-unavailable" }, t("monitor.settlement.current.stockUnavailable")) : null,
22213
- h9(RecallNotice, { result, partial: model.recallPartial, t })
22641
+ h9(RecallNotice, { evidence: model.view.evidence, partial: model.recallPartial, priced: model.priced, t })
22214
22642
  );
22215
- return h9(ContextView, { model, state, dispatch, width, lamWidth, chartRef, lamRef, notice: notice2, t });
22643
+ return h9(ContextView, { model, state, dispatch, width, lamWidth, graphWidth, chartRef, lamRef, graphRef, notice: notice2, text: read.selected === chosen ? read.result : null, t });
22216
22644
  }
22217
22645
 
22218
22646
  // dsh/src/client/monitor-drawer.js
@@ -22258,12 +22686,12 @@ function CarrierCache({ evidence, t }) {
22258
22686
  );
22259
22687
  }
22260
22688
  var seqText = (seq, t) => seq === null || seq === void 0 ? h10(Missing, { t }) : t("monitor.overview.seq", { seq });
22261
- var selectionOf = (request) => request.options ?? {};
22689
+ var selectionOf2 = (request) => request.options ?? {};
22262
22690
  function OverviewPage({ detail, payback = /* @__PURE__ */ new Map(), t }) {
22263
22691
  const { row: row2, ids, request } = detail;
22264
22692
  const status = shownStatusOf(row2, payback);
22265
22693
  const progress = payback.get(row2.id);
22266
- const { provider, model, reasoningEffort } = selectionOf(request);
22694
+ const { provider, model, reasoningEffort } = selectionOf2(request);
22267
22695
  const present = (value) => value === void 0 || value === null ? h10(Missing, { t }) : value;
22268
22696
  const entries = [
22269
22697
  [t("monitor.overview.status"), h10("span", { className: "sw-mon-status", "data-status": status }, t(`monitor.status.${status}`))],
@@ -22294,7 +22722,7 @@ function ToolsSection({ tools, t }) {
22294
22722
  }
22295
22723
  function RequestPage({ detail, t }) {
22296
22724
  const { request } = detail;
22297
- const options = Object.entries(selectionOf(request)).map(([name, value]) => [name, stringOf(value)]);
22725
+ const options = Object.entries(selectionOf2(request)).map(([name, value]) => [name, stringOf(value)]);
22298
22726
  const updates = request.toolHistory?.updates;
22299
22727
  return h10(
22300
22728
  import_react9.default.Fragment,
@@ -22416,11 +22844,15 @@ function QuotePage({ detail, t }) {
22416
22844
  h10(Facts, { entries: quoteFactsOf(detail.quote, t).map(([term, value]) => [term, value ?? h10(Missing, { t })]) })
22417
22845
  );
22418
22846
  }
22419
- function SourceEvent({ event, t }) {
22847
+ function SourceEvent({ event, opened, t }) {
22420
22848
  const { seq, type, visible, blocks, raw } = event;
22849
+ const ref = import_react9.default.useRef(null);
22850
+ import_react9.default.useEffect(() => {
22851
+ if (opened) ref.current.querySelector("summary").focus();
22852
+ }, [opened]);
22421
22853
  return h10(
22422
22854
  "details",
22423
- { className: "sw-mon-event", "data-sw-event": "", "data-seq": seq, "data-visible": String(visible), open: visible },
22855
+ { ref, className: "sw-mon-event", "data-sw-event": "", "data-seq": seq, "data-visible": String(visible), "data-sw-opened": opened ? "" : void 0, open: visible || opened },
22424
22856
  h10(
22425
22857
  "summary",
22426
22858
  null,
@@ -22442,11 +22874,87 @@ function SlotOverviewPage({ detail, t }) {
22442
22874
  function SlotSummaryPage({ detail, t }) {
22443
22875
  return h10(Section, { name: "c" }, h10(WholeText, { text: detail.c, t }));
22444
22876
  }
22445
- function SlotSourcePage({ detail, t }) {
22877
+ function SlotSourcePage({ detail, opened = null, t }) {
22446
22878
  return h10(
22447
22879
  Section,
22448
22880
  { name: "sources", title: t("monitor.slot.sources") },
22449
- detail.events.map((event) => h10(SourceEvent, { key: event.seq, event, t }))
22881
+ detail.events.map((event) => h10(SourceEvent, { key: event.seq, event, opened: opened?.seq === event.seq, t }))
22882
+ );
22883
+ }
22884
+ var DIRECT_READS = ["handoff-recall", "carrier-recall", "verbatim-recall"];
22885
+ var warningText = (kind, t) => t(DIRECT_READS.includes(kind) ? `monitor.tool.attempt.${kind}` : `monitor.warning.${kind}`);
22886
+ function cardWarningText(warning, t) {
22887
+ switch (warning.kind) {
22888
+ case "state-check":
22889
+ case "state-mixed":
22890
+ return t("monitor.tool.stateQuery");
22891
+ case "state-write":
22892
+ return t("monitor.tool.stateWrite");
22893
+ case "old-attribution": {
22894
+ const { percent: percent2, over, oldLines, newLines } = warning;
22895
+ return t("monitor.tool.oldAttribution", { label: t("monitor.warning.old-attribution"), percent: percent2 === null ? NOT_AVAILABLE : `${over ? ">" : ""}${percent2}%`, oldLines, newLines });
22896
+ }
22897
+ default:
22898
+ return warningText(warning.kind, t);
22899
+ }
22900
+ }
22901
+ var resultBlocksOf = (events, seq) => events.find((event) => event.seq === seq)?.blocks.find((block) => block.type === "tool-result")?.blocks ?? [];
22902
+ function toolStatesOf({ input, result }) {
22903
+ return [
22904
+ ...input === null ? [["no-input", "monitor.tool.noInput"]] : [],
22905
+ ...result === null ? [["no-result", "monitor.tool.noResult"]] : result.error ? [["error", "monitor.tool.failed"]] : result.empty ? [["empty-result", "monitor.tool.emptyResult"]] : []
22906
+ ];
22907
+ }
22908
+ function ToolCard({ card: { id, name, input, result, pruned, warnings }, events, open, t }) {
22909
+ return h10(
22910
+ "article",
22911
+ { className: "sw-mon-tool", "data-sw-tool": id },
22912
+ h10(
22913
+ "div",
22914
+ { className: "sw-mon-tool-head" },
22915
+ h10("span", { className: "sw-mon-tool-name" }, name ?? t("monitor.notRecorded")),
22916
+ toolStatesOf({ input, result }).map(([state, key]) => h10("span", { key: state, className: "sw-mon-tool-state", "data-state": state }, t(key)))
22917
+ ),
22918
+ warnings.length === 0 ? null : h10(
22919
+ "ul",
22920
+ { className: "sw-mon-tool-warnings" },
22921
+ warnings.map((warning) => h10("li", { key: warning.kind, className: "sw-mon-tool-warning", "data-sw-warning": warning.kind, "data-sw-attention": "" }, cardWarningText(warning, t)))
22922
+ ),
22923
+ pruned === null ? null : h10(
22924
+ "p",
22925
+ { className: "sw-mon-tool-pruned", "data-sw-pruned": "" },
22926
+ t("monitor.tool.pruned"),
22927
+ " ",
22928
+ h10("button", { type: "button", className: "sw-mon-link", "data-sw-open-source": pruned.seq, onClick: () => {
22929
+ open?.(pruned.seq);
22930
+ } }, t("monitor.tool.openPruned", { seq: pruned.seq }))
22931
+ ),
22932
+ input === null ? null : h10("details", { className: "sw-mon-fold", "data-sw-tool-section": "input" }, h10("summary", null, t("monitor.tool.input")), h10(WholeText, { text: input, t })),
22933
+ result === null || result.empty ? null : h10(
22934
+ "details",
22935
+ { className: "sw-mon-fold", "data-sw-tool-section": "output" },
22936
+ h10("summary", null, t("monitor.tool.output")),
22937
+ h10(Blocks, { blocks: resultBlocksOf(events, result.seq), t })
22938
+ )
22939
+ );
22940
+ }
22941
+ function SlotToolsPage({ detail, open, t }) {
22942
+ const { warnings, calls } = detail.tools;
22943
+ const explains = warnings.includes("old-attribution") || calls.some((card) => card.warnings.some(({ kind }) => kind === "old-attribution"));
22944
+ return h10(
22945
+ import_react9.default.Fragment,
22946
+ null,
22947
+ warnings.length === 0 && !explains ? null : h10(
22948
+ Section,
22949
+ { name: "warnings" },
22950
+ warnings.length === 0 ? null : h10(
22951
+ "ul",
22952
+ { className: "sw-mon-tool-warnings" },
22953
+ warnings.map((kind) => h10("li", { key: kind, className: "sw-mon-tool-warning", "data-sw-warning": kind, "data-sw-attention": "" }, warningText(kind, t)))
22954
+ ),
22955
+ explains ? h10("p", { className: "sw-mon-note", "data-sw-old-note": "" }, t("monitor.tool.oldNote")) : null
22956
+ ),
22957
+ calls.map((card, at) => h10(ToolCard, { key: at, card, events: detail.events, open, t }))
22450
22958
  );
22451
22959
  }
22452
22960
  function HandoffOverviewPage({ detail, t }) {
@@ -22495,8 +23003,10 @@ var CALL_PAGES = { overview: OverviewPage, request: RequestPage, response: Respo
22495
23003
  var SLOT_PAGES = { overview: SlotOverviewPage, summary: SlotSummaryPage, source: SlotSourcePage };
22496
23004
  var HANDOFF_PAGES = { overview: HandoffOverviewPage, summary: HandoffSummaryPage, files: HandoffFilesPage, turns: HandoffTurnsPage, lineage: HandoffLineagePage };
22497
23005
  var SETTLEMENT_PAGES = { payback: PaybackPage, context: ContextPage };
22498
- function PagedDetail({ pages, first, labels, ...props }) {
22499
- const [page, setPage] = import_react9.default.useState(first);
23006
+ function PagedDetail({ pages, first, labels, page: given, onPage, ...props }) {
23007
+ const [own, setOwn] = import_react9.default.useState(first);
23008
+ const page = pages[given ?? own] === void 0 ? first : given ?? own;
23009
+ const select = onPage ?? setOwn;
22500
23010
  const Page = pages[page];
22501
23011
  return h10(
22502
23012
  import_react9.default.Fragment,
@@ -22509,7 +23019,7 @@ function PagedDetail({ pages, first, labels, ...props }) {
22509
23019
  "data-page": name,
22510
23020
  "aria-selected": name === page,
22511
23021
  onClick: () => {
22512
- setPage(name);
23022
+ select(name);
22513
23023
  }
22514
23024
  }, props.t(`${labels}.${name}`)))),
22515
23025
  h10("div", { className: "sw-mon-page", role: "tabpanel", "data-page": page }, h10(Page, props))
@@ -22518,8 +23028,20 @@ function PagedDetail({ pages, first, labels, ...props }) {
22518
23028
  function CallDetail({ detail, monitor, attemptId, payback, now, t }) {
22519
23029
  return h10(PagedDetail, { pages: CALL_PAGES, first: "overview", labels: "monitor.page", detail, monitor, attemptId, payback, now, t });
22520
23030
  }
23031
+ var hasTools = ({ tools }) => tools !== void 0 && (tools.calls.length > 0 || tools.warnings.length > 0);
22521
23032
  function SlotDetail({ detail, t }) {
22522
- return h10(PagedDetail, { pages: SLOT_PAGES, first: "summary", labels: "monitor.slotPage", detail, t });
23033
+ const [page, setPage] = import_react9.default.useState("summary");
23034
+ const [opened, setOpened] = import_react9.default.useState(null);
23035
+ const pages = hasTools(detail) ? { ...SLOT_PAGES, tools: SlotToolsPage } : SLOT_PAGES;
23036
+ const select = (name) => {
23037
+ setOpened(null);
23038
+ setPage(name);
23039
+ };
23040
+ const open = (seq) => {
23041
+ setOpened({ seq });
23042
+ setPage("source");
23043
+ };
23044
+ return h10(PagedDetail, { pages, first: "summary", page, onPage: select, labels: "monitor.slotPage", detail, opened, open, t });
22523
23045
  }
22524
23046
  function HandoffDetail({ detail, t }) {
22525
23047
  const pages = detail.row.type === "load" ? HANDOFF_PAGES : Object.fromEntries(Object.entries(HANDOFF_PAGES).filter(([name]) => name !== "lineage"));
@@ -22529,19 +23051,19 @@ function SettlementDetail({ settlement, handoffId, monitor, session, t }) {
22529
23051
  return settlement === void 0 ? null : h10(PagedDetail, { pages: SETTLEMENT_PAGES, first: "payback", labels: "monitor.settlementPage", settlement, handoffId, monitor, session, t });
22530
23052
  }
22531
23053
  var CURRENT_SETTLEMENT_PAGES = {
22532
- payback: ({ detail: { base, report, curve, snapshot }, t }) => h10(PaybackReport, { model: paybackModelOf(base, report, curve, t, true), result: snapshot, t }),
22533
- context: ({ detail: { base, report, snapshot }, t }) => h10(ContextReport, { model: contextModelOf(base, report, snapshot, null, t), result: snapshot, current: true, t })
23054
+ payback: ({ view, t }) => h10(PaybackReport, { model: paybackPageOf(view, t, true), t }),
23055
+ context: ({ view, monitor, t }) => h10(ContextReport, { model: contextModelOf(view, null, t), current: true, monitor, t })
22534
23056
  };
22535
- function CurrentSettlementDetail({ result, t }) {
22536
- return h10(DetailBody, { result, t, render: (detail) => {
22537
- const { base, report } = detail;
22538
- if (base.count === 0) return h10(Notice, { state: "current-empty" }, t("monitor.settlement.current.empty"));
22539
- if (report === null) return h10(Notice, { state: "current-pending" }, t("monitor.settlement.current.pending"));
23057
+ function CurrentSettlementDetail({ result, monitor, t }) {
23058
+ return h10(DetailBody, { result, t, render: () => {
23059
+ const view = settlementViewOf(null, result);
23060
+ if (view.base.count === 0) return h10(Notice, { state: "current-empty" }, t("monitor.settlement.current.empty"));
23061
+ if (!view.priced) return h10(Notice, { state: "current-pending" }, t("monitor.settlement.recall.unpriced"));
22540
23062
  return h10(
22541
23063
  import_react9.default.Fragment,
22542
23064
  null,
22543
- base.rows.some((row2) => row2.saved === null) ? h10(Notice, { state: "current-partial" }, t("monitor.settlement.current.partial")) : null,
22544
- h10(PagedDetail, { pages: CURRENT_SETTLEMENT_PAGES, first: "payback", labels: "monitor.settlementPage", detail, t })
23065
+ view.base.rows.some((row2) => row2.saved === null) ? h10(Notice, { state: "current-partial" }, t("monitor.settlement.current.partial")) : null,
23066
+ h10(PagedDetail, { pages: CURRENT_SETTLEMENT_PAGES, first: "payback", labels: "monitor.settlementPage", view, monitor, t })
22545
23067
  );
22546
23068
  } });
22547
23069
  }
@@ -22741,10 +23263,10 @@ function MonitorDrawer({ state, monitor, session, ordinals, payback, handoffs =
22741
23263
  let subtitle;
22742
23264
  let body;
22743
23265
  if (kind === "current-settlement") {
22744
- const value = selected.result?.kind === "ready" ? selected.result.value : null;
22745
- title = value === null ? t("monitor.toolbar.currentSettlement") : t("monitor.drawer.settlement", { epoch: value.base.epoch });
22746
- subtitle = value === null ? null : h11("p", { className: "sw-mon-drawer-sub" }, t("monitor.settlement.current.through", { step: value.base.steps }));
22747
- body = h11(CurrentSettlementDetail, { key: identity, result: selected.result, t });
23266
+ const { base } = selected.result?.kind === "ready" ? settlementViewOf(null, selected.result) : { base: null };
23267
+ title = base === null ? t("monitor.toolbar.currentSettlement") : t("monitor.drawer.settlement", { epoch: base.epoch });
23268
+ subtitle = base === null ? null : h11("p", { className: "sw-mon-drawer-sub" }, t("monitor.settlement.current.through", { step: base.steps }));
23269
+ body = h11(CurrentSettlementDetail, { key: identity, result: selected.result, monitor, t });
22748
23270
  } else if (kind === "settlement") {
22749
23271
  const settlement = settlements.get(handoffId);
22750
23272
  title = t("monitor.drawer.settlement", { epoch: settlement === void 0 ? NOT_AVAILABLE : settlement.epoch });
@@ -26225,6 +26747,7 @@ var MONITOR_CSS = `[data-sw-monitor] {
26225
26747
  }
26226
26748
  [data-sw-monitor] .sw-mon-close:focus-visible,
26227
26749
  [data-sw-monitor] .sw-mon-fbtn:focus-visible,
26750
+ [data-sw-monitor] .sw-mon-link:focus-visible,
26228
26751
  [data-sw-monitor] .sw-mon-tab:focus-visible {
26229
26752
  outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
26230
26753
  outline-offset: -1px;
@@ -26354,6 +26877,57 @@ var MONITOR_CSS = `[data-sw-monitor] {
26354
26877
  [data-sw-monitor] .sw-mon-tag[data-tag="earlier"] {
26355
26878
  color: var(--dsw-alias-state-warn-primary);
26356
26879
  }
26880
+ [data-sw-monitor] .sw-mon-event[data-sw-opened] {
26881
+ border-color: var(--dsw-alias-state-business-primary);
26882
+ }
26883
+ [data-sw-monitor] .sw-mon-tool {
26884
+ margin: 0 0 12px;
26885
+ padding: 6px 8px;
26886
+ border: 0.5px solid var(--dsw-alias-border-l1);
26887
+ border-radius: 4px;
26888
+ corner-shape: round;
26889
+ }
26890
+ [data-sw-monitor] .sw-mon-tool-head {
26891
+ display: flex;
26892
+ flex-wrap: wrap;
26893
+ align-items: baseline;
26894
+ gap: 2px 10px;
26895
+ margin: 0 0 4px;
26896
+ }
26897
+ [data-sw-monitor] .sw-mon-tool-name {
26898
+ min-width: 0;
26899
+ color: var(--dsw-alias-label-primary);
26900
+ font-weight: 600;
26901
+ overflow-wrap: anywhere;
26902
+ }
26903
+ [data-sw-monitor] .sw-mon-tool-state {
26904
+ color: var(--dsw-alias-label-tertiary);
26905
+ }
26906
+ [data-sw-monitor] .sw-mon-tool-state[data-state="error"] {
26907
+ color: var(--dsw-alias-state-error-primary);
26908
+ }
26909
+ [data-sw-monitor] .sw-mon-tool-warnings {
26910
+ margin: 0 0 4px;
26911
+ padding: 0;
26912
+ list-style: none;
26913
+ }
26914
+ [data-sw-monitor] .sw-mon-tool-warning {
26915
+ color: var(--dsw-alias-state-warn-primary);
26916
+ overflow-wrap: anywhere;
26917
+ }
26918
+ [data-sw-monitor] .sw-mon-tool-pruned {
26919
+ margin: 0 0 4px;
26920
+ color: var(--dsw-alias-label-tertiary);
26921
+ }
26922
+ [data-sw-monitor] .sw-mon-link {
26923
+ padding: 0;
26924
+ border: 0;
26925
+ background: none;
26926
+ color: var(--dsw-alias-state-business-primary);
26927
+ cursor: pointer;
26928
+ font: inherit;
26929
+ text-decoration: underline;
26930
+ }
26357
26931
  [data-sw-monitor] .sw-mon-fold,
26358
26932
  [data-sw-monitor] .sw-mon-event {
26359
26933
  margin: 0 0 8px;
@@ -26715,6 +27289,10 @@ var MONITOR_CSS = `[data-sw-monitor] {
26715
27289
  margin: 6px 0 0;
26716
27290
  color: var(--dsw-alias-label-secondary);
26717
27291
  }
27292
+ [data-sw-monitor] .sw-pb-share {
27293
+ margin: 6px 0 0;
27294
+ color: var(--dsw-alias-label-secondary);
27295
+ }
26718
27296
  [data-sw-monitor] .sw-pb-facts p {
26719
27297
  margin: 0;
26720
27298
  }
@@ -27339,34 +27917,240 @@ var MONITOR_CSS = `[data-sw-monitor] {
27339
27917
  [data-sw-monitor] .sw-cx-assume {
27340
27918
  color: var(--dsw-alias-label-tertiary);
27341
27919
  }
27342
- [data-sw-monitor] .sw-cx-cache {
27920
+ [data-sw-monitor] .sw-cx-comp {
27343
27921
  margin: 12px 0 0;
27344
27922
  }
27345
- [data-sw-monitor] .sw-cx-sum {
27923
+ [data-sw-monitor] .sw-cx-comp-total {
27924
+ margin: 0 0 6px;
27925
+ font: var(--dsw-font-xs-13);
27926
+ font-variant-numeric: tabular-nums;
27927
+ font-weight: 600;
27928
+ }
27929
+ [data-sw-monitor] .sw-cx-stack {
27930
+ display: flex;
27931
+ height: 8px;
27932
+ margin: 0 0 8px;
27933
+ overflow: hidden;
27934
+ border-radius: 4px;
27935
+ background: var(--dsw-alias-border-l2);
27936
+ }
27937
+ [data-sw-monitor] .sw-cx-seg {
27938
+ display: block;
27939
+ height: 100%;
27940
+ }
27941
+ [data-sw-monitor] .sw-cx-seg[data-key='summary'],
27942
+ [data-sw-monitor] .sw-cx-swatch[data-key='summary'] {
27943
+ background: var(--dsw-alias-border-l4);
27944
+ }
27945
+ [data-sw-monitor] .sw-cx-seg[data-key='rebuild'],
27946
+ [data-sw-monitor] .sw-cx-swatch[data-key='rebuild'] {
27947
+ background: var(--dsw-alias-label-tertiary);
27948
+ }
27949
+ [data-sw-monitor] .sw-cx-seg[data-key='recall'],
27950
+ [data-sw-monitor] .sw-cx-swatch[data-key='recall'] {
27951
+ background: var(--dsw-alias-state-business-primary);
27952
+ }
27953
+ [data-sw-monitor] .sw-cx-comp-list {
27954
+ margin: 0;
27955
+ padding: 0;
27956
+ list-style: none;
27957
+ }
27958
+ [data-sw-monitor] .sw-cx-comp-row {
27346
27959
  display: grid;
27347
- grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
27348
- gap: 6px;
27349
- margin: 0 0 10px;
27960
+ grid-template-columns: 10px minmax(0, 1fr) auto 52px;
27961
+ gap: 0 8px;
27962
+ align-items: center;
27963
+ padding: 3px 0;
27964
+ border-bottom: 0.5px solid var(--dsw-alias-border-l1);
27350
27965
  }
27351
- [data-sw-monitor] .sw-cx-kv {
27352
- padding: 6px 8px;
27353
- border: 0.5px solid var(--dsw-alias-border-l2);
27966
+ [data-sw-monitor] .sw-cx-swatch {
27967
+ width: 10px;
27968
+ height: 10px;
27969
+ border-radius: 2px;
27970
+ }
27971
+ [data-sw-monitor] .sw-cx-comp-name {
27972
+ overflow-wrap: anywhere;
27973
+ }
27974
+ [data-sw-monitor] .sw-cx-comp-value,
27975
+ [data-sw-monitor] .sw-cx-comp-percent {
27976
+ font-variant-numeric: tabular-nums;
27977
+ text-align: right;
27978
+ }
27979
+ [data-sw-monitor] .sw-cx-comp-percent {
27980
+ color: var(--dsw-alias-label-secondary);
27981
+ }
27982
+ [data-sw-monitor] .sw-cx-ring {
27983
+ fill: none;
27984
+ stroke: var(--dsw-alias-state-business-primary);
27985
+ stroke-width: 2;
27986
+ }
27987
+ [data-sw-monitor] .sw-cx-trial {
27988
+ margin: 8px 0 0;
27989
+ }
27990
+ [data-sw-monitor] .sw-cx-trial > summary {
27991
+ padding: 3px 0;
27354
27992
  border-radius: var(--dsw-radius-sm);
27355
- corner-shape: round;
27993
+ color: var(--dsw-alias-label-secondary);
27994
+ cursor: pointer;
27356
27995
  }
27357
- [data-sw-monitor] .sw-cx-t {
27358
- color: var(--dsw-alias-label-tertiary);
27996
+ [data-sw-monitor] .sw-rc {
27997
+ margin: 12px 0 0;
27359
27998
  }
27360
- [data-sw-monitor] .sw-cx-v {
27361
- font: var(--dsw-font-xs-13);
27999
+ [data-sw-monitor] .sw-rc-axis,
28000
+ [data-sw-monitor] .sw-rc-track {
28001
+ display: block;
28002
+ max-width: 100%;
28003
+ height: auto;
28004
+ overflow: visible;
28005
+ }
28006
+ [data-sw-monitor] .sw-rc-zero {
28007
+ fill: var(--dsw-alias-border-l1, transparent);
28008
+ }
28009
+ [data-sw-monitor] .sw-rc-seal {
28010
+ stroke: var(--dsw-alias-label-tertiary);
28011
+ stroke-width: 1;
28012
+ }
28013
+ [data-sw-monitor] .sw-rc-rail {
28014
+ stroke: var(--dsw-alias-border-l2);
28015
+ stroke-width: 1;
28016
+ }
28017
+ [data-sw-monitor] .sw-rc-lbl {
28018
+ fill: var(--dsw-alias-label-tertiary);
28019
+ font: var(--dsw-font-xxxs-11);
27362
28020
  font-variant-numeric: tabular-nums;
28021
+ }
28022
+ [data-sw-monitor] .sw-rc-ring {
28023
+ fill: var(--dsw-alias-bg-layer-1);
28024
+ stroke: var(--dsw-alias-state-warn-primary);
28025
+ stroke-width: 1.75;
28026
+ }
28027
+ [data-sw-monitor] .sw-rc-dot {
28028
+ fill: var(--dsw-alias-label-primary);
28029
+ }
28030
+ [data-sw-monitor] .sw-rc-list {
28031
+ margin: 2px 0 0;
28032
+ padding: 0;
28033
+ list-style: none;
28034
+ }
28035
+ [data-sw-monitor] .sw-rc-row {
28036
+ display: block;
28037
+ box-sizing: border-box;
28038
+ width: 100%;
28039
+ margin: 0;
28040
+ padding: 4px 0 2px;
28041
+ border: 0;
28042
+ border-bottom: 0.5px solid var(--dsw-alias-border-l1);
28043
+ background: transparent;
28044
+ color: inherit;
28045
+ cursor: pointer;
28046
+ font: inherit;
28047
+ text-align: left;
28048
+ }
28049
+ [data-sw-monitor] .sw-rc-row[aria-pressed='true'] {
28050
+ background: var(--dsw-alias-interactive-bg-hover);
28051
+ box-shadow: inset 2px 0 0 var(--dsw-alias-state-business-primary);
28052
+ }
28053
+ @media (hover: hover) {
28054
+ [data-sw-monitor] .sw-rc-row:hover {
28055
+ background: var(--dsw-alias-interactive-bg-hover);
28056
+ }
28057
+ }
28058
+ [data-sw-monitor] .sw-rc-name {
28059
+ display: flex;
28060
+ flex-wrap: wrap;
28061
+ justify-content: space-between;
28062
+ gap: 0 8px;
28063
+ padding: 0 4px;
27363
28064
  font-weight: 600;
28065
+ overflow-wrap: anywhere;
27364
28066
  }
27365
- [data-sw-monitor] .sw-cx-v.sw-cx-neg {
27366
- color: var(--dsw-alias-state-error-primary);
28067
+ [data-sw-monitor] .sw-rc-name small {
28068
+ color: var(--dsw-alias-label-tertiary);
28069
+ font: var(--dsw-font-xxxs-11);
28070
+ font-weight: 400;
27367
28071
  }
27368
- [data-sw-monitor] .sw-cx-v.sw-cx-pos {
27369
- color: var(--dsw-alias-state-success-primary);
28072
+ [data-sw-monitor] .sw-rc-keys {
28073
+ display: flex;
28074
+ flex-wrap: wrap;
28075
+ align-items: center;
28076
+ gap: 2px 6px;
28077
+ margin: 6px 0 0;
28078
+ color: var(--dsw-alias-label-tertiary);
28079
+ font: var(--dsw-font-xxxs-11);
28080
+ }
28081
+ [data-sw-monitor] .sw-rc-key {
28082
+ display: inline-block;
28083
+ box-sizing: border-box;
28084
+ width: 9px;
28085
+ height: 9px;
28086
+ margin: 0 0 0 6px;
28087
+ }
28088
+ [data-sw-monitor] .sw-rc-ring-key {
28089
+ border: 1.75px solid var(--dsw-alias-state-warn-primary);
28090
+ border-radius: 50%;
28091
+ }
28092
+ [data-sw-monitor] .sw-rc-dot-key {
28093
+ border-radius: 50%;
28094
+ background: var(--dsw-alias-label-primary);
28095
+ }
28096
+ [data-sw-monitor] .sw-rc-seal-key {
28097
+ width: 1px;
28098
+ background: var(--dsw-alias-label-tertiary);
28099
+ }
28100
+ [data-sw-monitor] .sw-rc-zero-key {
28101
+ background: var(--dsw-alias-border-l1, transparent);
28102
+ }
28103
+ [data-sw-monitor] .sw-rc-panel {
28104
+ margin: 8px 0 0;
28105
+ padding: 8px 10px;
28106
+ border: 0.5px solid var(--dsw-alias-border-l2);
28107
+ border-radius: var(--dsw-radius-sm);
28108
+ corner-shape: round;
28109
+ background: var(--dsw-alias-bg-layer-1);
28110
+ }
28111
+ [data-sw-monitor] .sw-rc-title {
28112
+ margin: 0;
28113
+ font-size: 12px;
28114
+ font-weight: 600;
28115
+ }
28116
+ [data-sw-monitor] .sw-rc-landing {
28117
+ margin: 2px 0 6px;
28118
+ color: var(--dsw-alias-label-secondary);
28119
+ }
28120
+ [data-sw-monitor] .sw-rc-text {
28121
+ margin: 0 0 6px;
28122
+ font: var(--dsw-font-xxxs-11);
28123
+ overflow-wrap: anywhere;
28124
+ white-space: pre-wrap;
28125
+ }
28126
+ [data-sw-monitor] .sw-rc-more,
28127
+ [data-sw-monitor] .sw-rc-read {
28128
+ height: 24px;
28129
+ padding: 0 8px;
28130
+ border: 0.5px solid var(--dsw-alias-border-l2);
28131
+ border-radius: var(--dsw-radius-sm);
28132
+ corner-shape: round;
28133
+ background: transparent;
28134
+ color: var(--dsw-alias-label-secondary);
28135
+ font: var(--dsw-font-xxxs-11);
28136
+ font-variant-numeric: inherit;
28137
+ white-space: nowrap;
28138
+ }
28139
+ [data-sw-monitor] button.sw-rc-more,
28140
+ [data-sw-monitor] button.sw-rc-read {
28141
+ cursor: pointer;
28142
+ }
28143
+ [data-sw-monitor] .sw-rc-reads {
28144
+ display: flex;
28145
+ flex-wrap: wrap;
28146
+ gap: 4px;
28147
+ margin: 6px 0 0;
28148
+ padding: 0;
28149
+ list-style: none;
28150
+ }
28151
+ [data-sw-monitor] span.sw-rc-read {
28152
+ display: inline-flex;
28153
+ align-items: center;
27370
28154
  }
27371
28155
  [data-sw-monitor] .sw-cx-card {
27372
28156
  margin: 0 0 10px;