@aiwayds/dsh-opentui 0.28.0 → 0.28.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.
@@ -32274,6 +32274,26 @@ var init_i18n = __esm(() => {
32274
32274
  init_src2();
32275
32275
  });
32276
32276
 
32277
+ // ../tui-base/src/theme/contrast.ts
32278
+ function relativeLuminance(color) {
32279
+ const [r, g, b] = color.toInts();
32280
+ const channel = (value) => {
32281
+ const c = value / 255;
32282
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
32283
+ };
32284
+ return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
32285
+ }
32286
+ function contrastRatio(a, b) {
32287
+ const la = relativeLuminance(a);
32288
+ const lb = relativeLuminance(b);
32289
+ const hi = Math.max(la, lb);
32290
+ const lo = Math.min(la, lb);
32291
+ return (hi + 0.05) / (lo + 0.05);
32292
+ }
32293
+ function ensureContrast(foreground, background, min = 4.5, fallback = foreground) {
32294
+ return contrastRatio(foreground, background) >= min ? foreground : fallback;
32295
+ }
32296
+
32277
32297
  // ../tui-base/src/skin/semantic.ts
32278
32298
  import { parseColor } from "@opentui/core";
32279
32299
  function mixSkinColor(a, b, t) {
@@ -32317,6 +32337,25 @@ function currentRowColors(theme) {
32317
32337
  textColor: theme?.text.action.primary.focused ?? SKIN_FALLBACK.accent
32318
32338
  };
32319
32339
  }
32340
+ function boostSkinContrast(color, background, min = 4.5) {
32341
+ const bg = parseColor(background);
32342
+ const pole = contrastRatio(bg, parseColor(SKIN_POLE_LIGHT)) >= contrastRatio(bg, parseColor(SKIN_POLE_DARK)) ? SKIN_POLE_LIGHT : SKIN_POLE_DARK;
32343
+ let candidate = mixSkinColor(color, pole, 0);
32344
+ for (let i = 0;i < 32 && contrastRatio(parseColor(candidate), bg) < min; i++) {
32345
+ candidate = mixSkinColor(candidate, pole, 0.08);
32346
+ }
32347
+ return candidate;
32348
+ }
32349
+ function dockTabStripColors(theme) {
32350
+ const selectedBg = theme?.background.action.primary.focused ?? SKIN_FALLBACK.tabSelectedBg;
32351
+ const selectedFg = theme?.text.action.primary.focused ?? SKIN_FALLBACK.tabSelectedFg;
32352
+ const unselectedBg = theme?.background.raised.base ?? SKIN_FALLBACK.tabUnselectedBg;
32353
+ const unselectedFg = boostSkinContrast(theme?.text.muted ?? SKIN_FALLBACK.tabUnselectedFg, unselectedBg);
32354
+ return {
32355
+ selected: { bg: selectedBg, fg: selectedFg },
32356
+ unselected: { bg: unselectedBg, fg: unselectedFg }
32357
+ };
32358
+ }
32320
32359
  function skinCursor(config) {
32321
32360
  return {
32322
32361
  style: config?.style === "underline" ? "underline" : "line",
@@ -32349,13 +32388,17 @@ function composerLayout(input) {
32349
32388
  const content = Math.max(1, input.textareaLines) + Math.max(0, input.footerRows) + Math.max(0, input.paletteRows);
32350
32389
  return { height: content + borderRows, border };
32351
32390
  }
32352
- var SKIN_FALLBACK, UNFOCUSED_BORDER_MUTED_MIX = 0.5, COMPOSER_BORDER_ROWS = 2, COMPOSER_COMPACT_TERMINAL_ROWS = 30, SKIN_FOCUS_BLUR_DEBOUNCE_MS = 50;
32391
+ var SKIN_FALLBACK, UNFOCUSED_BORDER_MUTED_MIX = 0.5, SKIN_POLE_LIGHT = "#ffffff", SKIN_POLE_DARK = "#000000", COMPOSER_BORDER_ROWS = 2, COMPOSER_COMPACT_TERMINAL_ROWS = 30, SKIN_FOCUS_BLUR_DEBOUNCE_MS = 50;
32353
32392
  var init_semantic = __esm(() => {
32354
32393
  SKIN_FALLBACK = {
32355
32394
  border: "#7aa2f7",
32356
32395
  accent: "#7aa2f7",
32357
32396
  warning: "#e0af68",
32358
- success: "#9ece6a"
32397
+ success: "#9ece6a",
32398
+ tabSelectedBg: "#8599ff",
32399
+ tabSelectedFg: "#1e1e22",
32400
+ tabUnselectedBg: "#141419",
32401
+ tabUnselectedFg: "#8a8a8a"
32359
32402
  };
32360
32403
  });
32361
32404
 
@@ -36654,6 +36697,14 @@ var init_dock_visibility = __esm(() => {
36654
36697
 
36655
36698
  // ../tui-base/src/routes/session/seam-rows.ts
36656
36699
  function toStoredRow(stored, index) {
36700
+ if (stored.kind === "notice") {
36701
+ return {
36702
+ key: `notice:${stored.id ?? "ask-outcome:unknown"}`,
36703
+ kind: "assistant",
36704
+ text: stored.text,
36705
+ final: true
36706
+ };
36707
+ }
36657
36708
  const kind = stored.kind === "user" || stored.kind === "tool" || stored.kind === "ask" ? stored.kind : "assistant";
36658
36709
  const key = `stored:${kind}:${index}`;
36659
36710
  if (kind === "tool") {
@@ -37396,7 +37447,7 @@ function colorRgb(color) {
37396
37447
  const n = m[1];
37397
37448
  return [parseInt(n.slice(0, 2), 16), parseInt(n.slice(2, 4), 16), parseInt(n.slice(4, 6), 16)];
37398
37449
  }
37399
- function relativeLuminance(color) {
37450
+ function relativeLuminance2(color) {
37400
37451
  const [r, g, b] = colorRgb(color);
37401
37452
  const channel = (v) => {
37402
37453
  const c = v / 255;
@@ -37404,18 +37455,18 @@ function relativeLuminance(color) {
37404
37455
  };
37405
37456
  return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
37406
37457
  }
37407
- function contrastRatio(a, b) {
37408
- const la = relativeLuminance(a);
37409
- const lb = relativeLuminance(b);
37458
+ function contrastRatio2(a, b) {
37459
+ const la = relativeLuminance2(a);
37460
+ const lb = relativeLuminance2(b);
37410
37461
  const hi = Math.max(la, lb);
37411
37462
  const lo = Math.min(la, lb);
37412
37463
  return (hi + 0.05) / (lo + 0.05);
37413
37464
  }
37414
37465
  function autoContrast(bg) {
37415
- const preferred = contrastRatio(bg, AUTO_FG_DARK) >= contrastRatio(bg, AUTO_FG_LIGHT) ? AUTO_FG_DARK : AUTO_FG_LIGHT;
37416
- if (contrastRatio(bg, preferred) >= 4.5)
37466
+ const preferred = contrastRatio2(bg, AUTO_FG_DARK) >= contrastRatio2(bg, AUTO_FG_LIGHT) ? AUTO_FG_DARK : AUTO_FG_LIGHT;
37467
+ if (contrastRatio2(bg, preferred) >= 4.5)
37417
37468
  return preferred;
37418
- return contrastRatio(bg, "#000000") >= contrastRatio(bg, "#ffffff") ? "#000000" : "#ffffff";
37469
+ return contrastRatio2(bg, "#000000") >= contrastRatio2(bg, "#ffffff") ? "#000000" : "#ffffff";
37419
37470
  }
37420
37471
  function isExplicitEffort(word) {
37421
37472
  return (word?.trim() ?? "").length > 0;
@@ -37599,7 +37650,7 @@ function lightnessForChroma(hue, chroma, target) {
37599
37650
  for (let i = 0;i < 32; i++) {
37600
37651
  const mid = (lo + hi) / 2;
37601
37652
  const saturation = saturationForChroma(chroma, mid);
37602
- if (relativeLuminance(hslToHex(hue, saturation, mid)) < target)
37653
+ if (relativeLuminance2(hslToHex(hue, saturation, mid)) < target)
37603
37654
  lo = mid;
37604
37655
  else
37605
37656
  hi = mid;
@@ -38064,7 +38115,7 @@ function sessionFooterSegments(data) {
38064
38115
  add(bridgeStatusSegment(data.bridgeStatus));
38065
38116
  return applyPowerlineGradient(segs, theme);
38066
38117
  }
38067
- var POWERLINE_COLORS, AUTO_FG_DARK = "#1a1a2e", AUTO_FG_LIGHT = "#ffffff", DEFAULT_EFFORT = "high", POWERLINE_MIN_SEGMENT_DISTANCE = 80, POWERLINE_RAMP_FAMILIES, POWERLINE_RAMP_DEEP_LUMINANCE = 0.02, POWERLINE_RAMP_LIGHT_LUMINANCE = 0.55, POWERLINE_RAMP_HUE_STEPS, POWERLINE_RAMP_FALLBACK_HUES, EFFORT_ICONS;
38118
+ var POWERLINE_COLORS, POWERLINE_ARROW = "\uE0B0", AUTO_FG_DARK = "#1a1a2e", AUTO_FG_LIGHT = "#ffffff", DEFAULT_EFFORT = "high", POWERLINE_MIN_SEGMENT_DISTANCE = 80, POWERLINE_RAMP_FAMILIES, POWERLINE_RAMP_DEEP_LUMINANCE = 0.02, POWERLINE_RAMP_LIGHT_LUMINANCE = 0.55, POWERLINE_RAMP_HUE_STEPS, POWERLINE_RAMP_FALLBACK_HUES, EFFORT_ICONS;
38068
38119
  var init_powerline = __esm(() => {
38069
38120
  init_index_bun();
38070
38121
  init_index_bun();
@@ -38706,44 +38757,128 @@ function todoTabLines(rows, innerWidth, cursor = 0) {
38706
38757
  cursor
38707
38758
  });
38708
38759
  }
38709
- function dockTabBarLayout(innerWidth, mainLabel, todoLabel, tailText) {
38710
- const width = Math.max(0, Math.floor(innerWidth));
38711
- const between = " ";
38712
- const main = takeWidth(mainLabel, Math.max(0, width - stringWidth(between)));
38713
- const todo = takeWidth(todoLabel, Math.max(0, width - stringWidth(main) - stringWidth(between)));
38714
- const tail = takeWidth(tailText, Math.max(0, width - stringWidth(main) - stringWidth(between) - stringWidth(todo)));
38715
- const tailGap = " ".repeat(Math.max(0, width - stringWidth(main) - stringWidth(between) - stringWidth(todo) - stringWidth(tail)));
38760
+ function dockTabTextLevels(mainLabel, todoLabel) {
38761
+ const m = dockTabDigit(mainLabel);
38762
+ const t = dockTabDigit(todoLabel);
38763
+ return [
38764
+ {
38765
+ main: ` ${DOCK_TAB_ICON.main} ${mainLabel} `,
38766
+ todo: ` ${DOCK_TAB_ICON.todo} ${todoLabel} `
38767
+ },
38768
+ {
38769
+ main: `${DOCK_TAB_ICON.main} ${mainLabel}`,
38770
+ todo: `${DOCK_TAB_ICON.todo} ${todoLabel}`
38771
+ },
38772
+ {
38773
+ main: ` ${DOCK_TAB_ICON.main}${m} `,
38774
+ todo: ` ${DOCK_TAB_ICON.todo}${t} `
38775
+ },
38776
+ {
38777
+ main: `${DOCK_TAB_ICON.main}${m}`,
38778
+ todo: `${DOCK_TAB_ICON.todo}${t}`
38779
+ },
38780
+ {
38781
+ main: m,
38782
+ todo: t
38783
+ }
38784
+ ];
38785
+ }
38786
+ function activityDockTabLabels(_tab, mainLabel, todoLabel) {
38716
38787
  return {
38717
- mainLabel: main,
38718
- todoLabel: todo,
38719
- between,
38720
- tailGap,
38721
- tail
38788
+ main: mainLabel,
38789
+ todo: todoLabel
38722
38790
  };
38723
38791
  }
38724
- function activityDockTabLabels(tab, mainLabel, todoLabel) {
38725
- return tab === "main" ? {
38726
- main: `[${mainLabel}]`,
38727
- todo: todoLabel
38728
- } : {
38729
- main: mainLabel,
38730
- todo: `[${todoLabel}]`
38792
+ function dockTabStripCells(texts, activeTab, colors) {
38793
+ const mainColor = activeTab === "main" ? colors.selected : colors.unselected;
38794
+ const todoColor = activeTab === "main" ? colors.unselected : colors.selected;
38795
+ return [{
38796
+ text: texts.main,
38797
+ fg: mainColor.fg,
38798
+ bg: mainColor.bg,
38799
+ tab: "main"
38800
+ }, {
38801
+ text: POWERLINE_ARROW,
38802
+ fg: mainColor.bg,
38803
+ bg: todoColor.bg
38804
+ }, {
38805
+ text: texts.todo,
38806
+ fg: todoColor.fg,
38807
+ bg: todoColor.bg,
38808
+ tab: "todo"
38809
+ }, {
38810
+ text: POWERLINE_ARROW,
38811
+ fg: todoColor.bg
38812
+ }];
38813
+ }
38814
+ function dockTabStripWidth(texts) {
38815
+ return stringWidth(texts.main) + 1 + stringWidth(texts.todo) + 1;
38816
+ }
38817
+ function dockTabStripLayout(opts) {
38818
+ const colors = dockTabStripColors(opts.theme);
38819
+ const limit = Math.max(0, Math.floor(opts.innerWidth));
38820
+ for (const texts of dockTabTextLevels(opts.mainLabel, opts.todoLabel)) {
38821
+ const width = dockTabStripWidth(texts);
38822
+ for (const p of DOCK_TAB_PADDING_STEPS) {
38823
+ if (width <= limit - p) {
38824
+ return {
38825
+ cells: dockTabStripCells(texts, opts.activeTab, colors),
38826
+ stripWidth: width,
38827
+ rightPadding: p
38828
+ };
38829
+ }
38830
+ }
38831
+ }
38832
+ return {
38833
+ cells: [],
38834
+ stripWidth: 0,
38835
+ rightPadding: DOCK_TAB_PADDING_STEPS[0]
38731
38836
  };
38732
38837
  }
38733
- function dockTabAtPosition(x, y, screenX, screenY, layout) {
38734
- const relX = x - screenX - 2;
38735
- const relY = y - screenY;
38736
- if (relY < 0 || relY > 1)
38838
+ function dockTabAtPosition(x, y, box, framed, strip) {
38839
+ if (strip.cells.length === 0)
38840
+ return;
38841
+ const innerWidth = box.width - (framed ? 2 : 0);
38842
+ const stripLeft = box.screenX + (framed ? 1 : 0) + innerWidth - strip.rightPadding - strip.stripWidth;
38843
+ const row = framed ? box.screenY + box.height - 2 : box.screenY + box.height - 1;
38844
+ if (y !== row && !(framed && y === row + 1))
38737
38845
  return;
38738
- const mainEnd = stringWidth(layout.mainLabel);
38739
- const todoStart = mainEnd + stringWidth(layout.between);
38740
- const todoEnd = todoStart + stringWidth(layout.todoLabel);
38741
- if (relX >= 0 && relX < mainEnd)
38742
- return "main";
38743
- if (relX >= todoStart && relX < todoEnd)
38744
- return "todo";
38846
+ let cursor = stripLeft;
38847
+ for (const cell of strip.cells) {
38848
+ const cellWidth = stringWidth(cell.text);
38849
+ if (x >= cursor && x < cursor + cellWidth)
38850
+ return cell.tab;
38851
+ cursor += cellWidth;
38852
+ }
38745
38853
  return;
38746
38854
  }
38855
+ function DockTabStripView(props) {
38856
+ return (() => {
38857
+ var _el$ = createElement("box");
38858
+ setProp(_el$, "flexShrink", 0);
38859
+ setProp(_el$, "flexDirection", "row");
38860
+ setProp(_el$, "width", "100%");
38861
+ setProp(_el$, "height", 1);
38862
+ setProp(_el$, "justifyContent", "flex-end");
38863
+ insert(_el$, createComponent2(For, {
38864
+ get each() {
38865
+ return props.strip.cells;
38866
+ },
38867
+ children: (cell) => (() => {
38868
+ var _el$2 = createElement("text");
38869
+ setProp(_el$2, "wrapMode", "none");
38870
+ insert(_el$2, () => cell.text);
38871
+ effect((_$p) => setProp(_el$2, "style", {
38872
+ fg: cell.fg,
38873
+ bg: cell.bg
38874
+ }, _$p));
38875
+ return _el$2;
38876
+ })()
38877
+ }));
38878
+ effect((_$p) => setProp(_el$, "paddingRight", props.strip.rightPadding, _$p));
38879
+ return _el$;
38880
+ })();
38881
+ }
38747
38882
  function todoSetStartedAt(todos, now = Date.now()) {
38748
38883
  const sig = todoSetSignature(todos);
38749
38884
  const first = todoSetFirstSeen.get(sig);
@@ -38953,11 +39088,11 @@ function activityFrameMode(terminalRows, compactRows = COMPOSER_COMPACT_TERMINAL
38953
39088
  }
38954
39089
  function boostUntilContrast(color, background, min = 4.5) {
38955
39090
  let candidate = typeof color === "string" ? color : mixPowerlineColor(color, "#000000", 0);
38956
- const pole = contrastRatio(background, AUTO_POLE_LIGHT) >= contrastRatio(background, AUTO_POLE_DARK) ? AUTO_POLE_LIGHT : AUTO_POLE_DARK;
38957
- for (let i = 0;i < 32 && contrastRatio(candidate, background) < min; i++) {
39091
+ const pole = contrastRatio2(background, AUTO_POLE_LIGHT) >= contrastRatio2(background, AUTO_POLE_DARK) ? AUTO_POLE_LIGHT : AUTO_POLE_DARK;
39092
+ for (let i = 0;i < 32 && contrastRatio2(candidate, background) < min; i++) {
38958
39093
  candidate = mixPowerlineColor(candidate, pole, 0.08);
38959
39094
  }
38960
- const contrast = contrastRatio(candidate, background);
39095
+ const contrast = contrastRatio2(candidate, background);
38961
39096
  return {
38962
39097
  color: candidate,
38963
39098
  contrast,
@@ -38968,7 +39103,7 @@ function dockAccentColor(theme, accent) {
38968
39103
  const background = theme?.background?.base;
38969
39104
  const validatedFallback = (bg) => {
38970
39105
  const fallback = DOCK_ACCENT_FALLBACK[accent];
38971
- const darkSurface = relativeLuminance(bg) < 0.5;
39106
+ const darkSurface = relativeLuminance2(bg) < 0.5;
38972
39107
  return boostUntilContrast(darkSurface ? fallback.dark : fallback.light, bg, DOCK_ACCENT_MIN_CONTRAST).color;
38973
39108
  };
38974
39109
  const hues = theme?.hue;
@@ -38981,7 +39116,7 @@ function dockAccentColor(theme, accent) {
38981
39116
  continue;
38982
39117
  if (background === undefined)
38983
39118
  return candidates[0];
38984
- const preferred = candidates.find((value) => contrastRatio(value, background) >= DOCK_ACCENT_MIN_CONTRAST);
39119
+ const preferred = candidates.find((value) => contrastRatio2(value, background) >= DOCK_ACCENT_MIN_CONTRAST);
38985
39120
  if (preferred !== undefined)
38986
39121
  return preferred;
38987
39122
  return validatedFallback(background);
@@ -39182,9 +39317,15 @@ function WidgetsDock(props) {
39182
39317
  });
39183
39318
  const titleSlotWidth = () => dimensions().width - 4;
39184
39319
  const tabLabels = () => activityDockTabLabels(activityDockTab(), t("overlay.widgets.tab.main"), t("overlay.widgets.tab.todo"));
39185
- const tabBar = () => {
39320
+ const framedStrip = () => {
39186
39321
  const labels = tabLabels();
39187
- return dockTabBarLayout(titleSlotWidth(), labels.main, labels.todo, "");
39322
+ return dockTabStripLayout({
39323
+ mainLabel: labels.main,
39324
+ todoLabel: labels.todo,
39325
+ activeTab: activityDockTab(),
39326
+ theme: theme ?? undefined,
39327
+ innerWidth: dimensions().width - 2
39328
+ });
39188
39329
  };
39189
39330
  const mergedTitleText = () => {
39190
39331
  const {
@@ -39197,9 +39338,7 @@ function WidgetsDock(props) {
39197
39338
  subagent: mergedRunningAgents(props.rows).length > 0
39198
39339
  });
39199
39340
  const suffix = mergedPositionSuffix(info);
39200
- const bar = tabBar();
39201
- const head = `${bar.mainLabel}${bar.between}${bar.todoLabel} `;
39202
- const title = takeWidth(head + base, titleSlotWidth());
39341
+ const title = takeWidth(base, titleSlotWidth());
39203
39342
  if (suffix === null)
39204
39343
  return title;
39205
39344
  const gap = titleSlotWidth() - stringWidth(title) - stringWidth(suffix);
@@ -39212,7 +39351,7 @@ function WidgetsDock(props) {
39212
39351
  onActivityPanelMouseUp(event);
39213
39352
  if (dockBox === undefined)
39214
39353
  return;
39215
- const tab = dockTabAtPosition(event.x, event.y, dockBox.screenX, dockBox.screenY, tabBar());
39354
+ const tab = dockTabAtPosition(event.x, event.y, dockBox, true, framedStrip());
39216
39355
  if (tab !== undefined)
39217
39356
  onDockTabMouseUp(tab, event);
39218
39357
  };
@@ -39275,20 +39414,16 @@ function WidgetsDock(props) {
39275
39414
  const count = !animating || tweened >= target ? target : Math.min(target, tweened);
39276
39415
  return lines.slice(0, count);
39277
39416
  };
39278
- const frameHeight = () => 2 + tabContentLines().length;
39279
- const compactTabBar = () => {
39417
+ const frameHeight = () => 3 + tabContentLines().length;
39418
+ const compactStrip = () => {
39280
39419
  const labels = tabLabels();
39281
- return dockTabBarLayout(width(), labels.main, labels.todo, "");
39282
- };
39283
- const compactTabBarLine = () => {
39284
- const bar = compactTabBar();
39285
- return {
39286
- kind: "tool",
39287
- segments: [{
39288
- text: `${bar.mainLabel}${bar.between}${bar.todoLabel}`,
39289
- tone: "muted"
39290
- }]
39291
- };
39420
+ return dockTabStripLayout({
39421
+ mainLabel: labels.main,
39422
+ todoLabel: labels.todo,
39423
+ activeTab: activityDockTab(),
39424
+ theme: theme ?? undefined,
39425
+ innerWidth: dimensions().width - 3
39426
+ });
39292
39427
  };
39293
39428
  const compactLower = () => mergedCompactLowerLines(props.rows);
39294
39429
  const compactBrief = () => mergedCompactBriefLines(props.rows, Date.now(), width());
@@ -39300,7 +39435,7 @@ function WidgetsDock(props) {
39300
39435
  onActivityPanelMouseUp(event);
39301
39436
  if (compactDockBox === undefined)
39302
39437
  return;
39303
- const tab = dockTabAtPosition(event.x, event.y, compactDockBox.screenX + 1, compactDockBox.screenY, compactTabBar());
39438
+ const tab = dockTabAtPosition(event.x, event.y, compactDockBox, false, compactStrip());
39304
39439
  if (tab !== undefined)
39305
39440
  onDockTabMouseUp(tab, event);
39306
39441
  };
@@ -39318,34 +39453,34 @@ function WidgetsDock(props) {
39318
39453
  };
39319
39454
  const attributes = line.italic === true ? TextAttributes5.ITALIC : undefined;
39320
39455
  return (() => {
39321
- var _el$ = createElement("text");
39322
- setProp(_el$, "attributes", attributes);
39323
- setProp(_el$, "wrapMode", "none");
39324
- insert(_el$, createComponent2(For, {
39456
+ var _el$3 = createElement("text");
39457
+ setProp(_el$3, "attributes", attributes);
39458
+ setProp(_el$3, "wrapMode", "none");
39459
+ insert(_el$3, createComponent2(For, {
39325
39460
  get each() {
39326
39461
  return line.segments;
39327
39462
  },
39328
39463
  children: (segment) => {
39329
39464
  const target = segment.accent !== undefined ? accentFg(segment.accent) : fgFor(segment.tone);
39330
39465
  return (() => {
39331
- var _el$2 = createElement("span");
39332
- insert(_el$2, () => segment.text);
39333
- effect((_$p) => setProp(_el$2, "style", {
39466
+ var _el$4 = createElement("span");
39467
+ insert(_el$4, () => segment.text);
39468
+ effect((_$p) => setProp(_el$4, "style", {
39334
39469
  fg: skinDockLineFg(ctx, target, lineFade)
39335
39470
  }, _$p));
39336
- return _el$2;
39471
+ return _el$4;
39337
39472
  })();
39338
39473
  }
39339
39474
  }));
39340
- return _el$;
39475
+ return _el$3;
39341
39476
  })();
39342
39477
  };
39343
39478
  return (() => {
39344
- var _el$3 = createElement("box");
39345
- setProp(_el$3, "flexShrink", 0);
39346
- setProp(_el$3, "flexDirection", "column");
39347
- setProp(_el$3, "width", "100%");
39348
- insert(_el$3, createComponent2(Show, {
39479
+ var _el$5 = createElement("box");
39480
+ setProp(_el$5, "flexShrink", 0);
39481
+ setProp(_el$5, "flexDirection", "column");
39482
+ setProp(_el$5, "width", "100%");
39483
+ insert(_el$5, createComponent2(Show, {
39349
39484
  get when() {
39350
39485
  return activityFrameLatch.shown();
39351
39486
  },
@@ -39377,62 +39512,66 @@ function WidgetsDock(props) {
39377
39512
  },
39378
39513
  get fallback() {
39379
39514
  return (() => {
39380
- var _el$5 = createElement("box");
39515
+ var _el$7 = createElement("box");
39381
39516
  use((el) => {
39382
39517
  compactDockBox = el;
39383
- }, _el$5);
39384
- setProp(_el$5, "flexShrink", 0);
39385
- setProp(_el$5, "flexDirection", "column");
39386
- setProp(_el$5, "width", "100%");
39387
- setProp(_el$5, "paddingLeft", 3);
39388
- setProp(_el$5, "onMouseUp", onCompactTitleMouseUp);
39389
- insert(_el$5, createComponent2(For, {
39390
- get each() {
39391
- return [compactTabBarLine()];
39392
- },
39393
- children: mergedLineView
39394
- }), null);
39395
- insert(_el$5, createComponent2(For, {
39518
+ }, _el$7);
39519
+ setProp(_el$7, "flexShrink", 0);
39520
+ setProp(_el$7, "flexDirection", "column");
39521
+ setProp(_el$7, "width", "100%");
39522
+ setProp(_el$7, "paddingLeft", 3);
39523
+ setProp(_el$7, "onMouseUp", onCompactTitleMouseUp);
39524
+ insert(_el$7, createComponent2(For, {
39396
39525
  get each() {
39397
39526
  return memo2(() => activityDockTab() === "main")() ? activityRuleLines(props.rows) : [];
39398
39527
  },
39399
39528
  children: lineView
39400
39529
  }), null);
39401
- insert(_el$5, createComponent2(For, {
39530
+ insert(_el$7, createComponent2(For, {
39402
39531
  get each() {
39403
39532
  return compactContent();
39404
39533
  },
39405
39534
  children: mergedLineView
39406
39535
  }), null);
39407
- effect((_$p) => setProp(_el$5, "height", compactHeight(), _$p));
39408
- return _el$5;
39536
+ insert(_el$7, createComponent2(DockTabStripView, {
39537
+ get strip() {
39538
+ return compactStrip();
39539
+ }
39540
+ }), null);
39541
+ effect((_$p) => setProp(_el$7, "height", compactHeight(), _$p));
39542
+ return _el$7;
39409
39543
  })();
39410
39544
  },
39411
39545
  get children() {
39412
- var _el$4 = createElement("box");
39546
+ var _el$6 = createElement("box");
39413
39547
  use((el) => {
39414
39548
  dockBox = el;
39415
- }, _el$4);
39416
- setProp(_el$4, "flexShrink", 0);
39417
- setProp(_el$4, "flexDirection", "column");
39418
- setProp(_el$4, "width", "100%");
39419
- setProp(_el$4, "border", ["top", "bottom", "left", "right"]);
39420
- setProp(_el$4, "titleAlignment", "left");
39421
- setProp(_el$4, "onMouseScroll", onMergedWheel);
39422
- setProp(_el$4, "onMouseUp", onDockTitleMouseUp);
39423
- insert(_el$4, createComponent2(For, {
39549
+ }, _el$6);
39550
+ setProp(_el$6, "flexShrink", 0);
39551
+ setProp(_el$6, "flexDirection", "column");
39552
+ setProp(_el$6, "width", "100%");
39553
+ setProp(_el$6, "border", ["top", "bottom", "left", "right"]);
39554
+ setProp(_el$6, "titleAlignment", "left");
39555
+ setProp(_el$6, "onMouseScroll", onMergedWheel);
39556
+ setProp(_el$6, "onMouseUp", onDockTitleMouseUp);
39557
+ insert(_el$6, createComponent2(For, {
39424
39558
  get each() {
39425
39559
  return tabContentLines();
39426
39560
  },
39427
39561
  children: mergedLineView
39428
- }));
39562
+ }), null);
39563
+ insert(_el$6, createComponent2(DockTabStripView, {
39564
+ get strip() {
39565
+ return framedStrip();
39566
+ }
39567
+ }), null);
39429
39568
  effect((_p$) => {
39430
39569
  var _v$ = frameHeight(), _v$2 = activityFrame().borderStyle, _v$3 = activityFrame().borderColor, _v$4 = mergedTitleText(), _v$5 = activityFrame().titleColor;
39431
- _v$ !== _p$.e && (_p$.e = setProp(_el$4, "height", _v$, _p$.e));
39432
- _v$2 !== _p$.t && (_p$.t = setProp(_el$4, "borderStyle", _v$2, _p$.t));
39433
- _v$3 !== _p$.a && (_p$.a = setProp(_el$4, "borderColor", _v$3, _p$.a));
39434
- _v$4 !== _p$.o && (_p$.o = setProp(_el$4, "title", _v$4, _p$.o));
39435
- _v$5 !== _p$.i && (_p$.i = setProp(_el$4, "titleColor", _v$5, _p$.i));
39570
+ _v$ !== _p$.e && (_p$.e = setProp(_el$6, "height", _v$, _p$.e));
39571
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$6, "borderStyle", _v$2, _p$.t));
39572
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$6, "borderColor", _v$3, _p$.a));
39573
+ _v$4 !== _p$.o && (_p$.o = setProp(_el$6, "title", _v$4, _p$.o));
39574
+ _v$5 !== _p$.i && (_p$.i = setProp(_el$6, "titleColor", _v$5, _p$.i));
39436
39575
  return _p$;
39437
39576
  }, {
39438
39577
  e: undefined,
@@ -39441,12 +39580,12 @@ function WidgetsDock(props) {
39441
39580
  o: undefined,
39442
39581
  i: undefined
39443
39582
  });
39444
- return _el$4;
39583
+ return _el$6;
39445
39584
  }
39446
39585
  });
39447
39586
  }
39448
39587
  }));
39449
- return _el$3;
39588
+ return _el$5;
39450
39589
  })();
39451
39590
  }
39452
39591
  function FlatDock(props) {
@@ -39465,19 +39604,19 @@ function FlatDock(props) {
39465
39604
  return lines.slice(0, count);
39466
39605
  };
39467
39606
  return (() => {
39468
- var _el$6 = createElement("box");
39469
- setProp(_el$6, "flexShrink", 0);
39470
- setProp(_el$6, "flexDirection", "column");
39471
- setProp(_el$6, "width", "100%");
39472
- setProp(_el$6, "paddingLeft", 3);
39473
- insert(_el$6, createComponent2(For, {
39607
+ var _el$8 = createElement("box");
39608
+ setProp(_el$8, "flexShrink", 0);
39609
+ setProp(_el$8, "flexDirection", "column");
39610
+ setProp(_el$8, "width", "100%");
39611
+ setProp(_el$8, "paddingLeft", 3);
39612
+ insert(_el$8, createComponent2(For, {
39474
39613
  get each() {
39475
39614
  return flatLines();
39476
39615
  },
39477
39616
  children: (line) => dockLineNode(line, props.width, props.skinCtx, props.fgFor, props.accentFg)
39478
39617
  }));
39479
- effect((_$p) => setProp(_el$6, "height", flatLines().length, _$p));
39480
- return _el$6;
39618
+ effect((_$p) => setProp(_el$8, "height", flatLines().length, _$p));
39619
+ return _el$8;
39481
39620
  })();
39482
39621
  }
39483
39622
  function dockLineNode(line, width, ctx, fgFor, accentFg) {
@@ -39488,12 +39627,12 @@ function dockLineNode(line, width, ctx, fgFor, accentFg) {
39488
39627
  const markerAt = line.markerAt ?? 0;
39489
39628
  if (marker === undefined || line.text.slice(markerAt, markerAt + marker.length) !== marker) {
39490
39629
  return (() => {
39491
- var _el$7 = createElement("text");
39492
- setProp(_el$7, "fg", bodyFg);
39493
- setProp(_el$7, "attributes", attributes);
39494
- setProp(_el$7, "wrapMode", "none");
39495
- insert(_el$7, () => clipToWidth(line.text, width));
39496
- return _el$7;
39630
+ var _el$9 = createElement("text");
39631
+ setProp(_el$9, "fg", bodyFg);
39632
+ setProp(_el$9, "attributes", attributes);
39633
+ setProp(_el$9, "wrapMode", "none");
39634
+ insert(_el$9, () => clipToWidth(line.text, width));
39635
+ return _el$9;
39497
39636
  })();
39498
39637
  }
39499
39638
  const before = clipToWidth(line.text.slice(0, markerAt), width);
@@ -39502,21 +39641,21 @@ function dockLineNode(line, width, ctx, fgFor, accentFg) {
39502
39641
  const after = clipToWidth(line.text.slice(markerAt + marker.length), Math.max(0, markerBudget - stringWidth(clippedMarker)));
39503
39642
  const markerFg = skinDockLineFg(ctx, toneFg, line);
39504
39643
  return (() => {
39505
- var _el$8 = createElement("text"), _el$9 = createElement("span");
39506
- insertNode(_el$8, _el$9);
39507
- setProp(_el$8, "fg", bodyFg);
39508
- setProp(_el$8, "attributes", attributes);
39509
- setProp(_el$8, "wrapMode", "none");
39510
- insert(_el$8, before, _el$9);
39511
- setProp(_el$9, "style", {
39644
+ var _el$0 = createElement("text"), _el$1 = createElement("span");
39645
+ insertNode(_el$0, _el$1);
39646
+ setProp(_el$0, "fg", bodyFg);
39647
+ setProp(_el$0, "attributes", attributes);
39648
+ setProp(_el$0, "wrapMode", "none");
39649
+ insert(_el$0, before, _el$1);
39650
+ setProp(_el$1, "style", {
39512
39651
  fg: markerFg
39513
39652
  });
39514
- insert(_el$9, clippedMarker);
39515
- insert(_el$8, after, null);
39516
- return _el$8;
39653
+ insert(_el$1, clippedMarker);
39654
+ insert(_el$0, after, null);
39655
+ return _el$0;
39517
39656
  })();
39518
39657
  }
39519
- var SKIN_FADE_IN_MS = 400, SKIN_NOTICE_FADE_MS = 500, SKIN_PULSE_MS = 1200, SKIN_PULSE_CYCLES = 3, SKIN_PULSE_DIM = 0.45, SKIN_FAINT_MIX = 0.78, ACTIVITY_PANEL_GEARS, ACTIVITY_PANEL_ALL_LINES = 10, activityPanelGear, setActivityPanelGear, DOCK_HEIGHT_ANIM_MS = 200, dockHeightTween, setDockHeightTween, dockHeightSettled = undefined, dockFrameNow = 0, LINE_FIRST_SEEN_MAX = 512, lineFirstSeen, dockSpin, setDockSpin, mergedDockCursor, setMergedDockCursor, activityDockTab, setActivityDockTab, todoSetSignature = (todos) => todos.map((todo) => todo.content).sort().join("\x01"), todoSetFirstSeen, subagentBatchStartedAt, prevSubagentRunning = 0, TODO_TOOL_NAMES, AUTO_POLE_LIGHT = "#ffffff", AUTO_POLE_DARK = "#000000", DOCK_ACCENT_STEPS, DOCK_ACCENT_HUES, DOCK_ACCENT_MIN_CONTRAST = 4.5, DOCK_ACCENT_FALLBACK, ACTIVITY_FRAME_DEFER_MS = 60, activityFrameLatch, COMPACT_TREE_MAX_LINES = 8;
39658
+ var SKIN_FADE_IN_MS = 400, SKIN_NOTICE_FADE_MS = 500, SKIN_PULSE_MS = 1200, SKIN_PULSE_CYCLES = 3, SKIN_PULSE_DIM = 0.45, SKIN_FAINT_MIX = 0.78, ACTIVITY_PANEL_GEARS, ACTIVITY_PANEL_ALL_LINES = 10, activityPanelGear, setActivityPanelGear, DOCK_HEIGHT_ANIM_MS = 200, dockHeightTween, setDockHeightTween, dockHeightSettled = undefined, dockFrameNow = 0, LINE_FIRST_SEEN_MAX = 512, lineFirstSeen, dockSpin, setDockSpin, mergedDockCursor, setMergedDockCursor, activityDockTab, setActivityDockTab, DOCK_TAB_ICON, DOCK_TAB_PADDING_STEPS, dockTabDigit = (label) => label.match(/^\d+/)?.[0] ?? "", todoSetSignature = (todos) => todos.map((todo) => todo.content).sort().join("\x01"), todoSetFirstSeen, subagentBatchStartedAt, prevSubagentRunning = 0, TODO_TOOL_NAMES, AUTO_POLE_LIGHT = "#ffffff", AUTO_POLE_DARK = "#000000", DOCK_ACCENT_STEPS, DOCK_ACCENT_HUES, DOCK_ACCENT_MIN_CONTRAST = 4.5, DOCK_ACCENT_FALLBACK, ACTIVITY_FRAME_DEFER_MS = 60, activityFrameLatch, COMPACT_TREE_MAX_LINES = 8;
39520
39659
  var init_widgets_dock = __esm(() => {
39521
39660
  init_index_bun();
39522
39661
  init_index_bun();
@@ -39550,6 +39689,11 @@ var init_widgets_dock = __esm(() => {
39550
39689
  [dockSpin, setDockSpin] = createSignal(0);
39551
39690
  [mergedDockCursor, setMergedDockCursor] = createSignal(0);
39552
39691
  [activityDockTab, setActivityDockTab] = createSignal("main");
39692
+ DOCK_TAB_ICON = {
39693
+ main: "\uD83C\uDFE0",
39694
+ todo: "\uD83D\uDCCB"
39695
+ };
39696
+ DOCK_TAB_PADDING_STEPS = [2, 1, 0];
39553
39697
  todoSetFirstSeen = new Map;
39554
39698
  TODO_TOOL_NAMES = new Set(["todowrite", "todo_write"]);
39555
39699
  DOCK_ACCENT_STEPS = {
@@ -48123,16 +48267,16 @@ function fadeColor(from, to, t) {
48123
48267
  function srgbToLinear2(channel) {
48124
48268
  return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
48125
48269
  }
48126
- function relativeLuminance2(color) {
48270
+ function relativeLuminance3(color) {
48127
48271
  return 0.2126 * srgbToLinear2(color.r) + 0.7152 * srgbToLinear2(color.g) + 0.0722 * srgbToLinear2(color.b);
48128
48272
  }
48129
- function contrastRatio2(a, b) {
48130
- const la = relativeLuminance2(a);
48131
- const lb = relativeLuminance2(b);
48273
+ function contrastRatio3(a, b) {
48274
+ const la = relativeLuminance3(a);
48275
+ const lb = relativeLuminance3(b);
48132
48276
  return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
48133
48277
  }
48134
48278
  function withContrastFloor(fg, bg, fallback) {
48135
- return contrastRatio2(fg, bg) < MIN_CONTRAST ? fallback : fg;
48279
+ return contrastRatio3(fg, bg) < MIN_CONTRAST ? fallback : fg;
48136
48280
  }
48137
48281
  function fadeTheme(theme, t) {
48138
48282
  const progress = clamp012(t);
@@ -54905,7 +55049,7 @@ var init_subagents_viewer = __esm(() => {
54905
55049
  import { TextAttributes as TextAttributes12 } from "@opentui/core";
54906
55050
  function resolveVersion() {
54907
55051
  try {
54908
- return "0.28.0";
55052
+ return "0.28.2";
54909
55053
  } catch {
54910
55054
  return "dev";
54911
55055
  }
@@ -56488,7 +56632,7 @@ function createBtwSnapshotBuilder(seam) {
56488
56632
  return [];
56489
56633
  try {
56490
56634
  const rows = await seam.storedTranscript(id);
56491
- return rows.slice(-BTW_SNAPSHOT_ROWS).map((row) => `${row.kind}: ${row.text}`.slice(0, BTW_SNAPSHOT_ROW_CHARS));
56635
+ return rows.filter((row) => row.kind !== "notice").slice(-BTW_SNAPSHOT_ROWS).map((row) => `${row.kind}: ${row.text}`.slice(0, BTW_SNAPSHOT_ROW_CHARS));
56492
56636
  } catch {
56493
56637
  return [];
56494
56638
  }
@@ -56583,26 +56727,6 @@ function copyComposerSelection(source, clipboard, onError = () => {}) {
56583
56727
  return true;
56584
56728
  }
56585
56729
 
56586
- // ../tui-base/src/theme/contrast.ts
56587
- function relativeLuminance3(color) {
56588
- const [r, g, b] = color.toInts();
56589
- const channel = (value) => {
56590
- const c = value / 255;
56591
- return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
56592
- };
56593
- return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
56594
- }
56595
- function contrastRatio3(a, b) {
56596
- const la = relativeLuminance3(a);
56597
- const lb = relativeLuminance3(b);
56598
- const hi = Math.max(la, lb);
56599
- const lo = Math.min(la, lb);
56600
- return (hi + 0.05) / (lo + 0.05);
56601
- }
56602
- function ensureContrast(foreground, background, min = 4.5, fallback = foreground) {
56603
- return contrastRatio3(foreground, background) >= min ? foreground : fallback;
56604
- }
56605
-
56606
56730
  // ../tui-base/src/context/panel-kit-host.tsx
56607
56731
  import { RGBA as RGBA15, TextAttributes as TextAttributes13 } from "@opentui/core";
56608
56732
  function projectPanelTheme(theme) {
@@ -57592,6 +57716,85 @@ var init_journal_projection = __esm(() => {
57592
57716
  NOTICE_SOURCE_KINDS = new Set(["subagent-settled", "agent-message", "team-message", "webhook"]);
57593
57717
  });
57594
57718
 
57719
+ // src/client/ask-outcome.ts
57720
+ function legacyReason(input) {
57721
+ if (input.journalKind === "ask.responded") {
57722
+ if (input.outcome === "denied")
57723
+ return "rejected";
57724
+ if (input.outcome === "approved" && input.source === "answer")
57725
+ return "answered";
57726
+ if (input.outcome === "unavailable" && input.source === "fail-closed")
57727
+ return "no-channel";
57728
+ return "unrecorded";
57729
+ }
57730
+ if (input.journalKind === "ask.cancelled") {
57731
+ if (input.cancelReason === "deadline")
57732
+ return "timeout";
57733
+ if (input.cancelReason === "host-abort")
57734
+ return "ended";
57735
+ return "unrecorded";
57736
+ }
57737
+ if (input.outcome === "approved")
57738
+ return "answered";
57739
+ if (input.outcome === "denied")
57740
+ return "rejected";
57741
+ if (input.outcome === "unavailable")
57742
+ return "no-channel";
57743
+ return "unrecorded";
57744
+ }
57745
+ function reasonText(reason) {
57746
+ if (reason === "ended")
57747
+ return LEGACY_ENDED_TEXT;
57748
+ if (reason === "unrecorded")
57749
+ return LEGACY_UNRECORDED_TEXT;
57750
+ return SETTLE_TEXT[reason] ?? LEGACY_UNRECORDED_TEXT;
57751
+ }
57752
+ function deriveAskOutcomeNotice(input) {
57753
+ if (input.eventId === "" || input.sessionId === "" || input.sessionId === "unknown")
57754
+ return;
57755
+ if (input.source === "summary")
57756
+ return;
57757
+ if (!input.orphan && input.askKind === "questions" && input.outcome === "approved" && input.childSessionId === undefined) {
57758
+ return;
57759
+ }
57760
+ const text = input.orphan ? LEGACY_ORPHAN_TEXT : reasonText(input.settleReason !== undefined && CLOSED_SETTLE_REASONS.has(input.settleReason) ? input.settleReason : legacyReason(input));
57761
+ return {
57762
+ id: `ask-outcome:${input.eventId}`,
57763
+ text,
57764
+ anchorSeq: input.anchorSeq,
57765
+ sessionId: input.sessionId
57766
+ };
57767
+ }
57768
+ var CLOSED_SETTLE_REASONS, SETTLE_TEXT, LEGACY_ENDED_TEXT = "\u8BE5\u8BF7\u6C42\u5DF2\u7ED3\u675F\uFF08\u65E7\u65E5\u5FD7\u672A\u7EC6\u5206\uFF09", LEGACY_UNRECORDED_TEXT = "\u8BE5\u8BF7\u6C42\u7ED3\u5C40\u672A\u8BB0\u5F55\uFF08\u65E7\u65E5\u5FD7\u672A\u7EC6\u5206\uFF09", LEGACY_ORPHAN_TEXT = "\u672A\u6536\u5230\u8BE5\u8BF7\u6C42\u7684\u56DE\u7B54\u7ED3\u679C";
57769
+ var init_ask_outcome = __esm(() => {
57770
+ CLOSED_SETTLE_REASONS = new Set([
57771
+ "answered",
57772
+ "rejected",
57773
+ "unavailable",
57774
+ "timeout",
57775
+ "aborted",
57776
+ "turn-ended",
57777
+ "session-closed",
57778
+ "detached",
57779
+ "connection-closed",
57780
+ "no-channel",
57781
+ "auto-approved"
57782
+ ]);
57783
+ SETTLE_TEXT = {
57784
+ answered: "\u5DF2\u6536\u5230\u8BE5\u8BF7\u6C42\u7684\u56DE\u7B54",
57785
+ rejected: "\u8BE5\u8BF7\u6C42\u5DF2\u88AB\u62D2\u7EDD",
57786
+ unavailable: "\u8BE5\u8BF7\u6C42\u65E0\u53EF\u7528\u56DE\u7B54\u6E20\u9053",
57787
+ timeout: "\u7B49\u5F85\u8BE5\u8BF7\u6C42\u7684\u56DE\u7B54\u8D85\u65F6",
57788
+ aborted: "\u8BE5\u8BF7\u6C42\u88AB\u4E2D\u6B62",
57789
+ "turn-ended": "\u56DE\u5408\u7ED3\u675F\u65F6\u8BE5\u8BF7\u6C42\u5DF2\u53D6\u6D88",
57790
+ "session-closed": "\u4F1A\u8BDD\u5173\u95ED\u65F6\u8BE5\u8BF7\u6C42\u5DF2\u53D6\u6D88",
57791
+ detached: "\u8BE5\u8BF7\u6C42\u5DF2\u8131\u79BB\u5F53\u524D\u4F1A\u8BDD",
57792
+ "connection-closed": "\u8FDE\u63A5\u5173\u95ED\u65F6\u8BE5\u8BF7\u6C42\u5DF2\u53D6\u6D88",
57793
+ "no-channel": "\u6CA1\u6709\u53EF\u7528\u6295\u9012\u6E20\u9053\uFF0C\u8BE5\u8BF7\u6C42\u672A\u5B8C\u6210",
57794
+ "auto-approved": "\u8BE5\u8BF7\u6C42\u5DF2\u81EA\u52A8\u6279\u51C6"
57795
+ };
57796
+ });
57797
+
57595
57798
  // src/client/bridge-side-session.ts
57596
57799
  import { randomUUID as randomUUID2 } from "crypto";
57597
57800
  function classify(err, stage) {
@@ -59434,7 +59637,7 @@ function foldModelRouteCache(cache, rows) {
59434
59637
  function liveModelRoute(fold) {
59435
59638
  return fold.pending ?? fold.lastUsed;
59436
59639
  }
59437
- function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
59640
+ function bridgeReplayRowsToSeamTranscript(rows, skip = 0, sessionId) {
59438
59641
  const entries = rows.map((row) => ({
59439
59642
  type: row.type,
59440
59643
  seq: row.seq,
@@ -59442,7 +59645,7 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
59442
59645
  data: asRecord12(row.payload)
59443
59646
  }));
59444
59647
  const durable = journalToTranscriptRows(entries, skip);
59445
- return durable.map((row) => {
59648
+ const stored = durable.map((row) => {
59446
59649
  if (row.kind === "ask") {
59447
59650
  return { kind: "ask", text: "", final: true, entries: row.entries };
59448
59651
  }
@@ -59451,11 +59654,177 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
59451
59654
  }
59452
59655
  return { kind: row.kind, text: row.text, final: true };
59453
59656
  });
59657
+ if (sessionId === undefined || sessionId === "" || sessionId === "unknown")
59658
+ return stored;
59659
+ const notices = deriveAskOutcomeNoticeViews(rows, sessionId);
59660
+ if (notices.length === 0)
59661
+ return stored;
59662
+ const prefixCounts = new Map;
59663
+ const byInsert = new Map;
59664
+ for (const notice of notices) {
59665
+ let count = prefixCounts.get(notice.anchorSeq);
59666
+ if (count === undefined) {
59667
+ count = journalToTranscriptRows(entries.filter((e) => e.seq <= notice.anchorSeq), 0).length;
59668
+ prefixCounts.set(notice.anchorSeq, count);
59669
+ }
59670
+ const insertAt = Math.max(0, Math.min(stored.length, count - skip));
59671
+ const bucket = byInsert.get(insertAt);
59672
+ if (bucket === undefined)
59673
+ byInsert.set(insertAt, [notice]);
59674
+ else
59675
+ bucket.push(notice);
59676
+ }
59677
+ const merged = [];
59678
+ for (let i = 0;i <= stored.length; i++) {
59679
+ for (const notice of byInsert.get(i) ?? []) {
59680
+ merged.push({ kind: "notice", id: notice.id, text: notice.text, final: true });
59681
+ }
59682
+ if (i < stored.length)
59683
+ merged.push(stored[i]);
59684
+ }
59685
+ return merged;
59454
59686
  }
59455
59687
  function seamReplayEventKey(event) {
59456
59688
  const details = asRecord12(event.details);
59457
59689
  return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord12(details.part).id ?? "")}`;
59458
59690
  }
59691
+ function askJournalKind(row, data) {
59692
+ if (typeof data.kind === "string" && data.kind !== "")
59693
+ return data.kind;
59694
+ const prefix = "plugin:opentui/ask/";
59695
+ if (row.type.startsWith(prefix))
59696
+ return `ask.${row.type.slice(prefix.length)}`;
59697
+ return;
59698
+ }
59699
+ function deriveAskOutcomeNoticeViews(rows, sessionId) {
59700
+ const out = [];
59701
+ const terminals = new Map;
59702
+ for (const row of rows) {
59703
+ const data = asRecord12(row.payload);
59704
+ const kind = askJournalKind(row, data);
59705
+ if (kind !== "ask.responded" && kind !== "ask.cancelled")
59706
+ continue;
59707
+ const eventId = optionalStringField(data, "eventId");
59708
+ if (eventId === undefined || optionalStringField(data, "sessionId") !== sessionId)
59709
+ continue;
59710
+ const group = terminals.get(eventId);
59711
+ if (group === undefined)
59712
+ terminals.set(eventId, [row]);
59713
+ else
59714
+ group.push(row);
59715
+ }
59716
+ for (const [eventId, group] of terminals) {
59717
+ const ordered = [...group].sort((a, b) => a.seq - b.seq);
59718
+ const canonical = ordered[ordered.length - 1];
59719
+ const noticeOf = (row) => {
59720
+ const data = asRecord12(row.payload);
59721
+ return deriveAskOutcomeNotice({
59722
+ eventId,
59723
+ sessionId,
59724
+ anchorSeq: row.seq,
59725
+ settleReason: optionalStringField(data, "settleReason"),
59726
+ journalKind: askJournalKind(row, data),
59727
+ askKind: optionalStringField(data, "askKind"),
59728
+ outcome: optionalStringField(data, "outcome"),
59729
+ source: optionalStringField(data, "source"),
59730
+ cancelReason: optionalStringField(data, "reason"),
59731
+ childSessionId: optionalStringField(data, "childSessionId")
59732
+ });
59733
+ };
59734
+ const canonicalNotice = noticeOf(canonical);
59735
+ if (canonicalNotice === undefined)
59736
+ continue;
59737
+ const canonicalChild = optionalStringField(asRecord12(canonical.payload), "childSessionId");
59738
+ out.push({
59739
+ id: canonicalNotice.id,
59740
+ text: canonicalNotice.text,
59741
+ anchorSeq: canonicalNotice.anchorSeq,
59742
+ sessionId,
59743
+ ...canonicalChild !== undefined ? { childSessionId: canonicalChild } : {}
59744
+ });
59745
+ const seenText = new Set([canonicalNotice.text]);
59746
+ for (const row of ordered) {
59747
+ if (row === canonical)
59748
+ continue;
59749
+ const other = noticeOf(row);
59750
+ if (other === undefined || seenText.has(other.text))
59751
+ continue;
59752
+ seenText.add(other.text);
59753
+ const childSessionId = optionalStringField(asRecord12(row.payload), "childSessionId");
59754
+ out.push({
59755
+ id: `${other.id}:seq-${row.seq}`,
59756
+ text: `\u3010\u65E5\u5FD7\u7ED3\u5C40\u51B2\u7A81\u3011${other.text}`,
59757
+ anchorSeq: other.anchorSeq,
59758
+ sessionId,
59759
+ ...childSessionId !== undefined ? { childSessionId } : {}
59760
+ });
59761
+ }
59762
+ }
59763
+ const terminalIds = new Set(terminals.keys());
59764
+ const turnEnds = new Map;
59765
+ for (const row of rows) {
59766
+ if (row.type !== "turn/end")
59767
+ continue;
59768
+ const data = asRecord12(row.payload);
59769
+ const keys = [optionalStringField(data, "turnId")];
59770
+ if (typeof data.turn === "number" && Number.isFinite(data.turn))
59771
+ keys.push(String(data.turn));
59772
+ for (const key of keys) {
59773
+ if (key === undefined)
59774
+ continue;
59775
+ const prior = turnEnds.get(key);
59776
+ if (prior === undefined || row.seq > prior.seq)
59777
+ turnEnds.set(key, row);
59778
+ }
59779
+ }
59780
+ for (const row of rows) {
59781
+ const data = asRecord12(row.payload);
59782
+ if (askJournalKind(row, data) !== "ask.requested")
59783
+ continue;
59784
+ const eventId = optionalStringField(data, "eventId");
59785
+ if (eventId === undefined || terminalIds.has(eventId))
59786
+ continue;
59787
+ if (optionalStringField(data, "sessionId") !== sessionId)
59788
+ continue;
59789
+ const turnKey = optionalStringField(data, "turnId") ?? askTurnId(eventId);
59790
+ if (turnKey === undefined || turnKey === "")
59791
+ continue;
59792
+ const turnEnd = turnEnds.get(turnKey);
59793
+ if (turnEnd === undefined)
59794
+ continue;
59795
+ const notice = deriveAskOutcomeNotice({
59796
+ eventId,
59797
+ sessionId,
59798
+ anchorSeq: turnEnd.seq,
59799
+ orphan: true,
59800
+ askKind: optionalStringField(data, "askKind"),
59801
+ childSessionId: optionalStringField(data, "childSessionId")
59802
+ });
59803
+ if (notice !== undefined) {
59804
+ const childSessionId = optionalStringField(data, "childSessionId");
59805
+ out.push({
59806
+ id: notice.id,
59807
+ text: notice.text,
59808
+ anchorSeq: notice.anchorSeq,
59809
+ sessionId,
59810
+ ...childSessionId !== undefined ? { childSessionId } : {}
59811
+ });
59812
+ }
59813
+ }
59814
+ return out;
59815
+ }
59816
+ function askOutcomeEvent(view) {
59817
+ return {
59818
+ type: "message.updated",
59819
+ details: {
59820
+ id: view.id,
59821
+ role: "notice",
59822
+ text: view.text,
59823
+ sessionID: view.sessionId,
59824
+ ...view.childSessionId !== undefined ? { childSessionId: view.childSessionId } : {}
59825
+ }
59826
+ };
59827
+ }
59459
59828
  function bridgeReplayRowsToSeamEvents(rows, sessionId) {
59460
59829
  const events = [];
59461
59830
  const seen = new Set;
@@ -59466,6 +59835,14 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
59466
59835
  seen.add(key);
59467
59836
  events.push(event);
59468
59837
  };
59838
+ const noticeViews = [...deriveAskOutcomeNoticeViews(rows, sessionId)].sort((a, b) => a.anchorSeq - b.anchorSeq);
59839
+ let nextNotice = 0;
59840
+ const flushNoticesThrough = (seq) => {
59841
+ while (nextNotice < noticeViews.length && noticeViews[nextNotice].anchorSeq <= seq) {
59842
+ push(askOutcomeEvent(noticeViews[nextNotice]));
59843
+ nextNotice++;
59844
+ }
59845
+ };
59469
59846
  const toolCalls = new Map;
59470
59847
  for (const row of rows) {
59471
59848
  const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord12(row.payload) };
@@ -59506,7 +59883,9 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
59506
59883
  });
59507
59884
  }
59508
59885
  }
59886
+ flushNoticesThrough(row.seq);
59509
59887
  }
59888
+ flushNoticesThrough(Number.POSITIVE_INFINITY);
59510
59889
  return events;
59511
59890
  }
59512
59891
  function bridgeAgentRunKey(runId, seq) {
@@ -59727,7 +60106,7 @@ function bridgeChildJournalMeta(rows) {
59727
60106
  };
59728
60107
  }
59729
60108
  function bridgeReplayRowsToChildLog(rows) {
59730
- return bridgeReplayRowsToSeamTranscript(rows).map((row) => {
60109
+ return bridgeReplayRowsToSeamTranscript(rows).filter((row) => row.kind !== "notice").map((row) => {
59731
60110
  if (row.kind === "tool") {
59732
60111
  return row.output ? `\u25B6 ${row.text}
59733
60112
  \u23BF ${row.output}` : `\u25B6 ${row.text}`;
@@ -60296,6 +60675,7 @@ class BridgeSessionSeam {
60296
60675
  #deadInFlight;
60297
60676
  #inFlightPartial = "";
60298
60677
  #invalidatedAsks = new Map;
60678
+ #emittedAskOutcomes = new Set;
60299
60679
  #disposed = false;
60300
60680
  constructor(options) {
60301
60681
  this.#transport = options.transport;
@@ -60493,7 +60873,7 @@ class BridgeSessionSeam {
60493
60873
  this.#foldAgentReplayRows(drained.rows, boundId);
60494
60874
  this.#foldModelRouteFromDrain(boundId, drained.rows, from);
60495
60875
  await this.#sweepSubagents(boundId);
60496
- const rows = bridgeReplayRowsToSeamTranscript(drained.rows);
60876
+ const rows = bridgeReplayRowsToSeamTranscript(drained.rows, 0, boundId);
60497
60877
  if (drained.rows.length > 0) {
60498
60878
  const maxSeq = drained.rows.reduce((m, row) => Math.max(m, row.seq), -Infinity);
60499
60879
  this.#lastAppliedSeq = Math.max(this.#lastAppliedSeq ?? 0, maxSeq);
@@ -61316,7 +61696,7 @@ class BridgeSessionSeam {
61316
61696
  const rows = Array.isArray(asRecord12(value).rows) ? asRecord12(value).rows : [];
61317
61697
  this.#foldAgentReplayRows(rows, id);
61318
61698
  this.#sweepSubagents(id);
61319
- return bridgeReplayRowsToSeamTranscript(rows, skip);
61699
+ return bridgeReplayRowsToSeamTranscript(rows, skip, id);
61320
61700
  }
61321
61701
  async sessionJournal(id) {
61322
61702
  const value = await this.#transport.request("journal.replay", { sessionId: id });
@@ -61825,6 +62205,33 @@ class BridgeSessionSeam {
61825
62205
  const eventId = optionalStringField(payload, "eventId");
61826
62206
  if (eventId !== undefined)
61827
62207
  this.#settlePendingAsk(eventId);
62208
+ const bound = this.currentSessionId();
62209
+ const sid = optionalStringField(payload, "sessionId");
62210
+ const childSessionId = optionalStringField(payload, "childSessionId");
62211
+ if (eventId !== undefined && bound !== undefined && sid === bound && !this.#emittedAskOutcomes.has(eventId)) {
62212
+ const notice = deriveAskOutcomeNotice({
62213
+ eventId,
62214
+ sessionId: sid,
62215
+ anchorSeq: 0,
62216
+ settleReason: optionalStringField(payload, "reason"),
62217
+ askKind: optionalStringField(payload, "kind"),
62218
+ outcome: optionalStringField(payload, "outcome"),
62219
+ childSessionId
62220
+ });
62221
+ if (notice !== undefined) {
62222
+ this.#emittedAskOutcomes.add(eventId);
62223
+ this.#emitEvent({
62224
+ type: "message.updated",
62225
+ details: {
62226
+ id: notice.id,
62227
+ role: "notice",
62228
+ text: notice.text,
62229
+ sessionID: notice.sessionId,
62230
+ ...childSessionId !== undefined ? { childSessionId } : {}
62231
+ }
62232
+ });
62233
+ }
62234
+ }
61828
62235
  return true;
61829
62236
  }
61830
62237
  case "ask.pending": {
@@ -62028,6 +62435,7 @@ var CONFIRM_REQUIRED = (method) => new BridgeProtocolError("CONFIRM_REQUIRED", `
62028
62435
  var init_bridge_session_seam = __esm(() => {
62029
62436
  init_remote_session_ops();
62030
62437
  init_journal_projection();
62438
+ init_ask_outcome();
62031
62439
  init_bridge_side_session();
62032
62440
  init_loop();
62033
62441
  init_local_config_faces();
@@ -63569,5 +63977,5 @@ if (import.meta.main) {
63569
63977
  main();
63570
63978
  }
63571
63979
 
63572
- //# debugId=0ED0D1BCF742D48C64756E2164756E21
63980
+ //# debugId=DAD2522A36CE287C64756E2164756E21
63573
63981
  //# sourceMappingURL=index.js.map