@gobing-ai/knowledge-kit 0.1.25 → 0.1.28

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.
Files changed (62) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/board/collect/index.js +10 -0
  3. package/dist/board/daily-voice/index.js +1327 -2168
  4. package/dist/board/itc/index.js +10 -0
  5. package/dist/index.js +6043 -4620
  6. package/package.json +1 -1
  7. package/plugins/ingestions/aihot-ingest/dist/index.js +4 -1
  8. package/plugins/ingestions/aihot-ingest/src/rss.ts +22 -11
  9. package/plugins/kk/plugin.json +1 -1
  10. package/plugins/kk/scripts/cn-lead-gate.ts +494 -0
  11. package/plugins/kk/scripts/daily-stages.ts +423 -141
  12. package/plugins/kk/scripts/kk-workflow-stages.ts +53 -3
  13. package/plugins/kk/skills/news-editorial/SKILL.md +20 -3
  14. package/plugins/kk/skills/news-editorial/references/selection.md +42 -0
  15. package/plugins/kk/workflows/kk-news-generate.yaml +1 -1
  16. package/plugins/publishings/bilibili-pub/dist/index.js +114 -82
  17. package/plugins/publishings/bilibili-pub/dist/profile-check.js +34 -3
  18. package/plugins/publishings/cnblogs-pub/dist/index.js +114 -82
  19. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +34 -3
  20. package/plugins/publishings/csdn-pub/dist/index.js +114 -82
  21. package/plugins/publishings/csdn-pub/dist/profile-check.js +34 -3
  22. package/plugins/publishings/infoq-pub/dist/index.js +114 -82
  23. package/plugins/publishings/infoq-pub/dist/profile-check.js +34 -3
  24. package/plugins/publishings/jike-pub/dist/index.js +114 -82
  25. package/plugins/publishings/jike-pub/dist/profile-check.js +34 -3
  26. package/plugins/publishings/juejin-pub/dist/index.js +114 -82
  27. package/plugins/publishings/juejin-pub/dist/profile-check.js +34 -3
  28. package/plugins/publishings/linkedin-pub/dist/index.js +165 -93
  29. package/plugins/publishings/linkedin-pub/dist/profile-check.js +51 -6
  30. package/plugins/publishings/linkedin-pub/src/index.ts +126 -9
  31. package/plugins/publishings/medium-pub/dist/index.js +114 -82
  32. package/plugins/publishings/medium-pub/dist/profile-check.js +34 -3
  33. package/plugins/publishings/shipinhao-pub/dist/index.js +305 -87
  34. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +145 -5
  35. package/plugins/publishings/shipinhao-pub/src/cover-crop.ts +60 -0
  36. package/plugins/publishings/shipinhao-pub/src/flow.ts +15 -2
  37. package/plugins/publishings/shipinhao-pub/src/profile-check.ts +15 -12
  38. package/plugins/publishings/shipinhao-pub/src/selectors.ts +22 -1
  39. package/plugins/publishings/sspai-pub/dist/index.js +114 -82
  40. package/plugins/publishings/sspai-pub/dist/profile-check.js +34 -3
  41. package/plugins/publishings/substack-pub/dist/index.js +114 -82
  42. package/plugins/publishings/substack-pub/dist/profile-check.js +34 -3
  43. package/plugins/publishings/surfdash-pub/dist/index.js +96 -20
  44. package/plugins/publishings/surfdash-pub/src/index.ts +31 -4
  45. package/plugins/publishings/surfdash-pub/src/patch.ts +81 -12
  46. package/plugins/publishings/threads-pub/dist/index.js +119 -83
  47. package/plugins/publishings/threads-pub/dist/profile-check.js +34 -3
  48. package/plugins/publishings/threads-pub/src/index.ts +10 -0
  49. package/plugins/publishings/wechatmp-pub/dist/index.js +149 -86
  50. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +68 -4
  51. package/plugins/publishings/wechatmp-pub/src/index.ts +64 -1
  52. package/plugins/publishings/weibo-pub/dist/index.js +273 -91
  53. package/plugins/publishings/weibo-pub/dist/profile-check.js +178 -11
  54. package/plugins/publishings/weibo-pub/plugin.json +1 -1
  55. package/plugins/publishings/weibo-pub/src/index.ts +136 -10
  56. package/plugins/publishings/weibo-pub/src/profile-check.ts +4 -2
  57. package/plugins/publishings/x-pub/dist/index.js +114 -82
  58. package/plugins/publishings/x-pub/dist/profile-check.js +34 -3
  59. package/plugins/publishings/xhs-pub/dist/index.js +114 -82
  60. package/plugins/publishings/xhs-pub/dist/profile-check.js +34 -3
  61. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +114 -82
  62. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +34 -3
@@ -1,8 +1,12 @@
1
1
  // ../board/src/daily-voice/index.tsx
2
2
  import {
3
3
  Badge,
4
+ Button,
5
+ Card,
6
+ CardBody,
4
7
  Diagnostic,
5
8
  EmptyState,
9
+ Loading,
6
10
  ModuleHeader,
7
11
  ModuleShell,
8
12
  ModuleTabs,
@@ -530,221 +534,21 @@ function createBoardClient(options) {
530
534
  storeChannels: (query) => getJson(`${aggregateReader}/api/workflows/kk-collect/store/channels?${storeChannelsQueryString(query)}`),
531
535
  runDetail: (runId) => getJson(`${board}/api/runs/${encodeURIComponent(runId)}`),
532
536
  evidence: (workflow, runId) => getJson(`${reader}/api/workflows/${encodeURIComponent(workflow)}/runs/${encodeURIComponent(runId)}/evidence`),
537
+ day: (day) => getJson(`${reader}/api/days/${encodeURIComponent(day)}`),
538
+ days: (from, until) => getJson(`${reader}/api/days?from=${encodeURIComponent(from)}&until=${encodeURIComponent(until)}`),
539
+ action: async (kind, body) => {
540
+ const response = await doFetch(`${reader}/api/actions/${encodeURIComponent(kind)}`, {
541
+ method: "POST",
542
+ headers: { "content-type": "application/json", "x-kk-action": "1" },
543
+ body: JSON.stringify(body)
544
+ });
545
+ return { status: response.status, body: await response.json() };
546
+ },
533
547
  progress: (runId) => getJson(`${board}/api/runs/${encodeURIComponent(runId)}/progress`)
534
548
  };
535
549
  }
536
550
 
537
- // ../board/src/shared/channel-yield.tsx
538
- import { jsx, jsxs } from "react/jsx-runtime";
539
- function localDayKey(ms, timeZone) {
540
- return new Intl.DateTimeFormat("en-CA", {
541
- timeZone,
542
- year: "numeric",
543
- month: "2-digit",
544
- day: "2-digit"
545
- }).format(ms);
546
- }
547
- function isLocalMidnight(ms, timeZone) {
548
- return new Intl.DateTimeFormat("en-GB", {
549
- timeZone,
550
- hour: "2-digit",
551
- minute: "2-digit",
552
- second: "2-digit",
553
- hour12: false
554
- }).format(ms) === "00:00:00";
555
- }
556
- function isPartialDay(day, data) {
557
- const fromDay = localDayKey(data.fromMs, data.timeZone);
558
- const untilDay = localDayKey(Math.max(data.fromMs, data.untilMs - 1), data.timeZone);
559
- if (day === fromDay && !isLocalMidnight(data.fromMs, data.timeZone))
560
- return true;
561
- if (day === untilDay && !isLocalMidnight(data.untilMs, data.timeZone))
562
- return true;
563
- return false;
564
- }
565
- function lastPositiveLabel(at) {
566
- return at === null ? "unknown" : `${new Date(at).toLocaleString()} (${new Date(at).toISOString()})`;
567
- }
568
- function ChannelYieldTable({ data }) {
569
- const { sources, byDay, bySource } = data;
570
- if (byDay.length === 0) {
571
- return /* @__PURE__ */ jsx("p", {
572
- className: "kk-board-state",
573
- children: "No new items in this range."
574
- });
575
- }
576
- const grandTotal = sources.reduce((sum, source) => sum + (bySource[source] ?? 0), 0);
577
- return /* @__PURE__ */ jsxs("table", {
578
- className: "kk-table kk-channel-yield-table",
579
- children: [
580
- /* @__PURE__ */ jsx("thead", {
581
- children: /* @__PURE__ */ jsxs("tr", {
582
- children: [
583
- /* @__PURE__ */ jsx("th", {
584
- scope: "col",
585
- children: "Day"
586
- }),
587
- sources.map((source) => /* @__PURE__ */ jsx("th", {
588
- scope: "col",
589
- children: source
590
- }, source)),
591
- /* @__PURE__ */ jsx("th", {
592
- scope: "col",
593
- children: "Total"
594
- })
595
- ]
596
- })
597
- }),
598
- /* @__PURE__ */ jsxs("tbody", {
599
- children: [
600
- byDay.map((day) => /* @__PURE__ */ jsxs("tr", {
601
- children: [
602
- /* @__PURE__ */ jsxs("td", {
603
- children: [
604
- day.day,
605
- isPartialDay(day.day, data) ? " (partial)" : ""
606
- ]
607
- }),
608
- sources.map((source) => /* @__PURE__ */ jsx("td", {
609
- children: day.sources[source] ?? 0
610
- }, source)),
611
- /* @__PURE__ */ jsx("td", {
612
- children: day.total
613
- })
614
- ]
615
- }, day.day)),
616
- /* @__PURE__ */ jsxs("tr", {
617
- className: "kk-table-total",
618
- children: [
619
- /* @__PURE__ */ jsx("td", {
620
- children: "Total"
621
- }),
622
- sources.map((source) => /* @__PURE__ */ jsx("td", {
623
- children: bySource[source] ?? 0
624
- }, source)),
625
- /* @__PURE__ */ jsx("td", {
626
- children: grandTotal
627
- })
628
- ]
629
- })
630
- ]
631
- })
632
- ]
633
- });
634
- }
635
- function PluginRunTable({ data }) {
636
- const { plugins, runsByDay, lastPositiveAt } = data;
637
- if (runsByDay.length === 0) {
638
- return /* @__PURE__ */ jsx("p", {
639
- className: "kk-board-state",
640
- children: "No collection ticks in this range."
641
- });
642
- }
643
- return /* @__PURE__ */ jsxs("div", {
644
- className: "kk-plugin-run",
645
- children: [
646
- /* @__PURE__ */ jsxs("table", {
647
- className: "kk-table kk-plugin-run-table",
648
- children: [
649
- /* @__PURE__ */ jsx("caption", {
650
- className: "kk-plugin-run-caption",
651
- children: "Zero recorded contributions — plugin invocation health unknown."
652
- }),
653
- /* @__PURE__ */ jsx("thead", {
654
- children: /* @__PURE__ */ jsxs("tr", {
655
- children: [
656
- /* @__PURE__ */ jsx("th", {
657
- scope: "col",
658
- children: "Day"
659
- }),
660
- /* @__PURE__ */ jsx("th", {
661
- scope: "col",
662
- children: "Runs"
663
- }),
664
- plugins.map((plugin) => /* @__PURE__ */ jsx("th", {
665
- scope: "col",
666
- children: plugin
667
- }, plugin))
668
- ]
669
- })
670
- }),
671
- /* @__PURE__ */ jsx("tbody", {
672
- children: runsByDay.map((day) => {
673
- const pluginCounts = day.plugins;
674
- return /* @__PURE__ */ jsxs("tr", {
675
- children: [
676
- /* @__PURE__ */ jsx("td", {
677
- children: day.day
678
- }),
679
- /* @__PURE__ */ jsx("td", {
680
- children: day.runs
681
- }),
682
- pluginCounts === null ? /* @__PURE__ */ jsx("td", {
683
- colSpan: plugins.length,
684
- className: "kk-board-state",
685
- children: "unknown"
686
- }) : plugins.map((plugin) => /* @__PURE__ */ jsx("td", {
687
- children: pluginCounts[plugin] ?? 0
688
- }, plugin))
689
- ]
690
- }, day.day);
691
- })
692
- })
693
- ]
694
- }),
695
- /* @__PURE__ */ jsx("dl", {
696
- className: "kk-board-facts",
697
- children: plugins.map((plugin) => /* @__PURE__ */ jsxs("div", {
698
- children: [
699
- /* @__PURE__ */ jsxs("dt", {
700
- children: [
701
- "Last positive ",
702
- plugin
703
- ]
704
- }),
705
- /* @__PURE__ */ jsx("dd", {
706
- children: lastPositiveLabel(lastPositiveAt[plugin] ?? null)
707
- })
708
- ]
709
- }, plugin))
710
- })
711
- ]
712
- });
713
- }
714
-
715
551
  // ../board/src/shared/format.ts
716
- function availabilityLabel(availability) {
717
- switch (availability) {
718
- case "available":
719
- return "Available";
720
- case "pending":
721
- return "Not yet written";
722
- case "missing":
723
- return "Missing";
724
- case "invalid":
725
- return "Malformed";
726
- case "oversized":
727
- return "Too large to preview";
728
- case "superseded":
729
- return "Superseded by a later run";
730
- case "unverified":
731
- return "Unverified";
732
- }
733
- }
734
- function formatElapsed(startedAt, now) {
735
- if (startedAt === null || startedAt === undefined)
736
- return "elapsed unknown";
737
- const start = Date.parse(startedAt);
738
- if (Number.isNaN(start))
739
- return "elapsed unknown";
740
- const seconds = Math.max(0, Math.round((now - start) / 1000));
741
- if (seconds < 60)
742
- return `${seconds}s`;
743
- const minutes = Math.floor(seconds / 60);
744
- if (minutes < 60)
745
- return `${minutes}m ${seconds % 60}s`;
746
- return `${Math.floor(minutes / 60)}h ${minutes % 60}m`;
747
- }
748
552
  function dedupeDiagnostics(diagnostics) {
749
553
  const seen = new Set;
750
554
  return diagnostics.filter((diagnostic) => {
@@ -763,401 +567,225 @@ function formatTimestamp(iso) {
763
567
  return `${new Date(epoch).toLocaleString()} (${new Date(epoch).toISOString()})`;
764
568
  }
765
569
 
766
- // ../board/src/shared/collect.ts
767
- function artifactViews(results, readerOrigin) {
768
- return results.artifacts.map((artifact) => ({
769
- id: artifact.id,
770
- label: artifact.label,
771
- kind: artifact.kind,
772
- availability: artifact.availability,
773
- state: availabilityLabel(artifact.availability),
774
- href: artifact.availability === "available" ? `${readerOrigin}/api/workflows/${results.workflow}/runs/${results.runId}/artifacts/${artifact.id}` : null
775
- }));
776
- }
777
-
778
- // ../board/src/shared/refresh.ts
779
- var ACTIVE_POLL_MS = 5000;
780
- var HISTORY_POLL_MS = 30000;
781
- var MAX_BACKOFF_MS = 30000;
782
- function requestSequence() {
783
- let newest = 0;
784
- return { begin: () => ++newest, isCurrent: (token) => token === newest };
785
- }
786
- function initialRefresh(intervalMs) {
787
- return { pending: false, failures: 0, backoffMs: intervalMs, lastSuccessAt: null, failingSince: null };
788
- }
789
- function tick(state) {
790
- return state.pending ? state : { ...state, pending: true };
791
- }
792
- function succeeded(now, intervalMs) {
793
- return { pending: false, failures: 0, backoffMs: intervalMs, lastSuccessAt: now, failingSince: null };
794
- }
795
- function failed(state, now) {
796
- const failures = state.failures + 1;
797
- return {
798
- pending: false,
799
- failures,
800
- backoffMs: Math.min(state.backoffMs * 2, MAX_BACKOFF_MS),
801
- lastSuccessAt: state.lastSuccessAt,
802
- failingSince: state.failingSince ?? now
803
- };
804
- }
805
- function delayMs(state, intervalMs) {
806
- return state.failures > 0 ? state.backoffMs : intervalMs;
807
- }
808
- function isStale(state) {
809
- return state.failures > 0;
810
- }
811
- function freshnessLabel(state) {
812
- if (state.lastSuccessAt === null)
813
- return "Not yet loaded";
814
- const updated = new Date(state.lastSuccessAt).toISOString();
815
- return isStale(state) ? `Stale — last success ${updated}` : `Updated ${updated}`;
816
- }
817
-
818
- // ../board/src/shared/run-selection.ts
819
- var BOARD_TABS = ["summary", "results", "progress", "config"];
820
- function parseDeepLink(search, tabs = BOARD_TABS, aliases = {}) {
821
- const params = new URLSearchParams(search.startsWith("?") ? search.slice(1) : search);
822
- const diagnostics = [];
823
- const rawTab = params.get("tab");
824
- const rawRun = params.get("run");
825
- const known = tabs;
826
- let tab;
827
- if (rawTab !== null) {
828
- const aliased = Object.hasOwn(aliases, rawTab) ? aliases[rawTab] : undefined;
829
- if (known.includes(rawTab)) {
830
- tab = rawTab;
831
- } else if (aliased !== undefined && known.includes(aliased)) {
832
- tab = aliased;
833
- } else {
834
- diagnostics.push({
835
- code: "board.deeplink.unknown-tab",
836
- message: `Unknown tab '${rawTab}'; showing the default tab.`
837
- });
838
- }
839
- }
840
- let runId;
841
- if (rawRun !== null) {
842
- if (rawRun === "") {
843
- diagnostics.push({ code: "board.deeplink.empty-run", message: "Empty run id ignored." });
844
- } else {
845
- runId = rawRun;
846
- }
847
- }
848
- return { ...runId === undefined ? {} : { runId }, ...tab === undefined ? {} : { tab }, diagnostics };
849
- }
850
- function resolveSelection(rows, link, defaultTab = "summary") {
851
- const tab = link.tab ?? defaultTab;
852
- const diagnostics = [...link.diagnostics];
853
- if (link.runId !== undefined) {
854
- if (rows.some((row) => row.id === link.runId)) {
855
- return { runId: link.runId, tab, diagnostics };
856
- }
857
- diagnostics.push({
858
- code: "board.selection.unknown-run",
859
- message: `Run '${link.runId}' is not in the loaded history; select a run.`
860
- });
861
- return { runId: null, tab, diagnostics };
862
- }
863
- return { runId: rows[0]?.id ?? null, tab, diagnostics };
864
- }
865
- function selectionQuery(selection, search = "") {
866
- const params = new URLSearchParams;
867
- if (selection.runId !== null)
868
- params.set("run", selection.runId);
869
- params.set("tab", selection.tab);
870
- for (const [key, value] of new URLSearchParams(search)) {
871
- if (key === "run" || key === "tab")
872
- continue;
873
- params.set(key, value);
874
- }
875
- return `?${params.toString()}`;
876
- }
877
- var COLLECT_MODULE_PATH = "/board/modules/kk-collect";
878
- function selectionPath(selection, search = "", modulePath = COLLECT_MODULE_PATH) {
879
- return `${modulePath}${selectionQuery(selection, search)}`;
880
- }
881
- function syncSelectionUrl(selection, target, modulePath = COLLECT_MODULE_PATH) {
882
- if (target.location.pathname !== modulePath)
883
- return;
884
- const url = selectionPath(selection, target.location.search, modulePath);
885
- if (`${target.location.pathname}${target.location.search}` === url)
886
- return;
887
- target.history.replaceState(target.history.state, "", url);
888
- }
889
- function mergeRunPages(existing, page) {
890
- const seen = new Set(existing.map((row) => row.id));
891
- const merged = [...existing, ...page.runs.filter((row) => !seen.has(row.id))];
892
- return { runs: merged, count: merged.length, nextCursor: page.nextCursor, hasMore: page.hasMore };
893
- }
894
-
895
- // ../board/src/daily-voice/view.ts
896
- var CHANNEL_OUTCOME_LABELS = {
897
- live: "Live",
898
- draft: "Draft",
899
- skipped: "Skipped",
900
- error: "Failed",
901
- pending: "Not yet recorded",
902
- unavailable: "Unavailable"
570
+ // ../board/src/daily-voice/day-view.ts
571
+ var CONSOLE_TABS = ["today", "generation", "publishing", "history", "actions"];
572
+ var CONSOLE_TAB_LABELS = {
573
+ today: "Today",
574
+ generation: "Generation",
575
+ publishing: "Publishing",
576
+ history: "History",
577
+ actions: "Actions log"
903
578
  };
904
- function asRecord(value) {
905
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
906
- }
907
- function asString(value) {
908
- return typeof value === "string" && value !== "" ? value : null;
909
- }
910
- function asNumber(value) {
911
- return typeof value === "number" && Number.isFinite(value) ? value : null;
912
- }
913
- function asBool(value) {
914
- return typeof value === "boolean" ? value : null;
915
- }
916
- function isChannelOutcome(value) {
917
- return value === "live" || value === "draft" || value === "skipped" || value === "error" || value === "pending" || value === "unavailable";
918
- }
919
- function isConfidenceLevel(value) {
920
- return value === "HIGH" || value === "MEDIUM" || value === "LOW";
921
- }
922
- function channelView(value) {
923
- const record = asRecord(value);
924
- if (record === null || typeof record.channel !== "string" || !isChannelOutcome(record.outcome))
925
- return null;
579
+ var HISTORY_DEFAULT_DAYS = 14;
580
+ function isDayKey(day) {
581
+ return /^\d{8}$/.test(day);
582
+ }
583
+ function parseConsoleHash(hash) {
584
+ const raw = hash.startsWith("#") ? hash.slice(1) : hash;
585
+ const params = new URLSearchParams(raw);
586
+ const day = params.get("day");
587
+ const tab = params.get("tab");
926
588
  return {
927
- channel: record.channel,
928
- label: asString(record.label) ?? record.channel,
929
- outcome: record.outcome,
930
- state: CHANNEL_OUTCOME_LABELS[record.outcome],
931
- url: asString(record.url),
932
- detail: asString(record.detail)
589
+ day: day !== null && isDayKey(day) ? day : null,
590
+ tab: tab !== null && CONSOLE_TABS.includes(tab) ? tab : "today"
933
591
  };
934
592
  }
935
- function nodeView(value) {
936
- const record = asRecord(value);
937
- if (record === null || typeof record.id !== "string")
938
- return null;
939
- return {
940
- id: record.id,
941
- status: asString(record.status) ?? "unknown",
942
- attempts: asNumber(record.attempts) ?? 0,
943
- timing: asString(record.timing) ?? "timing unknown"
944
- };
945
- }
946
- function progressView(value) {
947
- const record = asRecord(value);
948
- if (record === null)
949
- return null;
950
- const edges = Array.isArray(record.edges) ? record.edges.map((edge) => asRecord(edge)).filter((edge) => edge !== null).map((edge) => ({ from: String(edge.from ?? ""), to: String(edge.to ?? "") })) : null;
951
- return {
952
- nodes: Array.isArray(record.nodes) ? record.nodes.map(nodeView).filter((node) => node !== null) : [],
953
- edges,
954
- edgesKnown: record.edgesKnown === true,
955
- childRunId: asString(record.childRunId)
593
+ function consoleHash(day, tab) {
594
+ const params = new URLSearchParams;
595
+ if (day !== null && isDayKey(day))
596
+ params.set("day", day);
597
+ params.set("tab", tab);
598
+ return `#${params.toString()}`;
599
+ }
600
+ function dayStatusWord(status) {
601
+ const words = {
602
+ ok: "all clear",
603
+ attention: "needs attention",
604
+ failed: "failed",
605
+ running: "running",
606
+ unknown: "unknown"
956
607
  };
957
- }
958
- function dailySummary(results) {
959
- const raw = results.summary ?? {};
960
- const counts = asRecord(raw.counts);
961
- const quality = asRecord(raw.quality);
962
- const safety = asRecord(raw.safety);
963
- return {
964
- status: asString(raw.status),
965
- startedAt: asString(raw.startedAt),
966
- completedAt: asString(raw.completedAt),
967
- outcome: asString(raw.outcome),
968
- articleTitle: asString(raw.articleTitle),
969
- channels: Array.isArray(raw.channels) ? raw.channels.map(channelView).filter((channel) => channel !== null) : [],
970
- quality: quality === null ? null : {
971
- overallScore: asNumber(quality.overallScore),
972
- passed: asBool(quality.passed),
973
- criticalIssues: Array.isArray(quality.criticalIssues) ? quality.criticalIssues.filter((issue) => typeof issue === "string") : []
974
- },
975
- safety: safety === null ? null : {
976
- verdict: asString(safety.verdict),
977
- confidence: isConfidenceLevel(safety.confidence) ? safety.confidence : null
978
- },
979
- progress: progressView(raw.progress),
980
- counts: {
981
- live: asNumber(counts?.live) ?? 0,
982
- draft: asNumber(counts?.draft) ?? 0,
983
- failed: asNumber(counts?.failed) ?? 0,
984
- skipped: asNumber(counts?.skipped) ?? 0
985
- },
986
- countsRecorded: counts !== null
608
+ const tones = {
609
+ ok: "success",
610
+ attention: "warn",
611
+ failed: "error",
612
+ running: "info",
613
+ unknown: "neutral"
987
614
  };
615
+ return { word: words[status], tone: tones[status] };
988
616
  }
989
- function count(value) {
990
- return value === null ? "unavailable" : String(value);
617
+ function unknownWord(reason) {
618
+ return reason === null ? "unknown" : `unknown (${reason})`;
991
619
  }
992
- function dailySummaryFacts(results, now) {
993
- const summary = dailySummary(results);
994
- const available = results.artifacts.filter((artifact) => artifact.availability === "available").length;
995
- const facts = [
996
- {
997
- label: "Execution status",
998
- value: summary.status ?? "unavailable",
999
- availability: summary.status === null ? "unverified" : "available"
1000
- },
1001
- {
1002
- label: "Result outcome",
1003
- value: summary.outcome ?? "unavailable",
1004
- availability: summary.outcome === null ? "unverified" : "available"
1005
- },
1006
- {
1007
- label: "Result availability",
1008
- value: `${available}/${results.artifacts.length} artifacts available`,
1009
- availability: results.availability
1010
- },
1011
- {
1012
- label: "Started",
1013
- value: formatTimestamp(summary.startedAt),
1014
- availability: summary.startedAt === null ? "unverified" : "available"
1015
- },
1016
- {
1017
- label: "Elapsed",
1018
- value: formatElapsed(summary.startedAt, now),
1019
- availability: summary.startedAt === null ? "unverified" : "available"
1020
- },
620
+ function generationFacts(digest) {
621
+ const generation = digest.generation;
622
+ const status = dayStatusWord(digest.status);
623
+ return [
624
+ { label: "day status", value: status.word, tone: status.tone },
1021
625
  {
1022
- label: "Channels live / draft",
1023
- value: summary.countsRecorded ? `${summary.counts.live} live, ${summary.counts.draft} draft` : "not recorded",
1024
- availability: summary.countsRecorded ? "available" : "unverified"
626
+ label: "run",
627
+ value: generation.runId ?? unknownWord(generation.unknownReason),
628
+ tone: generation.runId === null ? "warn" : "neutral"
1025
629
  },
1026
630
  {
1027
- label: "Channels failed / skipped",
1028
- value: summary.countsRecorded ? `${summary.counts.failed} failed, ${summary.counts.skipped} skipped` : "not recorded",
1029
- availability: !summary.countsRecorded ? "unverified" : summary.counts.failed > 0 ? "missing" : "available"
631
+ label: "launch",
632
+ value: generation.launchStatus ?? unknownWord(generation.unknownReason),
633
+ tone: generation.launchStatus === "done" ? "success" : generation.launchStatus === null ? "warn" : "info"
1030
634
  },
1031
635
  {
1032
- label: "Article",
1033
- value: summary.articleTitle ?? "unavailable",
1034
- availability: summary.articleTitle === null ? "unverified" : "available"
636
+ label: "outcome",
637
+ value: generation.outcome ?? unknownWord(generation.unknownReason),
638
+ tone: generation.outcome === "episode" ? "success" : generation.outcome === null ? "warn" : "info"
1035
639
  },
1036
640
  {
1037
- label: "Audio QC score",
1038
- value: count(summary.quality?.overallScore ?? null),
1039
- availability: summary.quality === null ? "unverified" : "available"
641
+ label: "bundle",
642
+ value: generation.bundle === null ? "unknown" : `${generation.bundle.identity} · ${generation.bundle.title ?? "untitled"}`,
643
+ tone: generation.bundle === null ? "warn" : "neutral"
1040
644
  },
1041
645
  {
1042
- label: "Content safety verdict",
1043
- value: summary.safety?.verdict ?? "not recorded",
1044
- availability: summary.safety === null ? "unverified" : "available"
646
+ label: "safety",
647
+ value: digest.safety.verdict === null ? unknownWord(digest.safety.unknownReason) : `${digest.safety.verdict}${digest.safety.judge === null ? "" : ` (judge ${digest.safety.judge})`}`,
648
+ tone: digest.safety.verdict === "pass" ? "success" : digest.safety.verdict === null ? "warn" : "error"
1045
649
  },
1046
650
  {
1047
- label: "Safety confidence",
1048
- value: summary.safety?.confidence ?? "not recorded",
1049
- availability: summary.safety?.confidence == null ? "unverified" : "available"
651
+ label: "attempts",
652
+ value: generation.attempts.length === 0 ? unknownWord("no-capture-record") : String(generation.attempts.length),
653
+ tone: generation.attempts.length === 0 ? "warn" : "neutral"
1050
654
  }
1051
655
  ];
1052
- return facts;
1053
656
  }
1054
- var GATE_NAMES = {
1055
- "episode-duration": "Duration floor refusal",
1056
- script: "Script refusal",
1057
- "qc-floor": "QC floor refusal",
1058
- "empty-pool": "Empty pool",
1059
- "qc-empty": "QC emptied the pool",
1060
- unknown: "unknown — no gate proven"
1061
- };
1062
- function isFunnelGate(value) {
1063
- return value === "episode-duration" || value === "script" || value === "qc-floor" || value === "empty-pool" || value === "qc-empty" || value === "unknown";
657
+ function windowLabel(window) {
658
+ const words = window.replace(/[-_]/g, " ");
659
+ return words.charAt(0).toUpperCase() + words.slice(1);
1064
660
  }
1065
- function funnelView(value) {
1066
- const record = asRecord(value);
1067
- const gate = isFunnelGate(record?.gate) ? record.gate : null;
1068
- return {
1069
- poolCount: asNumber(record?.poolCount),
1070
- annotatedCount: asNumber(record?.annotatedCount),
1071
- qcRejectedCount: asNumber(record?.qcRejectedCount),
1072
- topicKeptCount: asNumber(record?.topicKeptCount),
1073
- dedupKeptCount: asNumber(record?.dedupKeptCount),
1074
- plannedCount: asNumber(record?.plannedCount),
1075
- estimatedMinutes: asNumber(record?.estimatedMinutes),
1076
- measuredMinutes: asNumber(record?.measuredMinutes),
1077
- minMinutes: asNumber(record?.minMinutes),
1078
- maxMinutes: asNumber(record?.maxMinutes),
1079
- gate,
1080
- gateName: gate === null ? "not applicable — a content run has no gate" : GATE_NAMES[gate],
1081
- exclusions: Array.isArray(record?.exclusions) ? record.exclusions.map((entry) => {
1082
- const row = asRecord(entry);
1083
- return row === null || typeof row.rule !== "string" ? null : { rule: row.rule, matched: typeof row.matched === "string" ? row.matched : "" };
1084
- }).filter((row) => row !== null) : [],
1085
- evidence: record === null ? {} : Object.fromEntries(Object.entries(record.evidence ?? {}).filter((entry) => typeof entry[1] === "string")),
1086
- diagnostics: Array.isArray(record?.diagnostics) ? record.diagnostics.map((entry) => {
1087
- const row = asRecord(entry);
1088
- return row === null ? null : { code: String(row.code ?? ""), message: String(row.message ?? "") };
1089
- }).filter((row) => row !== null) : []
1090
- };
661
+ function windowRows(digest) {
662
+ return digest.windows.map((window) => {
663
+ const tone = window.launchStatus === "done" ? "success" : window.launchStatus === "failed" ? "error" : window.launchStatus === "running" ? "info" : window.launchStatus === "not-run" ? "neutral" : "warn";
664
+ return {
665
+ window: window.window,
666
+ label: windowLabel(window.window),
667
+ launch: window.launchStatus,
668
+ tone,
669
+ recorded: window.recordedStatus ?? "unknown",
670
+ unknownReason: window.unknownReason,
671
+ targets: window.targets.map((target) => ({
672
+ id: target.id,
673
+ target: target.target ?? target.id.split(".")[0] ?? target.id,
674
+ status: target.status,
675
+ effect: target.effect ?? "unknown",
676
+ error: target.error ?? "",
677
+ evidence: target.evidence.receipt ?? target.evidence.plan
678
+ }))
679
+ };
680
+ });
1091
681
  }
1092
- var WINDOW_UNITS = {
1093
- s: 1000,
1094
- m: 60000,
1095
- h: 3600000,
1096
- d: 86400000
1097
- };
1098
- function parseWindowMs(raw) {
1099
- if (raw === null || raw === undefined)
1100
- return null;
1101
- const match = /^(\d+)([smhd])$/.exec(raw.trim());
1102
- if (match === null)
1103
- return null;
1104
- const [, amountText, unitText] = match;
1105
- const unit = unitText === "s" || unitText === "m" || unitText === "h" || unitText === "d" ? unitText : null;
1106
- if (amountText === undefined || unit === null)
1107
- return null;
1108
- const milliseconds = Number(amountText) * WINDOW_UNITS[unit];
1109
- return milliseconds > 0 ? milliseconds : null;
682
+ function actionLogRows(digest) {
683
+ return [...digest.actions.lines].reverse().map((line) => {
684
+ const word = line.refusal !== undefined && line.refusal !== null ? `refused: ${line.refusal}` : line.result === "preview" ? "preview" : line.result === "launched" ? "launched" : line.exit === null ? line.result ?? "recorded" : `exit ${line.exit}`;
685
+ const tone = line.refusal !== undefined && line.refusal !== null ? "warn" : line.exit !== null && line.exit !== 0 ? "error" : line.result === "launched" ? "info" : "success";
686
+ return {
687
+ ts: line.ts,
688
+ kind: line.kind,
689
+ word,
690
+ tone,
691
+ argv: recipeText(line.argv),
692
+ runId: line.runId,
693
+ exit: line.exit,
694
+ refusal: line.refusal ?? null
695
+ };
696
+ });
1110
697
  }
1111
- function supplyContextOf(windowSetting, startedAt) {
1112
- const windowMs = parseWindowMs(windowSetting);
1113
- const started = startedAt === null || startedAt === undefined ? null : Date.parse(startedAt);
1114
- if (windowMs === null || started === null || !Number.isFinite(started))
1115
- return null;
1116
- return {
1117
- windowMs,
1118
- fromMs: started - windowMs,
1119
- untilMs: started,
1120
- fromLabel: formatTimestamp(new Date(started - windowMs).toISOString()),
1121
- untilLabel: formatTimestamp(new Date(started).toISOString())
1122
- };
698
+ function actionPlaneEnabled(digest) {
699
+ return digest.actions.enabled;
1123
700
  }
1124
- var DAILY_VIEWS = ["summary", "generation", "publishing"];
1125
- var DAILY_VIEW_ALIASES = {
1126
- results: "generation",
1127
- progress: "generation",
1128
- config: "summary"
701
+ var SEVERITY_TONE = {
702
+ error: "error",
703
+ warn: "warn",
704
+ info: "info"
1129
705
  };
1130
- var DAILY_WORKFLOW = "kk-news-generate";
1131
- var RETIRED_DAILY_WORKFLOWS = ["kk-daily-ai-voice2", "kk-daily-ai-voice"];
1132
- function pickDailyFamily(current, retired) {
1133
- if (current.length > 0)
1134
- return { family: DAILY_WORKFLOW, rows: current, retired: false };
1135
- const hit = retired.find((source) => source.rows.length > 0);
1136
- if (hit !== undefined)
1137
- return { family: hit.family, rows: hit.rows, retired: true };
1138
- return { family: DAILY_WORKFLOW, rows: current, retired: false };
1139
- }
1140
- function retiredLayoutNotice(choice) {
1141
- if (!choice.retired)
1142
- return null;
1143
- const days = choice.rows.length === 1 ? "1 run" : `${choice.rows.length} runs`;
1144
- return `Showing ${days} recorded under the retired ${choice.family} layout. New runs are recorded as ${DAILY_WORKFLOW}, so this list stops growing until that workflow runs.`;
706
+ function attentionRows(digest) {
707
+ return digest.attention.map((item) => ({
708
+ severity: item.severity,
709
+ tone: SEVERITY_TONE[item.severity],
710
+ kind: item.kind,
711
+ subject: item.subject,
712
+ message: item.message,
713
+ evidence: item.evidence,
714
+ recipes: item.recipes
715
+ }));
716
+ }
717
+ function recipeText(argv) {
718
+ return argv.map(quoteArg).join(" ");
719
+ }
720
+ function quoteArg(argument) {
721
+ if (argument !== "" && /^[A-Za-z0-9_./:=@%+,-]+$/.test(argument))
722
+ return argument;
723
+ return `'${argument.replace(/'/g, `'\\''`)}'`;
724
+ }
725
+ function historyRows(days) {
726
+ return days.map((day) => {
727
+ const status = dayStatusWord(day.status);
728
+ const durations = day.durations.filter((duration) => duration.durationMs !== null);
729
+ return {
730
+ day: day.day,
731
+ status: day.status,
732
+ word: status.word,
733
+ tone: status.tone,
734
+ runId: day.runId,
735
+ windows: day.windows.map((window) => ({
736
+ window: window.window,
737
+ launch: window.launchStatus,
738
+ tone: window.launchStatus === "done" ? "success" : window.launchStatus === "failed" ? "error" : window.launchStatus === "not-run" ? "neutral" : "warn"
739
+ })),
740
+ totalMs: durations.length === 0 ? null : durations.reduce((total, duration) => total + (duration.durationMs ?? 0), 0)
741
+ };
742
+ });
743
+ }
744
+ function durationTrend(days) {
745
+ const ordered = [...days].sort((left, right) => left.day.localeCompare(right.day));
746
+ const steps = new Set;
747
+ for (const day of ordered)
748
+ for (const duration of day.durations)
749
+ steps.add(duration.step);
750
+ return [...steps].sort().map((step) => {
751
+ const points = ordered.map((day) => {
752
+ const match = day.durations.find((duration) => duration.step === step);
753
+ return { day: day.day, ms: match?.durationMs ?? null };
754
+ });
755
+ const recorded = points.filter((point) => point.ms !== null);
756
+ return { step, points, latestMs: recorded.length === 0 ? null : recorded[recorded.length - 1]?.ms ?? null };
757
+ });
758
+ }
759
+ function formatDuration(ms) {
760
+ if (ms === null)
761
+ return "unknown";
762
+ if (ms < 1000)
763
+ return `${Math.round(ms)}ms`;
764
+ const seconds = Math.round(ms / 1000);
765
+ if (seconds < 60)
766
+ return `${seconds}s`;
767
+ const minutes = Math.floor(seconds / 60);
768
+ return `${minutes}m ${String(seconds % 60).padStart(2, "0")}s`;
769
+ }
770
+ function historyRange(anchor, days = HISTORY_DEFAULT_DAYS) {
771
+ const until = isDayKey(anchor) ? anchor : new Date().toISOString().slice(0, 10).replace(/-/g, "");
772
+ const date = new Date(Number(until.slice(0, 4)), Number(until.slice(4, 6)) - 1, Number(until.slice(6, 8)));
773
+ date.setDate(date.getDate() - (Math.max(1, days) - 1));
774
+ const from = `${date.getFullYear()}${String(date.getMonth() + 1).padStart(2, "0")}${String(date.getDate()).padStart(2, "0")}`;
775
+ return { from: from <= until ? from : until, until };
1145
776
  }
1146
777
 
1147
778
  // ../board/src/daily-voice/evidence.ts
1148
- function captureState(evidence) {
1149
- return evidence.capture ? "captured" : "uncaptured";
1150
- }
1151
- function asRecord2(value) {
779
+ function asRecord(value) {
1152
780
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
1153
781
  }
1154
- function asString2(value) {
782
+ function asString(value) {
1155
783
  return typeof value === "string" && value.length > 0 ? value : null;
1156
784
  }
1157
- function asNumber2(value) {
785
+ function asNumber(value) {
1158
786
  return typeof value === "number" && Number.isFinite(value) ? value : null;
1159
787
  }
1160
- function asBool2(value) {
788
+ function asBool(value) {
1161
789
  return typeof value === "boolean" ? value : null;
1162
790
  }
1163
791
  function newsSummaryOf(evidence) {
@@ -1166,17 +794,17 @@ function newsSummaryOf(evidence) {
1166
794
  return newsSummaryOfResults(evidence.results);
1167
795
  }
1168
796
  function newsSummaryOfResults(results) {
1169
- const summary = asRecord2(results.summary);
797
+ const summary = asRecord(results.summary);
1170
798
  if (!summary)
1171
799
  return null;
1172
800
  const generation = generationOf(summary);
1173
801
  const publishing = publishingOf(summary);
1174
802
  const counts = countsOf(summary);
1175
- const outcome = asString2(summary.outcome);
803
+ const outcome = asString(summary.outcome);
1176
804
  return {
1177
- status: asString2(summary.status) ?? "unknown",
1178
- startedAt: asString2(summary.startedAt),
1179
- completedAt: asString2(summary.completedAt),
805
+ status: asString(summary.status) ?? "unknown",
806
+ startedAt: asString(summary.startedAt),
807
+ completedAt: asString(summary.completedAt),
1180
808
  outcome,
1181
809
  generation,
1182
810
  publishing,
@@ -1184,104 +812,104 @@ function newsSummaryOfResults(results) {
1184
812
  };
1185
813
  }
1186
814
  function generationOf(summary) {
1187
- const bag = asRecord2(summary.generation) ?? {};
1188
- const gate = asRecord2(bag.gate) ?? {};
1189
- const launch = asRecord2(bag.launch) ?? {};
1190
- const progress = asRecord2(bag.progress) ?? null;
815
+ const bag = asRecord(summary.generation) ?? {};
816
+ const gate = asRecord(bag.gate) ?? {};
817
+ const launch = asRecord(bag.launch) ?? {};
818
+ const progress = asRecord(bag.progress) ?? null;
1191
819
  const engines = Array.isArray(bag.engines) ? bag.engines.flatMap((entry) => {
1192
- const row = asRecord2(entry);
820
+ const row = asRecord(entry);
1193
821
  if (!row)
1194
822
  return [];
1195
823
  const attempts = Array.isArray(row.attempts) ? row.attempts.flatMap((attempt) => {
1196
- const a = asRecord2(attempt);
824
+ const a = asRecord(attempt);
1197
825
  if (!a)
1198
826
  return [];
1199
827
  return [
1200
828
  {
1201
- status: asString2(a.status) ?? "unknown",
1202
- timing: asString2(a.timing) ?? "unknown"
829
+ status: asString(a.status) ?? "unknown",
830
+ timing: asString(a.timing) ?? "unknown"
1203
831
  }
1204
832
  ];
1205
833
  }) : [];
1206
834
  return [
1207
835
  {
1208
- node: asString2(row.node) ?? "unknown",
1209
- state: asString2(row.state) ?? "unknown",
836
+ node: asString(row.node) ?? "unknown",
837
+ state: asString(row.state) ?? "unknown",
1210
838
  attempts
1211
839
  }
1212
840
  ];
1213
841
  }) : [];
1214
842
  return {
1215
- outcome: asString2(bag.outcome),
1216
- gate: { status: asString2(gate.status) },
843
+ outcome: asString(bag.outcome),
844
+ gate: { status: asString(gate.status) },
1217
845
  launch: {
1218
- status: asString2(launch.status),
1219
- runId: asString2(launch.runId),
1220
- startedAt: asString2(launch.startedAt),
1221
- finishedAt: asString2(launch.finishedAt),
1222
- reason: asString2(launch.reason),
1223
- stale: asBool2(launch.stale) === true
846
+ status: asString(launch.status),
847
+ runId: asString(launch.runId),
848
+ startedAt: asString(launch.startedAt),
849
+ finishedAt: asString(launch.finishedAt),
850
+ reason: asString(launch.reason),
851
+ stale: asBool(launch.stale) === true
1224
852
  },
1225
853
  engines,
1226
854
  progress
1227
855
  };
1228
856
  }
1229
857
  function publishingOf(summary) {
1230
- const bag = asRecord2(summary.publishing) ?? {};
1231
- const bundleBag = asRecord2(bag.bundle) ?? null;
858
+ const bag = asRecord(summary.publishing) ?? {};
859
+ const bundleBag = asRecord(bag.bundle) ?? null;
1232
860
  const bundle = bundleBag ? {
1233
- identity: asString2(bundleBag.identity) ?? "unknown",
1234
- runDate: asString2(bundleBag.runDate) ?? "unknown",
1235
- parentRunId: asString2(bundleBag.parentRunId),
1236
- title: asString2(bundleBag.title),
861
+ identity: asString(bundleBag.identity) ?? "unknown",
862
+ runDate: asString(bundleBag.runDate) ?? "unknown",
863
+ parentRunId: asString(bundleBag.parentRunId),
864
+ title: asString(bundleBag.title),
1237
865
  variants: Array.isArray(bundleBag.variants) ? bundleBag.variants.flatMap((v) => {
1238
- const s = asString2(v);
866
+ const s = asString(v);
1239
867
  return s ? [s] : [];
1240
868
  }) : [],
1241
- safety: asString2(bundleBag.safety)
869
+ safety: asString(bundleBag.safety)
1242
870
  } : null;
1243
871
  const windows = Array.isArray(bag.windows) ? bag.windows.flatMap((entry) => {
1244
- const row = asRecord2(entry);
872
+ const row = asRecord(entry);
1245
873
  if (!row)
1246
874
  return [];
1247
- const windowId = asString2(row.window);
875
+ const windowId = asString(row.window);
1248
876
  if (!windowId)
1249
877
  return [];
1250
- const provenance = asRecord2(row.provenance) ?? {};
1251
- const recorded = asString2(row.recordedStatus);
878
+ const provenance = asRecord(row.provenance) ?? {};
879
+ const recorded = asString(row.recordedStatus);
1252
880
  return [
1253
881
  {
1254
882
  window: windowId,
1255
883
  recordedStatus: isWindowStatus(recorded) ? recorded : null,
1256
884
  provenance: {
1257
- dateMatch: asBool2(provenance.dateMatch),
1258
- bundleMatch: asBool2(provenance.bundleMatch),
1259
- parentMatch: asBool2(provenance.parentMatch),
1260
- digestMatch: asBool2(provenance.digestMatch)
885
+ dateMatch: asBool(provenance.dateMatch),
886
+ bundleMatch: asBool(provenance.bundleMatch),
887
+ parentMatch: asBool(provenance.parentMatch),
888
+ digestMatch: asBool(provenance.digestMatch)
1261
889
  },
1262
890
  targets: Array.isArray(row.targets) ? row.targets.flatMap((target) => {
1263
- const t = asRecord2(target);
891
+ const t = asRecord(target);
1264
892
  if (!t)
1265
893
  return [];
1266
- const id = asString2(t.id);
894
+ const id = asString(t.id);
1267
895
  if (!id)
1268
896
  return [];
1269
- const evidenceFiles = asRecord2(t.evidence) ?? {};
897
+ const evidenceFiles = asRecord(t.evidence) ?? {};
1270
898
  return [
1271
899
  {
1272
900
  id,
1273
- tier: asNumber2(t.tier),
1274
- mode: asString2(t.mode),
1275
- target: asString2(t.target),
1276
- status: isTargetStatus(asString2(t.status)) ? asString2(t.status) : "planned",
1277
- effect: asString2(t.effect),
1278
- url: asString2(t.url),
1279
- guid: asString2(t.guid),
1280
- finishedAt: asString2(t.finishedAt),
1281
- error: asString2(t.error),
901
+ tier: asNumber(t.tier),
902
+ mode: asString(t.mode),
903
+ target: asString(t.target),
904
+ status: isTargetStatus(asString(t.status)) ? asString(t.status) : "planned",
905
+ effect: asString(t.effect),
906
+ url: asString(t.url),
907
+ guid: asString(t.guid),
908
+ finishedAt: asString(t.finishedAt),
909
+ error: asString(t.error),
1282
910
  evidence: {
1283
- plan: asString2(evidenceFiles.plan) ?? "unknown",
1284
- receipt: asString2(evidenceFiles.receipt)
911
+ plan: asString(evidenceFiles.plan) ?? "unknown",
912
+ receipt: asString(evidenceFiles.receipt)
1285
913
  }
1286
914
  }
1287
915
  ];
@@ -1298,8 +926,8 @@ function isTargetStatus(value) {
1298
926
  return value === "succeeded" || value === "failed" || value === "uncertain" || value === "planned" || value === "dummy" || value === "skipped";
1299
927
  }
1300
928
  function countsOf(summary) {
1301
- const bag = asRecord2(summary.counts) ?? {};
1302
- const n = (key) => asNumber2(bag[key]);
929
+ const bag = asRecord(summary.counts) ?? {};
930
+ const n = (key) => asNumber(bag[key]);
1303
931
  return {
1304
932
  artifactsAvailable: n("artifactsAvailable"),
1305
933
  artifactsTotal: n("artifactsTotal"),
@@ -1321,43 +949,6 @@ var ENGINE_WORDS = {
1321
949
  function engineStateWord(state) {
1322
950
  return ENGINE_WORDS[state] ?? { word: state, tone: "neutral" };
1323
951
  }
1324
- var TARGET_WORDS = {
1325
- succeeded: { word: "sent", tone: "success" },
1326
- failed: { word: "failed", tone: "error" },
1327
- uncertain: { word: "uncertain", tone: "warn" },
1328
- planned: { word: "no evidence recorded", tone: "warn" },
1329
- dummy: { word: "rehearsal only", tone: "neutral" },
1330
- skipped: { word: "skipped", tone: "neutral" }
1331
- };
1332
- function targetStateWord(target) {
1333
- return TARGET_WORDS[target.status] ?? { word: target.status, tone: "neutral" };
1334
- }
1335
- var WINDOW_WORDS = {
1336
- full: { word: "all targets sent", tone: "success" },
1337
- partial: { word: "partially sent", tone: "warn" },
1338
- none: { word: "nothing sent", tone: "error" },
1339
- dummy: { word: "rehearsal only", tone: "neutral" }
1340
- };
1341
- function windowStateWord(status) {
1342
- return status ? WINDOW_WORDS[status] ?? null : null;
1343
- }
1344
- function windowLabel(window2) {
1345
- if (window2 === "after-generate")
1346
- return "After generate";
1347
- if (window2 === "cn-peak")
1348
- return "CN peak";
1349
- if (window2 === "overseas-rss")
1350
- return "Overseas RSS";
1351
- return window2;
1352
- }
1353
- function provenanceRows(window2) {
1354
- return [
1355
- { label: "run date matches the bundle", matched: window2.provenance.dateMatch },
1356
- { label: "plan references this bundle", matched: window2.provenance.bundleMatch },
1357
- { label: "plan references this parent run", matched: window2.provenance.parentMatch },
1358
- { label: "receipt digests match the plan", matched: window2.provenance.digestMatch }
1359
- ];
1360
- }
1361
952
  function generationStageRows(summary) {
1362
953
  const recorded = new Set;
1363
954
  const engineRows = summary.generation.engines.map((engine) => {
@@ -1374,16 +965,16 @@ function generationStageRows(summary) {
1374
965
  engine
1375
966
  };
1376
967
  });
1377
- const progress = asRecord2(summary.generation.progress);
968
+ const progress = asRecord(summary.generation.progress);
1378
969
  const nodes = progress && Array.isArray(progress.nodes) ? progress.nodes : [];
1379
970
  const progressRows = nodes.flatMap((entry) => {
1380
- const row = asRecord2(entry);
971
+ const row = asRecord(entry);
1381
972
  if (!row)
1382
973
  return [];
1383
- const id = asString2(row.id);
974
+ const id = asString(row.id);
1384
975
  if (!id || recorded.has(id))
1385
976
  return [];
1386
- const status = asString2(row.status) ?? "unknown";
977
+ const status = asString(row.status) ?? "unknown";
1387
978
  const { word, tone } = engineStateWord(status);
1388
979
  return [
1389
980
  {
@@ -1392,7 +983,7 @@ function generationStageRows(summary) {
1392
983
  status,
1393
984
  word,
1394
985
  tone,
1395
- timing: asString2(row.timing),
986
+ timing: asString(row.timing),
1396
987
  engine: null
1397
988
  }
1398
989
  ];
@@ -1414,54 +1005,6 @@ function engineNodeLabel(node) {
1414
1005
  };
1415
1006
  return labels[node] ?? node;
1416
1007
  }
1417
- function publishingWindowRows(summary) {
1418
- return summary.publishing.windows.map((window2) => ({
1419
- window: window2.window,
1420
- label: windowLabel(window2.window),
1421
- recorded: windowStateWord(window2.recordedStatus),
1422
- provenance: provenanceRows(window2),
1423
- targets: window2.targets.map((target) => {
1424
- const { word, tone } = targetStateWord(target);
1425
- return { ...target, word, tone };
1426
- })
1427
- }));
1428
- }
1429
- var STAGE_ORDER = [
1430
- "prepare",
1431
- "curate",
1432
- "script-write",
1433
- "editorial-judge",
1434
- "render",
1435
- "safety",
1436
- "voice",
1437
- "freeze"
1438
- ];
1439
- function outputGroups(results, readerOrigin) {
1440
- const views = artifactViews(results, readerOrigin);
1441
- const producersOf = new Map(views.map((view) => [view.id, view]));
1442
- const byProducer = new Map;
1443
- for (const descriptor of results.artifacts) {
1444
- const view = producersOf.get(descriptor.id);
1445
- if (!view)
1446
- continue;
1447
- const producer = descriptor.producerNode ?? "";
1448
- const bucket = byProducer.get(producer);
1449
- if (bucket)
1450
- bucket.push(view);
1451
- else
1452
- byProducer.set(producer, [view]);
1453
- }
1454
- const producers = [...byProducer.keys()].sort((a, b) => {
1455
- const ia = STAGE_ORDER.indexOf(a);
1456
- const ib = STAGE_ORDER.indexOf(b);
1457
- return (ia === -1 ? STAGE_ORDER.length : ia) - (ib === -1 ? STAGE_ORDER.length : ib);
1458
- });
1459
- return producers.map((producer) => ({
1460
- producer,
1461
- label: producer ? engineNodeLabel(producer) : "Unattributed",
1462
- artifacts: byProducer.get(producer) ?? []
1463
- }));
1464
- }
1465
1008
  function stamp(value) {
1466
1009
  if (!value)
1467
1010
  return "not recorded";
@@ -1517,45 +1060,146 @@ function newsSummaryFacts(evidence) {
1517
1060
  });
1518
1061
  return facts;
1519
1062
  }
1520
- function latestIssue(summary, diagnostics) {
1521
- if (summary) {
1522
- for (const window2 of summary.publishing.windows) {
1523
- for (const target of window2.targets) {
1524
- if (target.status === "failed" || target.status === "uncertain") {
1525
- const why = target.error ?? "no error detail recorded";
1526
- return {
1527
- title: `${windowLabel(window2.window)}: ${target.id} ${target.status}`,
1528
- detail: why
1529
- };
1530
- }
1531
- }
1532
- }
1533
- if (summary.generation.launch.stale) {
1534
- return {
1535
- title: "Launch receipt points at another run",
1536
- detail: `receipt run ${summary.generation.launch.runId ?? "unknown"} is not this attempt`
1537
- };
1538
- }
1063
+
1064
+ // ../board/src/daily-voice/detail-view.ts
1065
+ var NODE_DIAGNOSTIC_CAP = 20;
1066
+ function durationIndex(digest) {
1067
+ const index = new Map;
1068
+ for (const duration of digest.generation.durations)
1069
+ index.set(duration.step, duration.durationMs);
1070
+ return index;
1071
+ }
1072
+ function stepIdOf(nodeId) {
1073
+ return nodeId.startsWith("voice") ? "voice" : nodeId;
1074
+ }
1075
+ function engineChainOf(generation) {
1076
+ return (generation?.engines ?? []).map((engine) => ({
1077
+ node: engine.node,
1078
+ label: engine.node.startsWith("voice-fallback") ? `${engine.node} (retry)` : engine.node,
1079
+ state: engine.state,
1080
+ attempts: engine.attempts.length,
1081
+ lastTiming: engine.attempts.at(-1)?.timing ?? null
1082
+ }));
1083
+ }
1084
+ function generationDetail(evidence, digest) {
1085
+ const summary = newsSummaryOf(evidence);
1086
+ const generation = summary?.generation;
1087
+ const durations = durationIndex(digest);
1088
+ const stageRows = summary === null ? [] : generationStageRows(summary);
1089
+ const timeline = stageRows.map((row) => ({
1090
+ id: row.id,
1091
+ label: row.label,
1092
+ status: row.status,
1093
+ word: row.word,
1094
+ tone: row.tone,
1095
+ timing: row.timing,
1096
+ durationMs: durations.get(stepIdOf(row.id)) ?? null,
1097
+ engine: row.engine !== null
1098
+ }));
1099
+ for (const duration of digest.generation.durations) {
1100
+ if (timeline.some((node) => stepIdOf(node.id) === duration.step))
1101
+ continue;
1102
+ timeline.push({
1103
+ id: duration.step,
1104
+ label: duration.step,
1105
+ status: "unknown",
1106
+ word: "state unrecorded",
1107
+ tone: "neutral",
1108
+ timing: null,
1109
+ durationMs: duration.durationMs,
1110
+ engine: false
1111
+ });
1539
1112
  }
1540
- const first = diagnostics.find((d) => typeof d.message === "string" && d.message.length > 0);
1541
- return first ? { title: first.code, detail: first.message } : null;
1113
+ const diagnostics = [...evidence.diagnostics, ...summary === null ? [] : []].slice(0, NODE_DIAGNOSTIC_CAP);
1114
+ return {
1115
+ runId: evidence.runId,
1116
+ captureState: evidence.capture === null ? "uncaptured" : "captured",
1117
+ availability: evidence.results?.availability ?? "unverified",
1118
+ facts: newsSummaryFacts(evidence),
1119
+ timeline,
1120
+ engines: engineChainOf(generation),
1121
+ unknownReason: generation === undefined ? evidence.capture === null ? "no-capture-record" : "no-recorded-projection" : null,
1122
+ diagnostics: diagnostics.map((diagnostic) => ({ code: diagnostic.code, message: diagnostic.message })),
1123
+ artifacts: evidence.results?.artifacts.map((artifact) => ({
1124
+ id: artifact.id,
1125
+ label: artifact.label,
1126
+ availability: artifact.availability,
1127
+ reason: artifact.availability === "available" ? null : artifact.availability
1128
+ })) ?? []
1129
+ };
1542
1130
  }
1543
- function uncapturedDiagnostic(evidence) {
1544
- if (captureState(evidence) !== "uncaptured")
1545
- return null;
1546
- const found = evidence.diagnostics.find((d) => d.code === "board.evidence.uncaptured");
1547
- return found ?? null;
1131
+ function isPublicHttpUrl(value) {
1132
+ if (value === null)
1133
+ return false;
1134
+ try {
1135
+ const url = new URL(value);
1136
+ if (url.protocol !== "http:" && url.protocol !== "https:")
1137
+ return false;
1138
+ const host = url.hostname;
1139
+ if (host === "localhost" || host === "" || host.endsWith(".local"))
1140
+ return false;
1141
+ if (/^(127\.|10\.|192\.168\.|::1$|\[::1\])/.test(host))
1142
+ return false;
1143
+ return true;
1144
+ } catch {
1145
+ return false;
1146
+ }
1147
+ }
1148
+ var PROVENANCE_LABELS = {
1149
+ dateMatch: "date",
1150
+ bundleMatch: "bundle",
1151
+ parentMatch: "parent run",
1152
+ digestMatch: "plan digest"
1153
+ };
1154
+ function provenanceRows(window) {
1155
+ return Object.keys(PROVENANCE_LABELS).map((key) => ({
1156
+ label: PROVENANCE_LABELS[key],
1157
+ matched: window.provenance[key]
1158
+ }));
1159
+ }
1160
+ function provenanceWord(matched) {
1161
+ return matched === null ? "not checked" : matched ? "yes" : "no";
1162
+ }
1163
+ function publishingDetail(digest) {
1164
+ const strip = windowRows(digest);
1165
+ return digest.windows.map((window) => {
1166
+ const projected = strip.find((row) => row.window === window.window);
1167
+ const rows = window.targets.map((target) => ({
1168
+ id: target.id,
1169
+ target: target.target ?? target.id.split(".")[0] ?? target.id,
1170
+ tier: target.tier === null ? "unknown" : String(target.tier),
1171
+ mode: target.mode ?? "unknown",
1172
+ status: target.status,
1173
+ tone: target.status === "succeeded" ? "success" : target.status === "failed" ? "error" : target.status === "planned" ? "neutral" : "warn",
1174
+ effect: target.effect ?? "unknown",
1175
+ url: isPublicHttpUrl(target.url) ? target.url : null,
1176
+ error: target.error ?? "",
1177
+ evidence: target.evidence.receipt ?? target.evidence.plan
1178
+ }));
1179
+ return {
1180
+ window: window.window,
1181
+ label: projected?.label ?? window.window,
1182
+ launch: window.launchStatus,
1183
+ tone: projected?.tone ?? "neutral",
1184
+ unknownReason: window.unknownReason,
1185
+ recorded: window.recordedStatus ?? "unknown",
1186
+ runId: window.runId,
1187
+ provenance: provenanceRows({
1188
+ window: window.window,
1189
+ recordedStatus: window.recordedStatus,
1190
+ provenance: window.provenance,
1191
+ targets: []
1192
+ }),
1193
+ rows,
1194
+ notRun: window.launchStatus === "not-run" && window.targets.length === 0
1195
+ };
1196
+ });
1548
1197
  }
1549
1198
 
1550
1199
  // ../board/src/daily-voice/index.tsx
1551
- import { jsx as jsx2, jsxs as jsxs2, Fragment } from "react/jsx-runtime";
1200
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
1552
1201
  var MODULE_PATH = "/board/modules/kk-daily-ai-voice2";
1553
- var VIEW_TABS_ID = "daily-voice-view";
1554
- var VIEW_LABELS = {
1555
- summary: "Summary",
1556
- generation: "Generation",
1557
- publishing: "Publishing"
1558
- };
1202
+ var CONSOLE_TABS_ID = "daily-voice-console";
1559
1203
  var TONE_BADGE = {
1560
1204
  info: "info",
1561
1205
  success: "success",
@@ -1563,1575 +1207,1090 @@ var TONE_BADGE = {
1563
1207
  error: "error",
1564
1208
  neutral: "neutral"
1565
1209
  };
1566
- function statusBadgeVariant(status) {
1567
- if (status === "done" || status === "success" || status === "passed")
1568
- return "success";
1569
- if (status === "failed" || status === "failure")
1570
- return "error";
1571
- return "info";
1572
- }
1210
+ var INITIAL = { loading: true, digest: null, days: [], error: null, searchedPath: null };
1573
1211
  function isOfflineError(message) {
1574
1212
  return message.includes("Failed to fetch") || message.includes("NetworkError") || message.includes("ECONNREFUSED");
1575
1213
  }
1576
- function messageOf(error) {
1577
- return error instanceof Error ? error.message : String(error);
1578
- }
1579
- function usePolling(loader, intervalMs, refresh) {
1580
- const loaderRef = useRef(loader);
1581
- loaderRef.current = loader;
1582
- const refreshRef = useRef(refresh);
1583
- refreshRef.current = refresh;
1584
- useEffect(() => {
1585
- let cancelled = false;
1586
- let timer;
1587
- const loop = async () => {
1588
- if (!document.hidden)
1589
- await loaderRef.current();
1590
- if (!cancelled)
1591
- timer = setTimeout(() => void loop(), delayMs(refreshRef.current, intervalMs));
1592
- };
1593
- loop();
1594
- return () => {
1595
- cancelled = true;
1596
- clearTimeout(timer);
1597
- };
1598
- }, [intervalMs]);
1214
+ function readerFor(search) {
1215
+ const resolved = readerOriginFrom(search, DEFAULT_READER_ORIGIN);
1216
+ return { origin: resolved.origin, diagnostic: resolved.diagnostic };
1599
1217
  }
1600
- function DailyVoiceModule() {
1601
- const [link] = useState(() => parseDeepLink(window.location.search, DAILY_VIEWS, DAILY_VIEW_ALIASES));
1602
- const [reader] = useState(() => readerOriginFrom(window.location.search));
1603
- const [aggregateReader] = useState(() => readerOriginFrom(window.location.search, DEFAULT_READER_ORIGIN));
1604
- const readerOrigin = reader.origin;
1605
- const client = useMemo(() => createBoardClient({
1606
- readerOrigin,
1607
- aggregateReaderOrigin: aggregateReader.origin,
1608
- boardOrigin: window.location.origin
1609
- }), [readerOrigin, aggregateReader.origin]);
1610
- const [rows, setRows] = useState([]);
1611
- const [cursor, setCursor] = useState(null);
1612
- const [selection, setSelection] = useState({
1613
- runId: link.runId ?? null,
1614
- tab: link.tab ?? "summary"
1218
+ function StatusBanner({
1219
+ digest,
1220
+ fetchedAt,
1221
+ onRefresh
1222
+ }) {
1223
+ const facts = generationFacts(digest);
1224
+ const status = facts[0];
1225
+ return /* @__PURE__ */ jsxs("div", {
1226
+ className: "kk-board-module-banner",
1227
+ "data-testid": "day-status",
1228
+ children: [
1229
+ /* @__PURE__ */ jsx(Badge, {
1230
+ variant: TONE_BADGE[status?.tone ?? "neutral"],
1231
+ size: "md",
1232
+ children: status?.value ?? "unknown"
1233
+ }),
1234
+ /* @__PURE__ */ jsxs("span", {
1235
+ className: "kk-board-state",
1236
+ children: [
1237
+ digest.day,
1238
+ " · ",
1239
+ digest.attention.length,
1240
+ " attention item(s) · read",
1241
+ " ",
1242
+ formatTimestamp(fetchedAtIso(fetchedAt))
1243
+ ]
1244
+ }),
1245
+ /* @__PURE__ */ jsx(Button, {
1246
+ variant: "ghost",
1247
+ size: "xs",
1248
+ onClick: onRefresh,
1249
+ children: "Refresh"
1250
+ })
1251
+ ]
1615
1252
  });
1616
- const [diagnostics, setDiagnostics] = useState(() => [
1617
- ...link.diagnostics,
1618
- ...reader.diagnostic === null ? [] : [reader.diagnostic],
1619
- ...aggregateReader.diagnostic === null ? [] : [aggregateReader.diagnostic]
1620
- ]);
1621
- const [historyRefresh, setHistoryRefresh] = useState(() => initialRefresh(HISTORY_POLL_MS));
1622
- const [readerRefresh, setReaderRefresh] = useState(() => initialRefresh(ACTIVE_POLL_MS));
1623
- const [evidence, setEvidence] = useState(null);
1624
- const [results, setResults] = useState(null);
1625
- const [config, setConfig] = useState(null);
1626
- const [filterQuery, setFilterQuery] = useState("");
1627
- const [supply, setSupply] = useState(null);
1628
- const [storeOffline, setStoreOffline] = useState(false);
1629
- const supplyRequests = useRef(requestSequence());
1630
- const supplyKeyRef = useRef(null);
1631
- const historyBusy = useRef(false);
1632
- const readerBusy = useRef(false);
1633
- const selectionRef = useRef(selection);
1634
- selectionRef.current = selection;
1635
- const [family, setFamily] = useState(DAILY_WORKFLOW);
1636
- const familyRef = useRef(DAILY_WORKFLOW);
1637
- const loadHistory = useCallback(async () => {
1638
- if (historyBusy.current)
1639
- return;
1640
- historyBusy.current = true;
1641
- setHistoryRefresh((state) => tick(state));
1642
- try {
1643
- const current = await client.runs(DAILY_WORKFLOW);
1644
- let chosen = { family: DAILY_WORKFLOW, page: current };
1645
- if (current.runs.length === 0) {
1646
- const retiredPages = await Promise.all(RETIRED_DAILY_WORKFLOWS.map(async (retired) => ({
1647
- family: retired,
1648
- page: await client.runs(retired)
1649
- })));
1650
- const choice = pickDailyFamily(current.runs, retiredPages.map((entry) => ({ family: entry.family, rows: entry.page.runs })));
1651
- const hit = retiredPages.find((entry) => entry.family === choice.family);
1652
- if (choice.retired && hit !== undefined)
1653
- chosen = { family: hit.family, page: hit.page };
1654
- }
1655
- familyRef.current = chosen.family;
1656
- setFamily(chosen.family);
1657
- setRows((existing) => mergeRunPages(existing, chosen.page).runs);
1658
- setCursor(chosen.page.nextCursor);
1659
- setHistoryRefresh(() => succeeded(Date.now(), HISTORY_POLL_MS));
1660
- } catch (error) {
1661
- setDiagnostics((existing) => [
1662
- ...existing,
1663
- { code: "board.history.unavailable", message: messageOf(error) }
1664
- ]);
1665
- setHistoryRefresh((state) => failed(state, Date.now()));
1666
- } finally {
1667
- historyBusy.current = false;
1668
- }
1669
- }, [client]);
1670
- const loadReader = useCallback(async () => {
1671
- if (readerBusy.current)
1672
- return;
1673
- const runId = selectionRef.current.runId;
1674
- if (runId === null)
1675
- return;
1676
- readerBusy.current = true;
1677
- setReaderRefresh((state) => tick(state));
1678
- let stale = false;
1679
- try {
1680
- if (familyRef.current === DAILY_WORKFLOW) {
1681
- const envelope = await client.evidence(familyRef.current, runId);
1682
- if (selectionRef.current.runId !== runId) {
1683
- stale = true;
1684
- return;
1685
- }
1686
- setEvidence(envelope);
1687
- setResults(null);
1688
- setConfig(null);
1689
- } else {
1690
- const [nextResults, nextConfig] = await Promise.all([
1691
- client.results(familyRef.current, runId),
1692
- client.config(familyRef.current, runId)
1693
- ]);
1694
- if (selectionRef.current.runId !== runId) {
1695
- stale = true;
1696
- return;
1697
- }
1698
- setResults(nextResults);
1699
- setConfig(nextConfig);
1700
- setEvidence(null);
1701
- }
1702
- setReaderRefresh(() => succeeded(Date.now(), ACTIVE_POLL_MS));
1703
- } catch (error) {
1704
- if (selectionRef.current.runId !== runId) {
1705
- stale = true;
1706
- return;
1707
- }
1708
- setDiagnostics((existing) => [
1709
- ...existing,
1710
- { code: "board.reader.unavailable", message: messageOf(error) }
1711
- ]);
1712
- setReaderRefresh((state) => failed(state, Date.now()));
1713
- } finally {
1714
- readerBusy.current = false;
1715
- if (stale)
1716
- loadReader();
1717
- }
1718
- }, [client]);
1719
- usePolling(loadHistory, HISTORY_POLL_MS, historyRefresh);
1720
- usePolling(loadReader, ACTIVE_POLL_MS, readerRefresh);
1721
- useEffect(() => {
1722
- if (selection.runId === null && rows.length > 0) {
1723
- setSelection((state) => state.runId === null ? resolveSelection(rows, link, "summary") : state);
1724
- }
1725
- }, [rows, selection.runId, link]);
1726
- useEffect(() => {
1727
- syncSelectionUrl(selection, { location: window.location, history: window.history }, MODULE_PATH);
1728
- }, [selection]);
1729
- const view = selection.tab;
1730
- const newsFamily = family === DAILY_WORKFLOW;
1731
- const now = Date.now();
1732
- const legacySummary = results === null ? null : dailySummary(results);
1733
- const news = evidence !== null && newsFamily ? newsSummaryOf(evidence) : null;
1734
- const newsFacts = evidence !== null && newsFamily ? newsSummaryFacts(evidence) : [];
1735
- const issue = evidence !== null && newsFamily ? latestIssue(news, evidence.diagnostics) : null;
1736
- const funnel = funnelView(results?.summary.funnel);
1737
- const legacyArtifacts = results === null ? [] : artifactViews(results, readerOrigin);
1738
- const outputRows = evidence !== null && newsFamily && evidence.results !== null ? outputGroups(evidence.results, readerOrigin) : [];
1739
- const stageRows = news === null ? [] : generationStageRows(news);
1740
- const context = supplyContextOf(newsFamily ? evidence?.capture?.settings.window ?? null : config?.settings.window ?? null, news?.startedAt ?? legacySummary?.startedAt ?? null);
1741
- useEffect(() => {
1742
- const bounds = view === "summary" && context !== null ? context : null;
1743
- const key = bounds === null ? null : `${selection.runId}:${bounds.fromMs}:${bounds.untilMs}`;
1744
- if (key === supplyKeyRef.current)
1745
- return;
1746
- supplyKeyRef.current = key;
1747
- if (bounds === null) {
1748
- setSupply(null);
1749
- return;
1750
- }
1751
- const token = supplyRequests.current.begin();
1752
- let cancelled = false;
1753
- (async () => {
1754
- try {
1755
- const page = await client.storeChannels({ fromMs: bounds.fromMs, untilMs: bounds.untilMs, page: 1 });
1756
- if (cancelled || !supplyRequests.current.isCurrent(token))
1757
- return;
1758
- setSupply(page);
1759
- setStoreOffline(false);
1760
- } catch (error) {
1761
- if (cancelled || !supplyRequests.current.isCurrent(token))
1762
- return;
1763
- setSupply(null);
1764
- const message = messageOf(error);
1765
- if (isOfflineError(message))
1766
- setStoreOffline(true);
1767
- else
1768
- setDiagnostics((existing) => [...existing, { code: "board.store.channels-unavailable", message }]);
1769
- }
1770
- })();
1771
- return () => {
1772
- cancelled = true;
1773
- };
1774
- }, [client, view, context, selection.runId]);
1775
- const selectedRow = rows.find((row) => row.id === selection.runId);
1776
- const filteredRows = useMemo(() => {
1777
- const q = filterQuery.trim().toLowerCase();
1778
- if (q === "")
1779
- return rows;
1780
- return rows.filter((r) => r.id.toLowerCase().includes(q) || r.status.toLowerCase().includes(q));
1781
- }, [rows, filterQuery]);
1782
- const displayDiagnostics = dedupeDiagnostics([
1783
- ...diagnostics,
1784
- ...evidence?.diagnostics ?? results?.diagnostics ?? []
1785
- ]);
1786
- const freshness = freshnessLabel(readerRefresh);
1787
- const availability = evidence?.results?.availability ?? results?.availability ?? "unverified";
1788
- const outcomeWord = newsFamily ? news?.outcome ?? null : legacySummary?.outcome ?? null;
1789
- const filterBox = /* @__PURE__ */ jsxs2("div", {
1790
- className: "kk-board-run-filter-group",
1253
+ }
1254
+ function fetchedAtIso(fetchedAt) {
1255
+ return fetchedAt === null ? null : new Date(fetchedAt).toISOString();
1256
+ }
1257
+ function RecipeLine({ argv, label, dryRun }) {
1258
+ const [copied, setCopied] = useState(false);
1259
+ const text = recipeText(argv);
1260
+ return /* @__PURE__ */ jsxs("div", {
1261
+ className: "kk-board-recipe",
1791
1262
  children: [
1792
- /* @__PURE__ */ jsx2("input", {
1793
- type: "text",
1794
- className: "kk-board-run-filter-input",
1795
- placeholder: "Filter runs...",
1796
- value: filterQuery,
1797
- onChange: (e) => setFilterQuery(e.target.value),
1798
- "aria-label": "Filter runs"
1263
+ /* @__PURE__ */ jsx(Button, {
1264
+ variant: "ghost",
1265
+ size: "xs",
1266
+ onClick: () => {
1267
+ navigator.clipboard?.writeText(text).then(() => {
1268
+ setCopied(true);
1269
+ globalThis.setTimeout(() => setCopied(false), 1500);
1270
+ });
1271
+ },
1272
+ children: copied ? "copied" : "copy"
1799
1273
  }),
1800
- /* @__PURE__ */ jsxs2("label", {
1801
- className: "kk-board-run-selector",
1274
+ /* @__PURE__ */ jsx("code", {
1275
+ "data-testid": "recipe-argv",
1276
+ children: text
1277
+ }),
1278
+ dryRun === undefined ? null : /* @__PURE__ */ jsxs("span", {
1279
+ className: "kk-board-state",
1802
1280
  children: [
1803
- "Run",
1804
- /* @__PURE__ */ jsxs2("select", {
1805
- value: selection.runId ?? "",
1806
- onChange: (event) => setSelection((state) => ({ ...state, runId: event.target.value || null })),
1807
- children: [
1808
- /* @__PURE__ */ jsx2("option", {
1809
- value: "",
1810
- children: rows.length === 0 ? "No runs recorded" : filteredRows.length === 0 ? "No matching runs" : "Select a run"
1811
- }),
1812
- filteredRows.map((row) => /* @__PURE__ */ jsxs2("option", {
1813
- value: row.id,
1814
- children: [
1815
- row.id,
1816
- " — ",
1817
- row.status
1818
- ]
1819
- }, row.id))
1820
- ]
1821
- })
1281
+ "dry run: ",
1282
+ recipeText(dryRun)
1822
1283
  ]
1823
1284
  }),
1824
- /* @__PURE__ */ jsx2("button", {
1825
- type: "button",
1826
- onClick: () => void loadReader(),
1827
- title: "Refresh run data",
1828
- children: "↻ Refresh"
1829
- }),
1830
- selection.runId === null ? null : /* @__PURE__ */ jsx2("a", {
1831
- href: selectionPath(selection, window.location.search, MODULE_PATH),
1832
- className: "kk-btn-action",
1833
- title: "Permanent link",
1834
- children: "\uD83D\uDD17 Link"
1285
+ /* @__PURE__ */ jsxs("span", {
1286
+ className: "kk-board-state",
1287
+ children: [
1288
+ "(",
1289
+ label,
1290
+ ")"
1291
+ ]
1835
1292
  })
1836
1293
  ]
1837
1294
  });
1838
- return /* @__PURE__ */ jsxs2(ModuleShell, {
1839
- className: "kk-board kk-board-daily-voice",
1840
- children: [
1841
- /* @__PURE__ */ jsx2(ModuleHeader, {
1842
- icon: /* @__PURE__ */ jsx2("span", {
1843
- "aria-hidden": "true",
1844
- children: "\uD83C\uDF99️"
1295
+ }
1296
+ function AttentionList({ rows }) {
1297
+ if (rows.length === 0) {
1298
+ return /* @__PURE__ */ jsx(EmptyState, {
1299
+ testId: "attention-all-clear",
1300
+ children: "All clear — nothing on this day needs the operator."
1301
+ });
1302
+ }
1303
+ return /* @__PURE__ */ jsx("ul", {
1304
+ className: "kk-board-attention",
1305
+ "data-testid": "attention-list",
1306
+ children: rows.map((row) => /* @__PURE__ */ jsxs("li", {
1307
+ className: `kk-board-attention-${row.severity}`,
1308
+ children: [
1309
+ /* @__PURE__ */ jsx(Badge, {
1310
+ variant: TONE_BADGE[row.tone],
1311
+ size: "sm",
1312
+ children: row.severity
1313
+ }),
1314
+ /* @__PURE__ */ jsx("strong", {
1315
+ children: row.kind
1845
1316
  }),
1846
- title: "Daily AI Voice",
1847
- subtitle: /* @__PURE__ */ jsxs2(Fragment, {
1317
+ " ",
1318
+ /* @__PURE__ */ jsxs("span", {
1319
+ className: "kk-board-state",
1848
1320
  children: [
1849
- "Run ",
1850
- /* @__PURE__ */ jsx2("code", {
1851
- children: selection.runId ?? "none selected"
1852
- }),
1853
- " · ",
1854
- freshness,
1855
- " ·",
1856
- " ",
1857
- outcomeWord === null ? "outcome unknown" : `Outcome ${outcomeWord}`,
1858
- " · ",
1859
- availability
1321
+ "(",
1322
+ row.subject,
1323
+ ")"
1860
1324
  ]
1861
1325
  }),
1862
- status: selectedRow ? /* @__PURE__ */ jsx2(Badge, {
1863
- variant: statusBadgeVariant(selectedRow.status),
1864
- size: "sm",
1865
- children: selectedRow.status
1866
- }) : undefined,
1867
- filters: filterBox,
1868
- tabs: /* @__PURE__ */ jsx2(ModuleTabs, {
1869
- tabs: DAILY_VIEWS.map((id) => ({ id, label: VIEW_LABELS[id] })),
1870
- value: view,
1871
- onChange: (id) => setSelection((state) => ({ ...state, tab: id })),
1872
- label: "Daily AI Voice views",
1873
- idPrefix: VIEW_TABS_ID
1874
- })
1875
- }),
1876
- newsFamily ? null : /* @__PURE__ */ jsx2("p", {
1877
- className: "kk-board-empty kk-board-retired-layout",
1878
- children: retiredLayoutNotice({ family, rows, retired: true })
1879
- }),
1880
- rows.length === 0 ? /* @__PURE__ */ jsxs2(EmptyState, {
1881
- testId: "daily-voice-no-runs",
1882
- children: [
1883
- "No runs recorded for ",
1884
- DAILY_WORKFLOW,
1885
- ". Configure the workflow in",
1886
- " ",
1887
- /* @__PURE__ */ jsx2("a", {
1888
- href: withBase("/board/settings/workflows"),
1889
- children: "Settings → Workflows"
1890
- }),
1891
- "."
1892
- ]
1893
- }) : null,
1894
- DAILY_VIEWS.map((panelView) => {
1895
- const active = panelView === view;
1896
- const panel = panelView === "summary" ? newsFamily ? /* @__PURE__ */ jsx2(NewsSummaryPanel, {
1897
- evidence,
1898
- news,
1899
- facts: newsFacts,
1900
- issue,
1901
- context,
1902
- supply,
1903
- storeOffline
1904
- }) : /* @__PURE__ */ jsx2(LegacySummaryPanel, {
1905
- facts: results === null ? [] : dailySummaryFacts(results, now),
1906
- results,
1907
- config,
1908
- funnel,
1909
- artifacts: legacyArtifacts,
1910
- context,
1911
- supply,
1912
- storeOffline
1913
- }) : panelView === "generation" ? newsFamily ? /* @__PURE__ */ jsx2(NewsGenerationPanel, {
1914
- evidence,
1915
- news,
1916
- stages: stageRows,
1917
- groups: outputRows
1918
- }) : /* @__PURE__ */ jsxs2(Fragment, {
1326
+ /* @__PURE__ */ jsx("p", {
1327
+ children: row.message
1328
+ }),
1329
+ row.evidence === null ? null : /* @__PURE__ */ jsxs("p", {
1330
+ className: "kk-board-state",
1919
1331
  children: [
1920
- /* @__PURE__ */ jsx2(LegacyResultsPanel, {
1921
- artifacts: legacyArtifacts,
1922
- channels: legacySummary?.channels ?? []
1923
- }),
1924
- /* @__PURE__ */ jsx2(LegacyProgressPanel, {
1925
- progress: legacySummary?.progress ?? null
1332
+ "evidence: ",
1333
+ /* @__PURE__ */ jsx("code", {
1334
+ children: row.evidence
1926
1335
  })
1927
1336
  ]
1928
- }) : newsFamily ? /* @__PURE__ */ jsx2(NewsPublishingPanel, {
1929
- news
1930
- }) : /* @__PURE__ */ jsx2(LegacyChannelList, {
1931
- channels: legacySummary?.channels ?? []
1932
- });
1933
- return /* @__PURE__ */ jsx2("div", {
1934
- id: `${VIEW_TABS_ID}-panel-${panelView}`,
1935
- role: "tabpanel",
1936
- "aria-labelledby": `${VIEW_TABS_ID}-${panelView}`,
1937
- hidden: !active,
1938
- style: active ? { display: "flex", flexDirection: "column", gap: "0.875rem" } : undefined,
1939
- children: panel
1940
- }, panelView);
1941
- }),
1942
- displayDiagnostics.map((diagnostic) => /* @__PURE__ */ jsx2(Diagnostic, {
1943
- tone: "error",
1944
- title: diagnostic.code,
1945
- detail: diagnostic.message,
1946
- testId: "daily-voice-diagnostic"
1947
- }, diagnostic.code)),
1948
- cursor === null ? null : /* @__PURE__ */ jsx2("button", {
1949
- type: "button",
1950
- onClick: () => void loadHistory(),
1951
- children: "Load more runs"
1952
- }),
1953
- /* @__PURE__ */ jsxs2("p", {
1954
- className: "kk-board-footnote",
1955
- children: [
1956
- "Run history every ",
1957
- HISTORY_POLL_MS / 1000,
1958
- "s; selected run every ",
1959
- ACTIVE_POLL_MS / 1000,
1960
- "s."
1961
- ]
1962
- })
1963
- ]
1337
+ }),
1338
+ row.recipes.length === 0 ? /* @__PURE__ */ jsx("p", {
1339
+ className: "kk-board-state",
1340
+ children: "no recipe — the evidence above names what is missing"
1341
+ }) : /* @__PURE__ */ jsx("ul", {
1342
+ children: row.recipes.map((recipe) => /* @__PURE__ */ jsx("li", {
1343
+ children: /* @__PURE__ */ jsx(RecipeLine, {
1344
+ argv: recipe.argv,
1345
+ label: recipe.label,
1346
+ dryRun: recipe.dryRunArgv
1347
+ })
1348
+ }, `${recipe.kind}:${recipe.argv.join(" ")}`))
1349
+ })
1350
+ ]
1351
+ }, `${row.kind}:${row.subject}`))
1964
1352
  });
1965
1353
  }
1966
- function NewsSummaryPanel({
1967
- evidence,
1968
- news,
1969
- facts,
1970
- issue,
1971
- context,
1972
- supply,
1973
- storeOffline
1354
+ function TodayPanel({
1355
+ digest,
1356
+ onRefresh,
1357
+ fetchedAt
1974
1358
  }) {
1975
- if (evidence === null)
1976
- return /* @__PURE__ */ jsx2(EmptyState, {
1977
- children: "No evidence for the selected run yet."
1978
- });
1979
- const capture = evidence.capture;
1980
- const settings = capture === null ? [] : Object.entries(capture.settings);
1981
- return /* @__PURE__ */ jsxs2(Fragment, {
1359
+ const facts = generationFacts(digest);
1360
+ const windows = windowRows(digest);
1361
+ const attention = attentionRows(digest);
1362
+ const diagnostics = dedupeDiagnostics(digest.diagnostics);
1363
+ return /* @__PURE__ */ jsxs("div", {
1364
+ "data-testid": "today-panel",
1982
1365
  children: [
1983
- issue === null ? null : /* @__PURE__ */ jsx2(Diagnostic, {
1984
- tone: "error",
1985
- title: issue.title,
1986
- detail: issue.detail,
1987
- testId: "daily-voice-issue"
1366
+ /* @__PURE__ */ jsx(StatusBanner, {
1367
+ digest,
1368
+ fetchedAt,
1369
+ onRefresh
1988
1370
  }),
1989
- uncapturedDiagnostic(evidence) === null ? null : /* @__PURE__ */ jsx2(Diagnostic, {
1990
- tone: "warning",
1991
- title: "Attempt not captured",
1992
- detail: uncapturedDiagnostic(evidence)?.message,
1993
- code: uncapturedDiagnostic(evidence)?.code,
1994
- testId: "daily-voice-uncaptured"
1995
- }),
1996
- /* @__PURE__ */ jsx2("dl", {
1371
+ /* @__PURE__ */ jsx("div", {
1997
1372
  className: "kk-board-facts",
1998
- "data-testid": "daily-voice-summary-facts",
1999
- children: facts.map((fact) => /* @__PURE__ */ jsxs2("div", {
1373
+ "data-testid": "generation-card",
1374
+ children: facts.map((fact) => /* @__PURE__ */ jsxs("div", {
1375
+ className: "kk-board-fact",
2000
1376
  children: [
2001
- /* @__PURE__ */ jsx2("dt", {
1377
+ /* @__PURE__ */ jsx("span", {
1378
+ className: "kk-board-state",
2002
1379
  children: fact.label
2003
1380
  }),
2004
- /* @__PURE__ */ jsxs2("dd", {
2005
- children: [
2006
- fact.value,
2007
- " ",
2008
- /* @__PURE__ */ jsx2("span", {
2009
- className: "kk-board-state",
2010
- children: fact.availability
2011
- })
2012
- ]
1381
+ /* @__PURE__ */ jsx(Badge, {
1382
+ variant: TONE_BADGE[fact.tone] ?? "neutral",
1383
+ size: "sm",
1384
+ children: fact.value
2013
1385
  })
2014
1386
  ]
2015
1387
  }, fact.label))
2016
1388
  }),
2017
- capture === null ? null : /* @__PURE__ */ jsxs2("details", {
2018
- className: "kk-card",
2019
- "data-testid": "daily-voice-captured-settings",
2020
- children: [
2021
- /* @__PURE__ */ jsxs2("summary", {
2022
- children: [
2023
- "Captured settings ",
2024
- /* @__PURE__ */ jsxs2("span", {
2025
- className: "kk-stat-sub",
2026
- children: [
2027
- "stamp ",
2028
- capture.stamp
2029
- ]
2030
- })
2031
- ]
2032
- }),
2033
- /* @__PURE__ */ jsxs2("div", {
2034
- className: "kk-board-config",
2035
- children: [
2036
- /* @__PURE__ */ jsxs2("p", {
2037
- children: [
2038
- "Captured ",
2039
- formatTimestamp(capture.capturedAt)
2040
- ]
2041
- }),
2042
- settings.length === 0 ? /* @__PURE__ */ jsx2("p", {
2043
- children: "No settings were recorded for this attempt."
2044
- }) : null,
2045
- /* @__PURE__ */ jsx2("dl", {
2046
- children: settings.map(([key, value]) => /* @__PURE__ */ jsxs2("div", {
2047
- children: [
2048
- /* @__PURE__ */ jsx2("dt", {
2049
- children: key
2050
- }),
2051
- /* @__PURE__ */ jsx2("dd", {
2052
- children: value
2053
- })
2054
- ]
2055
- }, key))
2056
- }),
2057
- capture.definitionDigest === undefined ? null : /* @__PURE__ */ jsxs2("p", {
1389
+ /* @__PURE__ */ jsx("h2", {
1390
+ children: "Publish windows"
1391
+ }),
1392
+ /* @__PURE__ */ jsx("ul", {
1393
+ className: "kk-board-windows",
1394
+ "data-testid": "window-strip",
1395
+ children: windows.map((window) => /* @__PURE__ */ jsxs("li", {
1396
+ children: [
1397
+ /* @__PURE__ */ jsx("strong", {
1398
+ children: window.label
1399
+ }),
1400
+ " ",
1401
+ /* @__PURE__ */ jsx(Badge, {
1402
+ variant: TONE_BADGE[window.tone] ?? "neutral",
1403
+ size: "sm",
1404
+ children: window.launch
1405
+ }),
1406
+ " ",
1407
+ /* @__PURE__ */ jsxs("span", {
1408
+ className: "kk-board-state",
1409
+ children: [
1410
+ "outcome ",
1411
+ window.recorded,
1412
+ window.unknownReason === null ? "" : ` — ${window.unknownReason}`,
1413
+ window.targets.length === 0 ? "" : ` · ${window.targets.length} target(s)`
1414
+ ]
1415
+ }),
1416
+ window.targets.length === 0 ? null : /* @__PURE__ */ jsx("ul", {
1417
+ children: window.targets.map((target) => /* @__PURE__ */ jsxs("li", {
2058
1418
  children: [
2059
- "Definition digest ",
2060
- /* @__PURE__ */ jsx2("code", {
2061
- children: capture.definitionDigest
2062
- })
1419
+ target.id,
1420
+ " — ",
1421
+ target.status,
1422
+ " · effect ",
1423
+ target.effect,
1424
+ target.error === "" ? "" : ` — ${target.error}`
2063
1425
  ]
2064
- })
2065
- ]
2066
- })
2067
- ]
2068
- }),
2069
- /* @__PURE__ */ jsx2(SupplyPanel, {
2070
- context,
2071
- supply,
2072
- storeOffline
2073
- }),
2074
- news === null ? /* @__PURE__ */ jsx2("p", {
2075
- className: "kk-board-footnote",
2076
- children: "The generation and publishing views stay empty for an uncaptured attempt — fixed artifacts are unknown, never invented."
2077
- }) : null
2078
- ]
2079
- });
2080
- }
2081
- function StageRow({ stage }) {
2082
- return /* @__PURE__ */ jsxs2("li", {
2083
- children: [
2084
- /* @__PURE__ */ jsx2("strong", {
2085
- children: stage.label
1426
+ }, target.id))
1427
+ })
1428
+ ]
1429
+ }, window.window))
2086
1430
  }),
2087
- " ",
2088
- /* @__PURE__ */ jsx2(Badge, {
2089
- variant: TONE_BADGE[stage.tone],
2090
- size: "sm",
2091
- children: stage.word
1431
+ /* @__PURE__ */ jsx("h2", {
1432
+ children: "Safety"
2092
1433
  }),
2093
- stage.timing === null ? null : /* @__PURE__ */ jsxs2("span", {
2094
- className: "kk-board-state",
1434
+ /* @__PURE__ */ jsxs("p", {
1435
+ "data-testid": "safety-line",
2095
1436
  children: [
1437
+ "verdict ",
1438
+ digest.safety.verdict ?? `unknown (${digest.safety.unknownReason ?? "unrecorded"})`,
1439
+ " · judge",
2096
1440
  " ",
2097
- stage.timing
1441
+ digest.safety.judge ?? "unknown"
2098
1442
  ]
1443
+ }),
1444
+ /* @__PURE__ */ jsx("h2", {
1445
+ children: "Attention"
1446
+ }),
1447
+ /* @__PURE__ */ jsx(AttentionList, {
1448
+ rows: attention
1449
+ }),
1450
+ diagnostics.length === 0 ? null : /* @__PURE__ */ jsx("div", {
1451
+ className: "kk-board-diagnostics",
1452
+ children: diagnostics.map((diagnostic) => /* @__PURE__ */ jsx(Diagnostic, {
1453
+ title: diagnostic.code,
1454
+ detail: diagnostic.message
1455
+ }, diagnostic.code))
2099
1456
  })
2100
1457
  ]
2101
1458
  });
2102
1459
  }
2103
- function ArtifactRow({ artifact }) {
2104
- if (artifact.href === null) {
2105
- return /* @__PURE__ */ jsx2("li", {
2106
- children: /* @__PURE__ */ jsxs2("span", {
2107
- children: [
2108
- artifact.label,
2109
- " — ",
2110
- artifact.state
2111
- ]
2112
- })
2113
- }, artifact.id);
2114
- }
2115
- if (artifact.kind === "audio") {
2116
- return /* @__PURE__ */ jsxs2("li", {
2117
- children: [
2118
- /* @__PURE__ */ jsx2("audio", {
2119
- controls: true,
2120
- src: artifact.href,
2121
- children: /* @__PURE__ */ jsx2("track", {
2122
- kind: "captions"
2123
- })
2124
- }),
2125
- " ",
2126
- /* @__PURE__ */ jsxs2("a", {
2127
- href: artifact.href,
2128
- download: true,
2129
- children: [
2130
- "download ",
2131
- artifact.label
2132
- ]
2133
- }),
2134
- " ",
2135
- "— ",
2136
- artifact.state
2137
- ]
2138
- }, artifact.id);
2139
- }
2140
- if (artifact.kind === "image") {
2141
- return /* @__PURE__ */ jsxs2("li", {
2142
- children: [
2143
- /* @__PURE__ */ jsx2("img", {
2144
- src: artifact.href,
2145
- alt: artifact.label
2146
- }),
2147
- " ",
2148
- artifact.label,
2149
- " — ",
2150
- artifact.state
2151
- ]
2152
- }, artifact.id);
2153
- }
2154
- return /* @__PURE__ */ jsxs2("li", {
2155
- children: [
2156
- /* @__PURE__ */ jsx2("a", {
2157
- href: artifact.href,
2158
- children: artifact.label
2159
- }),
2160
- " — ",
2161
- artifact.state
2162
- ]
2163
- }, artifact.id);
2164
- }
2165
- function NewsGenerationPanel({
2166
- evidence,
2167
- news,
2168
- stages,
2169
- groups
1460
+ function GenerationPanel({
1461
+ digest,
1462
+ client,
1463
+ recipes
2170
1464
  }) {
2171
- if (evidence === null || evidence.results === null) {
2172
- return /* @__PURE__ */ jsx2(EmptyState, {
2173
- testId: "daily-voice-generation-empty",
2174
- children: "No captured projection for the selected run."
1465
+ const attempts = useMemo(() => [...digest.generation.attempts].reverse(), [digest.generation.attempts]);
1466
+ const [selected, setSelected] = useState(attempts[0]?.runId ?? null);
1467
+ const [evidence, setEvidence] = useState(null);
1468
+ const [error, setError] = useState(null);
1469
+ useEffect(() => {
1470
+ if (selected === null)
1471
+ return;
1472
+ let cancelled = false;
1473
+ setError(null);
1474
+ client.evidence("kk-news-generate", selected).then((next) => {
1475
+ if (!cancelled)
1476
+ setEvidence(next);
1477
+ }).catch((cause) => {
1478
+ if (!cancelled) {
1479
+ setEvidence(null);
1480
+ setError(cause instanceof Error ? cause.message : String(cause));
1481
+ }
2175
1482
  });
2176
- }
2177
- const gate = news?.generation.gate.status ?? null;
2178
- const launch = news?.generation.launch ?? null;
2179
- return /* @__PURE__ */ jsxs2(Fragment, {
1483
+ return () => {
1484
+ cancelled = true;
1485
+ };
1486
+ }, [client, selected]);
1487
+ const detail = evidence === null ? null : generationDetail(evidence, digest);
1488
+ return /* @__PURE__ */ jsxs("div", {
1489
+ "data-testid": "generation-panel",
2180
1490
  children: [
2181
- /* @__PURE__ */ jsxs2("div", {
2182
- className: "kk-stat-grid",
2183
- "data-testid": "daily-voice-generation-facts",
1491
+ /* @__PURE__ */ jsxs("div", {
1492
+ className: "kk-board-attempt-picker",
2184
1493
  children: [
2185
- /* @__PURE__ */ jsxs2("div", {
2186
- className: "kk-stat-card",
2187
- children: [
2188
- /* @__PURE__ */ jsx2("span", {
2189
- className: "kk-stat-label",
2190
- children: "Generation outcome"
2191
- }),
2192
- /* @__PURE__ */ jsx2("span", {
2193
- className: "kk-stat-value",
2194
- children: news?.generation.outcome ?? "—"
2195
- }),
2196
- /* @__PURE__ */ jsx2("span", {
2197
- className: "kk-stat-sub",
2198
- children: "from the recorded result files"
2199
- })
2200
- ]
1494
+ /* @__PURE__ */ jsx("label", {
1495
+ htmlFor: "daily-voice-attempt",
1496
+ children: "attempt"
2201
1497
  }),
2202
- /* @__PURE__ */ jsxs2("div", {
2203
- className: "kk-stat-card",
1498
+ /* @__PURE__ */ jsxs("select", {
1499
+ id: "daily-voice-attempt",
1500
+ value: selected ?? "",
1501
+ onChange: (event) => setSelected(event.target.value),
2204
1502
  children: [
2205
- /* @__PURE__ */ jsx2("span", {
2206
- className: "kk-stat-label",
2207
- children: "Pool gate"
2208
- }),
2209
- /* @__PURE__ */ jsx2("span", {
2210
- className: "kk-stat-value",
2211
- children: gate ?? "—"
2212
- }),
2213
- /* @__PURE__ */ jsx2("span", {
2214
- className: "kk-stat-sub",
2215
- children: "pool-gate verdict"
2216
- })
2217
- ]
2218
- }),
2219
- /* @__PURE__ */ jsxs2("div", {
2220
- className: "kk-stat-card",
2221
- children: [
2222
- /* @__PURE__ */ jsx2("span", {
2223
- className: "kk-stat-label",
2224
- children: "Launch receipt"
2225
- }),
2226
- /* @__PURE__ */ jsx2("span", {
2227
- className: "kk-stat-value",
2228
- children: launch?.status ?? "—"
2229
- }),
2230
- /* @__PURE__ */ jsx2("span", {
2231
- className: "kk-stat-sub",
2232
- children: launch === null ? "not recorded" : launch.stale ? `stale — receipt run ${launch.runId ?? "unknown"} is not this attempt` : `run ${launch.runId ?? "unknown"}`
2233
- })
2234
- ]
2235
- })
2236
- ]
2237
- }),
2238
- stages.length === 0 ? /* @__PURE__ */ jsx2("p", {
2239
- children: "No producer stages were recorded for this attempt."
2240
- }) : /* @__PURE__ */ jsx2("ul", {
2241
- className: "kk-board-progress",
2242
- "data-testid": "daily-voice-generation-stages",
2243
- children: stages.map((stage) => /* @__PURE__ */ jsx2(StageRow, {
2244
- stage
2245
- }, stage.id))
2246
- }),
2247
- groups.length === 0 ? /* @__PURE__ */ jsx2("p", {
2248
- children: "No fixed artifacts were recorded for this attempt."
2249
- }) : groups.map((group) => /* @__PURE__ */ jsxs2("details", {
2250
- className: "kk-card",
2251
- "data-testid": "daily-voice-artifact-group",
2252
- children: [
2253
- /* @__PURE__ */ jsxs2("summary", {
2254
- children: [
2255
- group.label,
2256
- " ",
2257
- /* @__PURE__ */ jsxs2("span", {
2258
- className: "kk-stat-sub",
1503
+ attempts.length === 0 ? /* @__PURE__ */ jsx("option", {
1504
+ value: "",
1505
+ children: "no captured attempt"
1506
+ }) : null,
1507
+ attempts.map((attempt) => /* @__PURE__ */ jsxs("option", {
1508
+ value: attempt.runId,
2259
1509
  children: [
2260
- group.artifacts.filter((a) => a.href !== null).length,
2261
- " available of",
2262
- " ",
2263
- group.artifacts.length
1510
+ attempt.runId,
1511
+ " — ",
1512
+ attempt.status ?? "status unknown"
2264
1513
  ]
2265
- })
1514
+ }, attempt.runId))
2266
1515
  ]
2267
- }),
2268
- /* @__PURE__ */ jsx2("ul", {
2269
- className: "kk-board-artifacts",
2270
- children: group.artifacts.map((artifact) => /* @__PURE__ */ jsx2(ArtifactRow, {
2271
- artifact
2272
- }, artifact.id))
2273
- })
2274
- ]
2275
- }, group.producer || "unattributed"))
2276
- ]
2277
- });
2278
- }
2279
- function countWord(value) {
2280
- return value === null ? "not recorded" : `${value}`;
2281
- }
2282
- function countSumWord(left, right) {
2283
- return left === null || right === null ? "not recorded" : `${left + right}`;
2284
- }
2285
- function ProvenanceRow({ label, matched }) {
2286
- const word = matched === null ? "unknown" : matched ? "matched" : "MISMATCHED";
2287
- const tone = matched === null ? "neutral" : matched ? "success" : "error";
2288
- return /* @__PURE__ */ jsxs2("li", {
2289
- children: [
2290
- label,
2291
- " ",
2292
- /* @__PURE__ */ jsx2(Badge, {
2293
- variant: TONE_BADGE[tone],
2294
- size: "sm",
2295
- children: word
2296
- })
2297
- ]
2298
- });
2299
- }
2300
- function TargetRow({ target }) {
2301
- return /* @__PURE__ */ jsxs2("li", {
2302
- "data-testid": "daily-voice-publish-target",
2303
- children: [
2304
- /* @__PURE__ */ jsx2("strong", {
2305
- children: target.id
2306
- }),
2307
- " ",
2308
- /* @__PURE__ */ jsx2(Badge, {
2309
- variant: TONE_BADGE[target.tone],
2310
- size: "sm",
2311
- children: target.word
2312
- }),
2313
- target.target === null ? null : /* @__PURE__ */ jsxs2("span", {
2314
- children: [
2315
- " · ",
2316
- target.target
2317
- ]
2318
- }),
2319
- target.mode === null ? null : /* @__PURE__ */ jsxs2("span", {
2320
- children: [
2321
- " (",
2322
- target.mode,
2323
- ")"
2324
- ]
2325
- }),
2326
- target.url === null ? null : /* @__PURE__ */ jsxs2(Fragment, {
2327
- children: [
2328
- " ",
2329
- /* @__PURE__ */ jsx2("a", {
2330
- href: target.url,
2331
- rel: "noreferrer",
2332
- children: "open"
2333
1516
  })
2334
1517
  ]
2335
1518
  }),
2336
- target.error === null ? null : /* @__PURE__ */ jsxs2("span", {
2337
- className: "kk-board-state",
2338
- children: [
2339
- " — ",
2340
- target.error
2341
- ]
2342
- }),
2343
- target.finishedAt === null ? null : /* @__PURE__ */ jsxs2("span", {
2344
- className: "kk-board-state",
2345
- children: [
2346
- " finished ",
2347
- formatTimestamp(target.finishedAt)
2348
- ]
1519
+ error === null ? null : /* @__PURE__ */ jsx(Diagnostic, {
1520
+ title: "The attempt evidence could not be read",
1521
+ detail: error,
1522
+ code: "board.reader.unavailable"
2349
1523
  }),
2350
- /* @__PURE__ */ jsxs2("span", {
2351
- className: "kk-board-state",
1524
+ detail === null ? null : /* @__PURE__ */ jsxs(Fragment, {
2352
1525
  children: [
2353
- " ",
2354
- "evidence ",
2355
- /* @__PURE__ */ jsx2("code", {
2356
- children: target.evidence.plan
2357
- }),
2358
- target.evidence.receipt === null ? " · receipt not recorded" : /* @__PURE__ */ jsxs2("code", {
1526
+ /* @__PURE__ */ jsxs("p", {
1527
+ className: "kk-board-state",
2359
1528
  children: [
2360
- " · ",
2361
- target.evidence.receipt
2362
- ]
2363
- })
2364
- ]
2365
- })
2366
- ]
2367
- }, target.id);
2368
- }
2369
- function NewsPublishingPanel({ news }) {
2370
- if (news === null) {
2371
- return /* @__PURE__ */ jsx2(EmptyState, {
2372
- testId: "daily-voice-publishing-empty",
2373
- children: "No captured publishing projection for the selected run."
2374
- });
2375
- }
2376
- const bundle = news.publishing.bundle;
2377
- const rows = publishingWindowRows(news);
2378
- return /* @__PURE__ */ jsxs2(Fragment, {
2379
- children: [
2380
- /* @__PURE__ */ jsxs2("div", {
2381
- className: "kk-stat-grid",
2382
- "data-testid": "daily-voice-bundle",
2383
- children: [
2384
- /* @__PURE__ */ jsxs2("div", {
2385
- className: "kk-stat-card",
2386
- children: [
2387
- /* @__PURE__ */ jsx2("span", {
2388
- className: "kk-stat-label",
2389
- children: "Bundle"
2390
- }),
2391
- /* @__PURE__ */ jsx2("span", {
2392
- className: "kk-stat-value",
2393
- children: bundle?.title ?? "—"
2394
- }),
2395
- /* @__PURE__ */ jsx2("span", {
2396
- className: "kk-stat-sub",
2397
- children: bundle === null ? "not recorded" : bundle.identity
2398
- })
1529
+ "capture ",
1530
+ detail.captureState,
1531
+ " · availability ",
1532
+ detail.availability,
1533
+ detail.unknownReason === null ? "" : ` · unknown (${detail.unknownReason})`
2399
1534
  ]
2400
1535
  }),
2401
- /* @__PURE__ */ jsxs2("div", {
2402
- className: "kk-stat-card",
1536
+ /* @__PURE__ */ jsx("div", {
1537
+ className: "kk-board-facts",
1538
+ "data-testid": "attempt-facts",
1539
+ children: detail.facts.map((fact) => /* @__PURE__ */ jsxs("div", {
1540
+ className: "kk-board-fact",
1541
+ children: [
1542
+ /* @__PURE__ */ jsx("span", {
1543
+ className: "kk-board-state",
1544
+ children: fact.label
1545
+ }),
1546
+ /* @__PURE__ */ jsx("span", {
1547
+ children: fact.value === "" ? "unknown" : fact.value
1548
+ })
1549
+ ]
1550
+ }, fact.label))
1551
+ }),
1552
+ /* @__PURE__ */ jsx("h2", {
1553
+ children: "Node timeline"
1554
+ }),
1555
+ detail.timeline.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
1556
+ children: "No node was recorded for this attempt."
1557
+ }) : /* @__PURE__ */ jsxs("table", {
1558
+ className: "kk-board-timeline",
1559
+ "data-testid": "node-timeline",
2403
1560
  children: [
2404
- /* @__PURE__ */ jsx2("span", {
2405
- className: "kk-stat-label",
2406
- children: "Run date"
2407
- }),
2408
- /* @__PURE__ */ jsx2("span", {
2409
- className: "kk-stat-value",
2410
- children: bundle?.runDate ?? "—"
1561
+ /* @__PURE__ */ jsx("thead", {
1562
+ children: /* @__PURE__ */ jsxs("tr", {
1563
+ children: [
1564
+ /* @__PURE__ */ jsx("th", {
1565
+ children: "node"
1566
+ }),
1567
+ /* @__PURE__ */ jsx("th", {
1568
+ children: "state"
1569
+ }),
1570
+ /* @__PURE__ */ jsx("th", {
1571
+ children: "attempts"
1572
+ }),
1573
+ /* @__PURE__ */ jsx("th", {
1574
+ children: "step duration"
1575
+ }),
1576
+ /* @__PURE__ */ jsx("th", {
1577
+ children: "recipe"
1578
+ })
1579
+ ]
1580
+ })
2411
1581
  }),
2412
- /* @__PURE__ */ jsx2("span", {
2413
- className: "kk-stat-sub",
2414
- children: bundle?.variants.length ? `variants ${bundle.variants.join(", ")}` : "variants unrecorded"
1582
+ /* @__PURE__ */ jsx("tbody", {
1583
+ children: detail.timeline.map((node) => /* @__PURE__ */ jsxs("tr", {
1584
+ children: [
1585
+ /* @__PURE__ */ jsxs("td", {
1586
+ children: [
1587
+ node.label,
1588
+ node.engine ? /* @__PURE__ */ jsx("span", {
1589
+ className: "kk-board-state",
1590
+ children: " (voice chain)"
1591
+ }) : null
1592
+ ]
1593
+ }),
1594
+ /* @__PURE__ */ jsx("td", {
1595
+ children: /* @__PURE__ */ jsx(Badge, {
1596
+ variant: TONE_BADGE[node.tone] ?? "neutral",
1597
+ size: "sm",
1598
+ children: node.word
1599
+ })
1600
+ }),
1601
+ /* @__PURE__ */ jsx("td", {
1602
+ children: node.timing ?? "timing unknown"
1603
+ }),
1604
+ /* @__PURE__ */ jsx("td", {
1605
+ children: formatDuration(node.durationMs)
1606
+ }),
1607
+ /* @__PURE__ */ jsx("td", {
1608
+ children: recipes(node.id).map((recipe) => /* @__PURE__ */ jsx(RecipeLine, {
1609
+ argv: recipe.argv,
1610
+ label: recipe.label,
1611
+ dryRun: recipe.dryRunArgv
1612
+ }, recipe.argv.join(" ")))
1613
+ })
1614
+ ]
1615
+ }, node.id))
2415
1616
  })
2416
1617
  ]
2417
1618
  }),
2418
- /* @__PURE__ */ jsxs2("div", {
2419
- className: "kk-stat-card",
1619
+ /* @__PURE__ */ jsx("h2", {
1620
+ children: "Engine chain"
1621
+ }),
1622
+ detail.engines.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
1623
+ children: "No engine was recorded for this attempt."
1624
+ }) : /* @__PURE__ */ jsx("ul", {
1625
+ "data-testid": "engine-chain",
1626
+ children: detail.engines.map((engine) => /* @__PURE__ */ jsxs("li", {
1627
+ children: [
1628
+ engine.label,
1629
+ " — ",
1630
+ engine.state,
1631
+ " · ",
1632
+ engine.attempts,
1633
+ " attempt(s)",
1634
+ engine.lastTiming === null ? "" : ` · ${engine.lastTiming}`
1635
+ ]
1636
+ }, engine.node))
1637
+ }),
1638
+ /* @__PURE__ */ jsx("h2", {
1639
+ children: "Artifacts"
1640
+ }),
1641
+ detail.artifacts.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
1642
+ children: "This attempt recorded no artifact."
1643
+ }) : /* @__PURE__ */ jsx("ul", {
1644
+ "data-testid": "attempt-artifacts",
1645
+ children: detail.artifacts.map((artifact) => /* @__PURE__ */ jsxs("li", {
1646
+ children: [
1647
+ artifact.label,
1648
+ " —",
1649
+ " ",
1650
+ artifact.availability === "available" ? /* @__PURE__ */ jsx("a", {
1651
+ href: client.artifactUrl("kk-news-generate", detail.runId, artifact.id),
1652
+ children: "available"
1653
+ }) : /* @__PURE__ */ jsxs("span", {
1654
+ className: "kk-board-state",
1655
+ children: [
1656
+ artifact.availability,
1657
+ artifact.reason === null ? "" : ` (${artifact.reason})`
1658
+ ]
1659
+ })
1660
+ ]
1661
+ }, artifact.id))
1662
+ }),
1663
+ /* @__PURE__ */ jsx("h2", {
1664
+ children: "Diagnostics"
1665
+ }),
1666
+ detail.diagnostics.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
1667
+ children: "No diagnostic was recorded for this attempt."
1668
+ }) : /* @__PURE__ */ jsxs(Fragment, {
2420
1669
  children: [
2421
- /* @__PURE__ */ jsx2("span", {
2422
- className: "kk-stat-label",
2423
- children: "Targets"
2424
- }),
2425
- /* @__PURE__ */ jsxs2("span", {
2426
- className: "kk-stat-value",
2427
- children: [
2428
- countWord(news.counts.targetsSucceeded),
2429
- " sent"
2430
- ]
2431
- }),
2432
- /* @__PURE__ */ jsxs2("span", {
2433
- className: "kk-stat-sub",
1670
+ detail.diagnostics.map((diagnostic) => /* @__PURE__ */ jsx(Diagnostic, {
1671
+ title: diagnostic.code,
1672
+ detail: diagnostic.message
1673
+ }, diagnostic.code)),
1674
+ detail.diagnostics.length >= NODE_DIAGNOSTIC_CAP ? /* @__PURE__ */ jsxs("p", {
1675
+ className: "kk-board-state",
2434
1676
  children: [
2435
- countSumWord(news.counts.targetsFailed, news.counts.targetsUncertain),
2436
- " failed or uncertain ·",
2437
- " ",
2438
- countWord(news.counts.targetsPlanned),
2439
- " planned"
1677
+ "truncated — the first ",
1678
+ NODE_DIAGNOSTIC_CAP,
1679
+ " diagnostics are shown."
2440
1680
  ]
2441
- })
2442
- ]
2443
- })
2444
- ]
2445
- }),
2446
- bundle?.parentRunId == null ? null : /* @__PURE__ */ jsxs2("p", {
2447
- children: [
2448
- "Parent run ",
2449
- /* @__PURE__ */ jsx2("code", {
2450
- children: bundle.parentRunId
2451
- })
2452
- ]
2453
- }),
2454
- bundle?.safety == null ? null : /* @__PURE__ */ jsxs2("p", {
2455
- children: [
2456
- "Safety: ",
2457
- bundle.safety
2458
- ]
2459
- }),
2460
- rows.length === 0 ? /* @__PURE__ */ jsx2(EmptyState, {
2461
- children: "No publishable window was recorded for this attempt."
2462
- }) : rows.map((row) => /* @__PURE__ */ jsxs2("section", {
2463
- className: "kk-card",
2464
- "data-testid": "daily-voice-publish-window",
2465
- children: [
2466
- /* @__PURE__ */ jsxs2("div", {
2467
- className: "kk-card-header",
2468
- children: [
2469
- /* @__PURE__ */ jsx2("h2", {
2470
- children: row.label
2471
- }),
2472
- /* @__PURE__ */ jsx2(Badge, {
2473
- variant: row.recorded === null ? "neutral" : TONE_BADGE[row.recorded.tone],
2474
- size: "sm",
2475
- children: row.recorded === null ? "outcome not recorded" : row.recorded.word
2476
- })
1681
+ }) : null
2477
1682
  ]
2478
- }),
2479
- /* @__PURE__ */ jsx2("ul", {
2480
- className: "kk-board-edges",
2481
- children: row.provenance.map((check) => /* @__PURE__ */ jsx2(ProvenanceRow, {
2482
- label: check.label,
2483
- matched: check.matched
2484
- }, check.label))
2485
- }),
2486
- row.targets.length === 0 ? /* @__PURE__ */ jsx2("p", {
2487
- children: "No target plan was recorded for this window."
2488
- }) : /* @__PURE__ */ jsx2("ul", {
2489
- className: "kk-board-channels",
2490
- children: row.targets.map((target) => /* @__PURE__ */ jsx2(TargetRow, {
2491
- target
2492
- }, target.id))
2493
1683
  })
2494
1684
  ]
2495
- }, row.window)),
2496
- /* @__PURE__ */ jsx2("p", {
2497
- className: "kk-board-footnote",
2498
- children: "Evidence paths are workspace-relative references recorded by the run — shown as text, never turned into links."
2499
1685
  })
2500
1686
  ]
2501
1687
  });
2502
1688
  }
2503
- function funnelCount(value) {
2504
- return value === null ? "unavailable" : String(value);
2505
- }
2506
- function funnelMinutes(value) {
2507
- return value === null ? "unavailable" : `${value.toFixed(1)} min`;
2508
- }
2509
- function EvidenceChip({
2510
- field,
2511
- funnel,
2512
- artifacts
2513
- }) {
2514
- const evidenceId = funnel.evidence[field];
2515
- if (evidenceId === undefined)
2516
- return /* @__PURE__ */ jsx2("span", {
2517
- className: "kk-board-state",
2518
- children: "no evidence"
2519
- });
2520
- if (evidenceId === "captured-settings")
2521
- return /* @__PURE__ */ jsx2("code", {
2522
- children: "captured-settings"
2523
- });
2524
- const artifact = artifacts.find((candidate) => candidate.id === evidenceId);
2525
- return artifact === undefined || artifact.href === null ? /* @__PURE__ */ jsxs2("code", {
2526
- children: [
2527
- evidenceId,
2528
- " (",
2529
- artifact?.state ?? "missing",
2530
- ")"
2531
- ]
2532
- }) : /* @__PURE__ */ jsx2("a", {
2533
- href: artifact.href,
2534
- children: /* @__PURE__ */ jsx2("code", {
2535
- children: evidenceId
2536
- })
2537
- });
2538
- }
2539
- function FunnelPanel({ funnel, artifacts }) {
2540
- const rows = [
2541
- { label: "1 · Episode pool", value: funnelCount(funnel.poolCount), field: "poolCount" },
2542
- { label: "2 · Annotated", value: funnelCount(funnel.annotatedCount), field: "annotatedCount" },
2543
- { label: "3 · Topic filter kept", value: funnelCount(funnel.topicKeptCount), field: "topicKeptCount" },
2544
- { label: "4 · QC rejected", value: funnelCount(funnel.qcRejectedCount), field: "qcRejectedCount" },
2545
- {
2546
- label: "5 · Post-dedup survivors",
2547
- value: funnel.dedupKeptCount === null && (funnel.gate === "episode-duration" || funnel.gate === "script" || funnel.gate === "qc-floor") ? "unknown — cleared by the refusal" : funnel.dedupKeptCount === null && funnel.plannedCount !== null ? "unknown — plan recorded" : funnelCount(funnel.dedupKeptCount),
2548
- field: "dedupKeptCount"
2549
- },
2550
- { label: "6 · Episode plan", value: funnelCount(funnel.plannedCount), field: "plannedCount" }
2551
- ];
2552
- return /* @__PURE__ */ jsxs2("section", {
2553
- className: "kk-card kk-daily-funnel",
1689
+ function PublishingPanel({ digest, recipes }) {
1690
+ const windows = publishingDetail(digest);
1691
+ return /* @__PURE__ */ jsxs("div", {
1692
+ "data-testid": "publishing-panel",
2554
1693
  children: [
2555
- /* @__PURE__ */ jsxs2("div", {
2556
- className: "kk-card-header",
2557
- children: [
2558
- /* @__PURE__ */ jsx2("h2", {
2559
- children: "Episode funnel"
2560
- }),
2561
- /* @__PURE__ */ jsx2("span", {
2562
- className: "kk-stat-sub",
2563
- children: "artifact-backed by this run"
2564
- })
2565
- ]
2566
- }),
2567
- /* @__PURE__ */ jsxs2("dl", {
2568
- children: [
2569
- rows.map((row) => /* @__PURE__ */ jsxs2("div", {
2570
- children: [
2571
- /* @__PURE__ */ jsx2("dt", {
2572
- children: row.label
2573
- }),
2574
- /* @__PURE__ */ jsxs2("dd", {
2575
- children: [
2576
- row.value,
2577
- " · evidence",
2578
- " ",
2579
- /* @__PURE__ */ jsx2(EvidenceChip, {
2580
- field: row.field,
2581
- funnel,
2582
- artifacts
2583
- })
2584
- ]
2585
- })
2586
- ]
2587
- }, row.label)),
2588
- /* @__PURE__ */ jsxs2("div", {
2589
- children: [
2590
- /* @__PURE__ */ jsx2("dt", {
2591
- children: "Duration ladder"
2592
- }),
2593
- /* @__PURE__ */ jsxs2("dd", {
2594
- children: [
2595
- "measured ",
2596
- funnelMinutes(funnel.measuredMinutes),
2597
- " · estimated",
2598
- " ",
2599
- funnelMinutes(funnel.estimatedMinutes),
2600
- " · floor ",
2601
- funnelMinutes(funnel.minMinutes),
2602
- " · ceiling",
2603
- " ",
2604
- funnelMinutes(funnel.maxMinutes)
2605
- ]
2606
- })
2607
- ]
2608
- }, "minutes"),
2609
- /* @__PURE__ */ jsxs2("div", {
2610
- children: [
2611
- /* @__PURE__ */ jsx2("dt", {
2612
- children: "No-content gate"
2613
- }),
2614
- /* @__PURE__ */ jsxs2("dd", {
2615
- children: [
2616
- funnel.gateName,
2617
- " · evidence ",
2618
- /* @__PURE__ */ jsx2(EvidenceChip, {
2619
- field: "gate",
2620
- funnel,
2621
- artifacts
2622
- })
2623
- ]
2624
- })
2625
- ]
2626
- }, "gate")
2627
- ]
2628
- }),
2629
- funnel.exclusions.length === 0 ? null : /* @__PURE__ */ jsxs2("div", {
2630
- children: [
2631
- /* @__PURE__ */ jsx2("h3", {
2632
- children: "Topic-filter exclusions"
2633
- }),
2634
- /* @__PURE__ */ jsx2("ul", {
2635
- className: "kk-board-channels",
2636
- children: funnel.exclusions.map((exclusion) => /* @__PURE__ */ jsxs2("li", {
1694
+ windows.map((window) => /* @__PURE__ */ jsx(Card, {
1695
+ variant: "bordered",
1696
+ children: /* @__PURE__ */ jsxs(CardBody, {
1697
+ children: [
1698
+ /* @__PURE__ */ jsxs("h2", {
1699
+ children: [
1700
+ window.label,
1701
+ " ",
1702
+ /* @__PURE__ */ jsx(Badge, {
1703
+ variant: TONE_BADGE[window.tone] ?? "neutral",
1704
+ size: "sm",
1705
+ children: window.launch
1706
+ })
1707
+ ]
1708
+ }),
1709
+ /* @__PURE__ */ jsxs("p", {
1710
+ className: "kk-board-state",
1711
+ children: [
1712
+ "outcome ",
1713
+ window.recorded,
1714
+ window.unknownReason === null ? "" : ` — unknown (${window.unknownReason})`,
1715
+ window.runId === null ? "" : ` · run ${window.runId}`
1716
+ ]
1717
+ }),
1718
+ /* @__PURE__ */ jsxs("p", {
1719
+ className: "kk-board-state",
1720
+ "data-testid": "window-provenance",
1721
+ children: [
1722
+ "provenance:",
1723
+ " ",
1724
+ window.provenance.map((row) => `${row.label} ${provenanceWord(row.matched)}`).join(" · ")
1725
+ ]
1726
+ }),
1727
+ window.rows.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
1728
+ children: window.notRun ? "This window recorded no plan and no launch receipt." : "This window planned no target."
1729
+ }) : /* @__PURE__ */ jsxs("table", {
1730
+ className: "kk-board-matrix",
1731
+ "data-testid": "target-matrix",
2637
1732
  children: [
2638
- /* @__PURE__ */ jsx2("strong", {
2639
- children: exclusion.rule
1733
+ /* @__PURE__ */ jsx("thead", {
1734
+ children: /* @__PURE__ */ jsxs("tr", {
1735
+ children: [
1736
+ /* @__PURE__ */ jsx("th", {
1737
+ children: "target"
1738
+ }),
1739
+ /* @__PURE__ */ jsx("th", {
1740
+ children: "tier"
1741
+ }),
1742
+ /* @__PURE__ */ jsx("th", {
1743
+ children: "mode"
1744
+ }),
1745
+ /* @__PURE__ */ jsx("th", {
1746
+ children: "status"
1747
+ }),
1748
+ /* @__PURE__ */ jsx("th", {
1749
+ children: "effect"
1750
+ }),
1751
+ /* @__PURE__ */ jsx("th", {
1752
+ children: "url"
1753
+ }),
1754
+ /* @__PURE__ */ jsx("th", {
1755
+ children: "error"
1756
+ }),
1757
+ /* @__PURE__ */ jsx("th", {
1758
+ children: "evidence"
1759
+ })
1760
+ ]
1761
+ })
2640
1762
  }),
2641
- exclusion.matched === "" ? null : ` — matched “${exclusion.matched}”`
1763
+ /* @__PURE__ */ jsx("tbody", {
1764
+ children: window.rows.map((row) => /* @__PURE__ */ jsxs("tr", {
1765
+ children: [
1766
+ /* @__PURE__ */ jsx("td", {
1767
+ children: row.id
1768
+ }),
1769
+ /* @__PURE__ */ jsx("td", {
1770
+ children: row.tier
1771
+ }),
1772
+ /* @__PURE__ */ jsx("td", {
1773
+ children: row.mode
1774
+ }),
1775
+ /* @__PURE__ */ jsx("td", {
1776
+ children: /* @__PURE__ */ jsx(Badge, {
1777
+ variant: TONE_BADGE[row.tone] ?? "neutral",
1778
+ size: "sm",
1779
+ children: row.status
1780
+ })
1781
+ }),
1782
+ /* @__PURE__ */ jsx("td", {
1783
+ children: row.effect
1784
+ }),
1785
+ /* @__PURE__ */ jsx("td", {
1786
+ children: row.url === null ? "—" : /* @__PURE__ */ jsx("a", {
1787
+ href: row.url,
1788
+ rel: "noreferrer noopener",
1789
+ target: "_blank",
1790
+ children: row.url
1791
+ })
1792
+ }),
1793
+ /* @__PURE__ */ jsx("td", {
1794
+ children: row.error === "" ? "—" : row.error
1795
+ }),
1796
+ /* @__PURE__ */ jsx("td", {
1797
+ children: /* @__PURE__ */ jsx("code", {
1798
+ children: row.evidence
1799
+ })
1800
+ })
1801
+ ]
1802
+ }, row.id))
1803
+ })
2642
1804
  ]
2643
- }, `${exclusion.rule}::${exclusion.matched}`))
2644
- })
2645
- ]
2646
- }),
2647
- funnel.diagnostics.length === 0 ? null : /* @__PURE__ */ jsx2("ul", {
2648
- children: funnel.diagnostics.map((diagnostic) => /* @__PURE__ */ jsxs2("li", {
2649
- role: "status",
2650
- className: "kk-board-diagnostic",
2651
- children: [
2652
- diagnostic.code,
2653
- ": ",
2654
- diagnostic.message
1805
+ }),
1806
+ recipes(window.window).map((recipe) => /* @__PURE__ */ jsx(RecipeLine, {
1807
+ argv: recipe.argv,
1808
+ label: recipe.label,
1809
+ dryRun: recipe.dryRunArgv
1810
+ }, recipe.argv.join(" ")))
2655
1811
  ]
2656
- }, diagnostic.code))
1812
+ })
1813
+ }, window.window)),
1814
+ /* @__PURE__ */ jsx("p", {
1815
+ className: "kk-board-state",
1816
+ children: "Receipts and plans are text, never links. Only a public http(s) result URL becomes a link."
2657
1817
  })
2658
1818
  ]
2659
1819
  });
2660
1820
  }
2661
- function SupplyPanel({
2662
- context,
2663
- supply,
2664
- storeOffline
1821
+ function HistoryPanel({
1822
+ days,
1823
+ selected,
1824
+ onSelect
2665
1825
  }) {
2666
- return /* @__PURE__ */ jsxs2("section", {
2667
- className: "kk-card kk-daily-supply",
1826
+ const rows = historyRows(days);
1827
+ const trend = durationTrend(days);
1828
+ if (rows.length === 0) {
1829
+ return /* @__PURE__ */ jsx(EmptyState, {
1830
+ testId: "history-empty",
1831
+ children: "No recorded day in the selected range."
1832
+ });
1833
+ }
1834
+ return /* @__PURE__ */ jsxs("div", {
1835
+ "data-testid": "history-panel",
2668
1836
  children: [
2669
- /* @__PURE__ */ jsxs2("div", {
2670
- className: "kk-card-header",
1837
+ /* @__PURE__ */ jsxs("table", {
1838
+ className: "kk-board-history",
2671
1839
  children: [
2672
- /* @__PURE__ */ jsx2("h2", {
2673
- children: "Supply context (configured)"
1840
+ /* @__PURE__ */ jsx("thead", {
1841
+ children: /* @__PURE__ */ jsxs("tr", {
1842
+ children: [
1843
+ /* @__PURE__ */ jsx("th", {
1844
+ children: "day"
1845
+ }),
1846
+ /* @__PURE__ */ jsx("th", {
1847
+ children: "status"
1848
+ }),
1849
+ /* @__PURE__ */ jsx("th", {
1850
+ children: "run"
1851
+ }),
1852
+ /* @__PURE__ */ jsx("th", {
1853
+ children: "windows"
1854
+ }),
1855
+ /* @__PURE__ */ jsx("th", {
1856
+ children: "generation time"
1857
+ })
1858
+ ]
1859
+ })
2674
1860
  }),
2675
- /* @__PURE__ */ jsx2("span", {
2676
- className: "kk-stat-sub",
2677
- children: "read from the kk-collect store"
1861
+ /* @__PURE__ */ jsx("tbody", {
1862
+ children: rows.map((row) => /* @__PURE__ */ jsxs("tr", {
1863
+ className: row.day === selected ? "kk-board-selected" : undefined,
1864
+ children: [
1865
+ /* @__PURE__ */ jsx("td", {
1866
+ children: /* @__PURE__ */ jsx(Button, {
1867
+ variant: "ghost",
1868
+ size: "xs",
1869
+ onClick: () => onSelect(row.day),
1870
+ children: row.day
1871
+ })
1872
+ }),
1873
+ /* @__PURE__ */ jsx("td", {
1874
+ children: /* @__PURE__ */ jsx(Badge, {
1875
+ variant: TONE_BADGE[row.tone] ?? "neutral",
1876
+ size: "sm",
1877
+ children: row.word
1878
+ })
1879
+ }),
1880
+ /* @__PURE__ */ jsx("td", {
1881
+ children: row.runId ?? "unknown"
1882
+ }),
1883
+ /* @__PURE__ */ jsx("td", {
1884
+ children: row.windows.length === 0 ? "none" : row.windows.map((window) => `${window.window}: ${window.launch}`).join(", ")
1885
+ }),
1886
+ /* @__PURE__ */ jsx("td", {
1887
+ children: formatDuration(row.totalMs)
1888
+ })
1889
+ ]
1890
+ }, row.day))
2678
1891
  })
2679
1892
  ]
2680
1893
  }),
2681
- context === null ? /* @__PURE__ */ jsx2("p", {
2682
- children: "The configured supply interval is unknown — no captured window setting or run start was recorded, so no store query was issued."
2683
- }) : /* @__PURE__ */ jsxs2("p", {
2684
- children: [
2685
- "Window ",
2686
- /* @__PURE__ */ jsx2("code", {
2687
- children: context.fromLabel
2688
- }),
2689
- " → ",
2690
- /* @__PURE__ */ jsx2("code", {
2691
- children: context.untilLabel
2692
- }),
2693
- supply === null ? "" : ` · time zone ${supply.timeZone}`,
2694
- " — configured context; the effective extraction window (ladder bounds) is unknown, not persisted."
2695
- ]
1894
+ /* @__PURE__ */ jsx("h2", {
1895
+ children: "Per-node duration trend"
2696
1896
  }),
2697
- storeOffline ? /* @__PURE__ */ jsx2("p", {
2698
- children: "The store reader is offline; supply counts are unavailable."
2699
- }) : null,
2700
- supply !== null && supply.availability === "unavailable" ? /* @__PURE__ */ jsx2("p", {
2701
- children: "The store could not be read for this window; no counts are shown."
2702
- }) : null,
2703
- supply !== null && supply.availability === "unavailable" && supply.diagnostics.length > 0 ? /* @__PURE__ */ jsx2("ul", {
2704
- children: supply.diagnostics.map((diagnostic) => /* @__PURE__ */ jsxs2("li", {
2705
- className: "kk-board-diagnostic",
2706
- children: [
2707
- diagnostic.code,
2708
- ": ",
2709
- diagnostic.message
2710
- ]
2711
- }, diagnostic.code))
2712
- }) : null,
2713
- supply !== null && supply.availability === "available" ? /* @__PURE__ */ jsxs2("div", {
2714
- className: "kk-summary-grids",
1897
+ /* @__PURE__ */ jsxs("table", {
1898
+ className: "kk-board-trend",
1899
+ "data-testid": "duration-trend",
2715
1900
  children: [
2716
- /* @__PURE__ */ jsxs2("div", {
2717
- className: "kk-card",
2718
- children: [
2719
- /* @__PURE__ */ jsxs2("div", {
2720
- className: "kk-card-header",
2721
- children: [
2722
- /* @__PURE__ */ jsx2("h2", {
2723
- children: "New items by day and source"
2724
- }),
2725
- /* @__PURE__ */ jsxs2("span", {
2726
- className: "kk-stat-sub",
2727
- children: [
2728
- supply.sources.length,
2729
- " sources"
2730
- ]
2731
- })
2732
- ]
2733
- }),
2734
- /* @__PURE__ */ jsx2("div", {
2735
- className: "kk-table-container",
2736
- children: /* @__PURE__ */ jsx2(ChannelYieldTable, {
2737
- data: supply
1901
+ /* @__PURE__ */ jsx("thead", {
1902
+ children: /* @__PURE__ */ jsxs("tr", {
1903
+ children: [
1904
+ /* @__PURE__ */ jsx("th", {
1905
+ children: "step"
1906
+ }),
1907
+ /* @__PURE__ */ jsx("th", {
1908
+ children: "latest"
1909
+ }),
1910
+ /* @__PURE__ */ jsx("th", {
1911
+ children: "days"
2738
1912
  })
2739
- })
2740
- ]
1913
+ ]
1914
+ })
2741
1915
  }),
2742
- /* @__PURE__ */ jsxs2("div", {
2743
- className: "kk-card",
2744
- children: [
2745
- /* @__PURE__ */ jsxs2("div", {
2746
- className: "kk-card-header",
2747
- children: [
2748
- /* @__PURE__ */ jsx2("h2", {
2749
- children: "Collection ticks and plugin contributions"
2750
- }),
2751
- /* @__PURE__ */ jsxs2("span", {
2752
- className: "kk-stat-sub",
2753
- children: [
2754
- supply.plugins.length,
2755
- " plugins"
2756
- ]
2757
- })
2758
- ]
2759
- }),
2760
- /* @__PURE__ */ jsx2("div", {
2761
- className: "kk-table-container",
2762
- children: /* @__PURE__ */ jsx2(PluginRunTable, {
2763
- data: supply
1916
+ /* @__PURE__ */ jsx("tbody", {
1917
+ children: trend.map((series) => /* @__PURE__ */ jsxs("tr", {
1918
+ children: [
1919
+ /* @__PURE__ */ jsx("td", {
1920
+ children: series.step
1921
+ }),
1922
+ /* @__PURE__ */ jsx("td", {
1923
+ children: formatDuration(series.latestMs)
1924
+ }),
1925
+ /* @__PURE__ */ jsx("td", {
1926
+ children: series.points.map((point) => `${point.day}: ${formatDuration(point.ms)}`).join(" · ")
2764
1927
  })
2765
- })
2766
- ]
1928
+ ]
1929
+ }, series.step))
2767
1930
  })
2768
1931
  ]
2769
- }) : null,
2770
- /* @__PURE__ */ jsx2("p", {
2771
- className: "kk-board-footnote",
2772
- children: "A source absent from this window recorded 0 contributions; its health is unknown. The artifact-backed evidence stays the consumption record — supply here is context, not consumption."
2773
1932
  })
2774
1933
  ]
2775
1934
  });
2776
1935
  }
2777
- function LegacySummaryPanel({
2778
- facts,
2779
- results,
2780
- config,
2781
- funnel,
2782
- artifacts,
2783
- context,
2784
- supply,
2785
- storeOffline
1936
+ function ActionLauncher({
1937
+ client,
1938
+ recipe,
1939
+ day,
1940
+ onLaunched
2786
1941
  }) {
2787
- if (results === null)
2788
- return /* @__PURE__ */ jsx2(EmptyState, {
2789
- children: "No captured results for the selected run."
1942
+ const [preview, setPreview] = useState(null);
1943
+ const [confirm, setConfirm] = useState("");
1944
+ const [state, setState] = useState(null);
1945
+ const post = async (body) => {
1946
+ const answer = await client.action(recipe.kind, body);
1947
+ const payload = answer.body ?? {};
1948
+ if (answer.status !== 200 && answer.status !== 202) {
1949
+ setState(`refused: ${String(payload.code ?? answer.status)}`);
1950
+ return;
1951
+ }
1952
+ if (answer.status === 202) {
1953
+ setState("launched — see Actions log");
1954
+ onLaunched();
1955
+ return;
1956
+ }
1957
+ setPreview({
1958
+ token: String(payload.token ?? ""),
1959
+ dryRun: typeof payload.dryRun === "string" ? payload.dryRun : null,
1960
+ argv: Array.isArray(payload.argv) ? payload.argv : []
2790
1961
  });
2791
- const summary = dailySummary(results);
2792
- const settings = config === null ? [] : Object.entries(config.settings);
2793
- const liveChannels = summary.channels.filter((c) => c.state === "live").length;
2794
- return /* @__PURE__ */ jsxs2(Fragment, {
1962
+ setState(null);
1963
+ };
1964
+ return /* @__PURE__ */ jsxs("div", {
1965
+ className: "kk-board-action",
2795
1966
  children: [
2796
- /* @__PURE__ */ jsxs2("div", {
2797
- className: "kk-stat-grid",
1967
+ preview === null ? /* @__PURE__ */ jsx(Button, {
1968
+ variant: "ghost",
1969
+ size: "xs",
1970
+ onClick: () => void post({ params: recipe.params }),
1971
+ children: "preview"
1972
+ }) : /* @__PURE__ */ jsxs(Fragment, {
2798
1973
  children: [
2799
- /* @__PURE__ */ jsxs2("div", {
2800
- className: "kk-stat-card",
2801
- children: [
2802
- /* @__PURE__ */ jsx2("span", {
2803
- className: "kk-stat-label",
2804
- children: "Episode Outcome"
2805
- }),
2806
- /* @__PURE__ */ jsx2("span", {
2807
- className: "kk-stat-value",
2808
- children: summary.outcome ?? "—"
2809
- }),
2810
- /* @__PURE__ */ jsx2("span", {
2811
- className: "kk-stat-sub",
2812
- children: summary.articleTitle ? summary.articleTitle.slice(0, 32) : "Daily podcast"
2813
- })
2814
- ]
2815
- }),
2816
- /* @__PURE__ */ jsxs2("div", {
2817
- className: "kk-stat-card",
2818
- children: [
2819
- /* @__PURE__ */ jsx2("span", {
2820
- className: "kk-stat-label",
2821
- children: "Distribution"
2822
- }),
2823
- /* @__PURE__ */ jsxs2("span", {
2824
- className: "kk-stat-value",
2825
- children: [
2826
- liveChannels,
2827
- " / ",
2828
- summary.channels.length
2829
- ]
2830
- }),
2831
- /* @__PURE__ */ jsx2("span", {
2832
- className: "kk-stat-sub",
2833
- children: "Channels published live"
2834
- })
2835
- ]
1974
+ /* @__PURE__ */ jsx("code", {
1975
+ "data-testid": "action-preview-argv",
1976
+ children: preview.argv.join(" ")
2836
1977
  }),
2837
- /* @__PURE__ */ jsxs2("div", {
2838
- className: "kk-stat-card",
2839
- children: [
2840
- /* @__PURE__ */ jsx2("span", {
2841
- className: "kk-stat-label",
2842
- children: "Quality Score"
2843
- }),
2844
- /* @__PURE__ */ jsx2("span", {
2845
- className: "kk-stat-value",
2846
- children: summary.quality?.overallScore ?? "—"
2847
- }),
2848
- /* @__PURE__ */ jsx2("span", {
2849
- className: "kk-stat-sub",
2850
- children: summary.quality?.passed ? "Passed QC standard" : "Under evaluation"
2851
- })
2852
- ]
1978
+ preview.dryRun === null ? null : /* @__PURE__ */ jsx("pre", {
1979
+ className: "kk-board-state",
1980
+ children: preview.dryRun
2853
1981
  }),
2854
- /* @__PURE__ */ jsxs2("div", {
2855
- className: "kk-stat-card",
1982
+ recipe.live ? /* @__PURE__ */ jsxs("label", {
2856
1983
  children: [
2857
- /* @__PURE__ */ jsx2("span", {
2858
- className: "kk-stat-label",
2859
- children: "Safety Verdict"
2860
- }),
2861
- /* @__PURE__ */ jsx2("span", {
2862
- className: "kk-stat-value",
2863
- children: summary.safety?.verdict ?? "—"
2864
- }),
2865
- /* @__PURE__ */ jsxs2("span", {
2866
- className: "kk-stat-sub",
2867
- children: [
2868
- "Confidence: ",
2869
- summary.safety?.confidence ?? "—"
2870
- ]
1984
+ "type ",
1985
+ day,
1986
+ " to send live",
1987
+ /* @__PURE__ */ jsx("input", {
1988
+ value: confirm,
1989
+ onChange: (event) => setConfirm(event.target.value)
2871
1990
  })
2872
1991
  ]
1992
+ }) : null,
1993
+ /* @__PURE__ */ jsx(Button, {
1994
+ variant: "primary",
1995
+ size: "xs",
1996
+ onClick: () => void post({
1997
+ params: recipe.params,
1998
+ token: preview.token,
1999
+ ...recipe.live ? { typedConfirm: confirm } : {}
2000
+ }),
2001
+ children: "run"
2873
2002
  })
2874
2003
  ]
2875
2004
  }),
2876
- /* @__PURE__ */ jsx2("dl", {
2877
- className: "kk-board-facts",
2878
- children: facts.map((fact) => /* @__PURE__ */ jsxs2("div", {
2005
+ state === null ? null : /* @__PURE__ */ jsx("span", {
2006
+ className: "kk-board-state",
2007
+ children: state
2008
+ })
2009
+ ]
2010
+ });
2011
+ }
2012
+ function ActionsPanel({
2013
+ digest,
2014
+ client,
2015
+ recipes,
2016
+ onLaunched
2017
+ }) {
2018
+ const rows = actionLogRows(digest);
2019
+ const enabled = actionPlaneEnabled(digest);
2020
+ return /* @__PURE__ */ jsxs("div", {
2021
+ "data-testid": "actions-panel",
2022
+ children: [
2023
+ enabled ? null : /* @__PURE__ */ jsx(Diagnostic, {
2024
+ title: "Actions are disabled — recipes only",
2025
+ detail: "Set board.actions.enabled: true in ~/.config/kk/config.yaml, then restart the reader, to launch from here.",
2026
+ hint: "Every launch is previewed, confirmed with a single-use token and audited; nothing is sent silently."
2027
+ }),
2028
+ recipes.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
2029
+ children: "This day offered no recipe."
2030
+ }) : /* @__PURE__ */ jsx("ul", {
2031
+ "data-testid": "action-recipes",
2032
+ children: recipes.map((recipe) => /* @__PURE__ */ jsxs("li", {
2879
2033
  children: [
2880
- /* @__PURE__ */ jsx2("dt", {
2881
- children: fact.label
2034
+ /* @__PURE__ */ jsx(RecipeLine, {
2035
+ argv: recipe.argv,
2036
+ label: recipe.label,
2037
+ dryRun: recipe.dryRunArgv
2882
2038
  }),
2883
- /* @__PURE__ */ jsxs2("dd", {
2039
+ enabled ? /* @__PURE__ */ jsx(ActionLauncher, {
2040
+ client,
2041
+ recipe,
2042
+ day: digest.day,
2043
+ onLaunched
2044
+ }) : null
2045
+ ]
2046
+ }, `${recipe.kind}:${recipe.argv.join(" ")}`))
2047
+ }),
2048
+ /* @__PURE__ */ jsx("h2", {
2049
+ children: "Recorded actions"
2050
+ }),
2051
+ rows.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
2052
+ testId: "actions-empty",
2053
+ children: "No action was recorded for this day."
2054
+ }) : /* @__PURE__ */ jsxs("table", {
2055
+ className: "kk-board-action-log",
2056
+ "data-testid": "actions-log",
2057
+ children: [
2058
+ /* @__PURE__ */ jsx("thead", {
2059
+ children: /* @__PURE__ */ jsxs("tr", {
2884
2060
  children: [
2885
- fact.value,
2886
- " ",
2887
- /* @__PURE__ */ jsx2("span", {
2888
- className: "kk-board-state",
2889
- children: fact.availability
2061
+ /* @__PURE__ */ jsx("th", {
2062
+ children: "when"
2063
+ }),
2064
+ /* @__PURE__ */ jsx("th", {
2065
+ children: "kind"
2066
+ }),
2067
+ /* @__PURE__ */ jsx("th", {
2068
+ children: "result"
2069
+ }),
2070
+ /* @__PURE__ */ jsx("th", {
2071
+ children: "argv"
2072
+ }),
2073
+ /* @__PURE__ */ jsx("th", {
2074
+ children: "run"
2890
2075
  })
2891
2076
  ]
2892
2077
  })
2893
- ]
2894
- }, fact.label))
2895
- }),
2896
- config === null ? null : /* @__PURE__ */ jsxs2("details", {
2897
- className: "kk-card",
2898
- "data-testid": "daily-voice-captured-config",
2899
- children: [
2900
- /* @__PURE__ */ jsxs2("summary", {
2901
- children: [
2902
- "Captured configuration",
2903
- " ",
2904
- /* @__PURE__ */ jsx2("span", {
2905
- className: "kk-stat-sub",
2906
- children: config.capturedAt === null ? "capture time not recorded" : `captured ${formatTimestamp(config.capturedAt)}`
2907
- })
2908
- ]
2909
2078
  }),
2910
- /* @__PURE__ */ jsxs2("div", {
2911
- className: "kk-board-config",
2912
- children: [
2913
- /* @__PURE__ */ jsx2("p", {
2914
- children: config.capturedAt === null ? "This run predates capture: its settings are unknown, never today’s defaults." : `Captured ${formatTimestamp(config.capturedAt)}`
2915
- }),
2916
- settings.length === 0 ? /* @__PURE__ */ jsx2("p", {
2917
- children: "No settings were recorded for this run."
2918
- }) : /* @__PURE__ */ jsx2("dl", {
2919
- children: settings.map(([key, value]) => /* @__PURE__ */ jsxs2("div", {
2920
- children: [
2921
- /* @__PURE__ */ jsx2("dt", {
2922
- children: key
2923
- }),
2924
- /* @__PURE__ */ jsx2("dd", {
2925
- children: value
2926
- })
2927
- ]
2928
- }, key))
2929
- }),
2930
- config.unavailableKeys.length === 0 ? null : /* @__PURE__ */ jsxs2("p", {
2931
- children: [
2932
- "Not captured: ",
2933
- /* @__PURE__ */ jsx2("code", {
2934
- children: config.unavailableKeys.join(", ")
2079
+ /* @__PURE__ */ jsx("tbody", {
2080
+ children: rows.map((row) => /* @__PURE__ */ jsxs("tr", {
2081
+ children: [
2082
+ /* @__PURE__ */ jsx("td", {
2083
+ children: formatTimestamp(row.ts)
2084
+ }),
2085
+ /* @__PURE__ */ jsx("td", {
2086
+ children: row.kind
2087
+ }),
2088
+ /* @__PURE__ */ jsx("td", {
2089
+ children: /* @__PURE__ */ jsx(Badge, {
2090
+ variant: TONE_BADGE[row.tone] ?? "neutral",
2091
+ size: "sm",
2092
+ children: row.word
2935
2093
  })
2936
- ]
2937
- }),
2938
- config.definitionDigest === undefined ? null : /* @__PURE__ */ jsxs2("p", {
2939
- children: [
2940
- "Definition digest ",
2941
- /* @__PURE__ */ jsx2("code", {
2942
- children: config.definitionDigest
2094
+ }),
2095
+ /* @__PURE__ */ jsx("td", {
2096
+ children: /* @__PURE__ */ jsx("code", {
2097
+ children: row.argv
2943
2098
  })
2944
- ]
2945
- })
2946
- ]
2099
+ }),
2100
+ /* @__PURE__ */ jsx("td", {
2101
+ children: row.runId === null ? "—" : /* @__PURE__ */ jsx("code", {
2102
+ children: row.runId
2103
+ })
2104
+ })
2105
+ ]
2106
+ }, `${row.ts}:${row.argv}`))
2947
2107
  })
2948
2108
  ]
2949
- }),
2950
- /* @__PURE__ */ jsx2(FunnelPanel, {
2951
- funnel,
2952
- artifacts
2953
- }),
2954
- /* @__PURE__ */ jsx2(SupplyPanel, {
2955
- context,
2956
- supply,
2957
- storeOffline
2958
2109
  })
2959
2110
  ]
2960
2111
  });
2961
2112
  }
2962
- function LegacyChannelList({ channels }) {
2963
- if (channels.length === 0)
2964
- return /* @__PURE__ */ jsx2(EmptyState, {
2965
- children: "No channel outcomes recorded for the selected run."
2113
+ function DailyVoiceConsole({ search }) {
2114
+ const reader = useMemo(() => readerFor(search), [search]);
2115
+ const clientRef = useRef(null);
2116
+ const [location, setLocation] = useState(() => parseConsoleHash(globalThis.location?.hash ?? ""));
2117
+ const [state, setState] = useState(INITIAL);
2118
+ const [fetchedAt, setFetchedAt] = useState(null);
2119
+ if (clientRef.current === null) {
2120
+ clientRef.current = createBoardClient({
2121
+ readerOrigin: reader.origin,
2122
+ boardOrigin: globalThis.location?.origin ?? reader.origin,
2123
+ fetchImpl: fetch
2966
2124
  });
2967
- return /* @__PURE__ */ jsx2("ul", {
2968
- className: "kk-board-channels",
2969
- children: channels.map((channel) => /* @__PURE__ */ jsxs2("li", {
2125
+ }
2126
+ const load = useCallback(async () => {
2127
+ const client = clientRef.current;
2128
+ if (client === null)
2129
+ return;
2130
+ setState((prior) => ({ ...prior, loading: true, error: null }));
2131
+ const until = location.day ?? new Date().toISOString().slice(0, 10).replace(/-/g, "");
2132
+ const range = historyRange(until);
2133
+ try {
2134
+ const days = await client.days(range.from, range.until);
2135
+ const day = location.day ?? days[0]?.day ?? null;
2136
+ const digest = day === null ? null : await client.day(day);
2137
+ setFetchedAt(Date.now());
2138
+ setState({ loading: false, digest, days, error: null, searchedPath: day });
2139
+ if (location.day === null && day !== null)
2140
+ setLocation((prior) => ({ ...prior, day }));
2141
+ } catch (error) {
2142
+ const message = error instanceof Error ? error.message : String(error);
2143
+ setState((prior) => ({
2144
+ loading: false,
2145
+ digest: null,
2146
+ days: prior.days,
2147
+ error: isOfflineError(message) ? "The reader is not answering. Start it with `kk board serve --board-origin <this Board>.`" : message,
2148
+ searchedPath: null
2149
+ }));
2150
+ }
2151
+ }, [location.day]);
2152
+ useEffect(() => {
2153
+ load();
2154
+ }, [load]);
2155
+ useEffect(() => {
2156
+ const next = consoleHash(location.day, location.tab);
2157
+ if (globalThis.location !== undefined && globalThis.location.hash !== next) {
2158
+ globalThis.location.hash = next;
2159
+ }
2160
+ }, [location.day, location.tab]);
2161
+ const recipesFor = useCallback((subject) => state.digest === null ? [] : state.digest.attention.filter((item) => item.subject === subject).flatMap((item) => item.recipes), [state.digest]);
2162
+ const setTab = (tab) => setLocation((prior) => ({ ...prior, tab }));
2163
+ const setDay = (day) => setLocation({ day, tab: "today" });
2164
+ const header = /* @__PURE__ */ jsx(ModuleHeader, {
2165
+ icon: /* @__PURE__ */ jsx("span", {
2166
+ "aria-hidden": "true",
2167
+ children: "◉"
2168
+ }),
2169
+ title: "Daily AI Voice",
2170
+ subtitle: "One day, one episode: generation, publish windows, safety and what needs you.",
2171
+ status: state.digest === null ? null : /* @__PURE__ */ jsx(Badge, {
2172
+ variant: TONE_BADGE[generationFacts(state.digest)[0]?.tone ?? "neutral"],
2173
+ size: "sm",
2174
+ children: generationFacts(state.digest)[0]?.value ?? "unknown"
2175
+ }),
2176
+ filters: /* @__PURE__ */ jsxs("div", {
2177
+ className: "kk-board-day-picker",
2970
2178
  children: [
2971
- /* @__PURE__ */ jsx2("strong", {
2972
- children: channel.label
2179
+ /* @__PURE__ */ jsx("label", {
2180
+ htmlFor: `${CONSOLE_TABS_ID}-day`,
2181
+ children: "day"
2973
2182
  }),
2974
- " — ",
2975
- channel.state,
2976
- channel.detail === null ? null : /* @__PURE__ */ jsxs2("span", {
2977
- className: "kk-board-state",
2183
+ /* @__PURE__ */ jsxs("select", {
2184
+ id: `${CONSOLE_TABS_ID}-day`,
2185
+ value: location.day ?? "",
2186
+ onChange: (event) => setDay(event.target.value),
2978
2187
  children: [
2979
- " (",
2980
- channel.detail,
2981
- ")"
2188
+ state.days.length === 0 && location.day !== null ? /* @__PURE__ */ jsx("option", {
2189
+ value: location.day,
2190
+ children: location.day
2191
+ }) : null,
2192
+ state.days.map((day) => /* @__PURE__ */ jsxs("option", {
2193
+ value: day.day,
2194
+ children: [
2195
+ day.day,
2196
+ " — ",
2197
+ day.status
2198
+ ]
2199
+ }, day.day))
2982
2200
  ]
2983
2201
  }),
2984
- channel.url === null ? null : /* @__PURE__ */ jsxs2(Fragment, {
2202
+ /* @__PURE__ */ jsx(Button, {
2203
+ variant: "ghost",
2204
+ size: "xs",
2205
+ onClick: () => void load(),
2206
+ children: "Reload"
2207
+ })
2208
+ ]
2209
+ }),
2210
+ tabs: /* @__PURE__ */ jsx(ModuleTabs, {
2211
+ tabs: CONSOLE_TABS.map((id) => ({ id, label: CONSOLE_TAB_LABELS[id] })),
2212
+ value: location.tab,
2213
+ onChange: (id) => setTab(id),
2214
+ label: "Daily AI Voice views",
2215
+ idPrefix: CONSOLE_TABS_ID
2216
+ })
2217
+ });
2218
+ return /* @__PURE__ */ jsx("div", {
2219
+ className: "kk-board kk-board-daily-voice",
2220
+ children: /* @__PURE__ */ jsxs(ModuleShell, {
2221
+ children: [
2222
+ header,
2223
+ reader.diagnostic === null ? null : /* @__PURE__ */ jsx(Diagnostic, {
2224
+ title: "Reader origin ignored",
2225
+ detail: reader.diagnostic.message,
2226
+ code: reader.diagnostic.code
2227
+ }),
2228
+ state.error === null ? null : /* @__PURE__ */ jsx(Diagnostic, {
2229
+ title: "The day could not be read",
2230
+ detail: state.error,
2231
+ code: state.searchedPath === null ? undefined : `day ${state.searchedPath}`,
2232
+ hint: "A day with no directory answers 404 and names the path it looked up."
2233
+ }),
2234
+ state.loading ? /* @__PURE__ */ jsx(Loading, {
2235
+ size: "sm"
2236
+ }) : null,
2237
+ /* @__PURE__ */ jsx("div", {
2238
+ role: "tabpanel",
2239
+ id: `${CONSOLE_TABS_ID}-panel-${location.tab}`,
2240
+ children: state.digest === null ? state.loading ? null : /* @__PURE__ */ jsx(EmptyState, {
2241
+ testId: "no-day",
2242
+ children: "No day is selected. Pick one from the day picker, or open History."
2243
+ }) : location.tab === "today" ? /* @__PURE__ */ jsx(TodayPanel, {
2244
+ digest: state.digest,
2245
+ onRefresh: () => void load(),
2246
+ fetchedAt
2247
+ }) : location.tab === "generation" ? /* @__PURE__ */ jsx(GenerationPanel, {
2248
+ digest: state.digest,
2249
+ client: clientRef.current,
2250
+ recipes: recipesFor
2251
+ }) : location.tab === "publishing" ? /* @__PURE__ */ jsx(PublishingPanel, {
2252
+ digest: state.digest,
2253
+ recipes: recipesFor
2254
+ }) : location.tab === "history" ? /* @__PURE__ */ jsx(HistoryPanel, {
2255
+ days: state.days,
2256
+ selected: location.day,
2257
+ onSelect: setDay
2258
+ }) : /* @__PURE__ */ jsx(ActionsPanel, {
2259
+ digest: state.digest,
2260
+ client: clientRef.current,
2261
+ recipes: state.digest.attention.flatMap((item) => item.recipes),
2262
+ onLaunched: () => void load()
2263
+ })
2264
+ }),
2265
+ /* @__PURE__ */ jsxs("p", {
2266
+ className: "kk-board-state",
2985
2267
  children: [
2268
+ "Day projection shared with ",
2269
+ /* @__PURE__ */ jsx("code", {
2270
+ children: "kk news digest"
2271
+ }),
2272
+ " ·",
2986
2273
  " ",
2987
- /* @__PURE__ */ jsx2("a", {
2988
- href: channel.url,
2989
- rel: "noreferrer",
2990
- children: "open"
2274
+ /* @__PURE__ */ jsx("a", {
2275
+ href: withBase("/board/settings/workflows"),
2276
+ children: "Settings → Workflows"
2991
2277
  })
2992
2278
  ]
2993
2279
  })
2994
2280
  ]
2995
- }, channel.channel))
2996
- });
2997
- }
2998
- function LegacyResultsPanel({ artifacts, channels }) {
2999
- if (artifacts.length === 0)
3000
- return /* @__PURE__ */ jsx2(EmptyState, {
3001
- children: "No artifact evidence for the selected run."
3002
- });
3003
- const media = artifacts.filter((artifact) => artifact.kind === "image" || artifact.kind === "audio");
3004
- const files = artifacts.filter((artifact) => artifact.kind !== "image" && artifact.kind !== "audio");
3005
- return /* @__PURE__ */ jsxs2("div", {
3006
- className: "kk-board-results",
3007
- children: [
3008
- media.map((artifact) => artifact.href === null ? /* @__PURE__ */ jsxs2("p", {
3009
- children: [
3010
- artifact.label,
3011
- " — ",
3012
- artifact.state
3013
- ]
3014
- }, artifact.id) : artifact.kind === "audio" ? /* @__PURE__ */ jsxs2("p", {
3015
- children: [
3016
- /* @__PURE__ */ jsx2("audio", {
3017
- controls: true,
3018
- src: artifact.href,
3019
- children: /* @__PURE__ */ jsx2("track", {
3020
- kind: "captions"
3021
- })
3022
- }),
3023
- /* @__PURE__ */ jsxs2("a", {
3024
- href: artifact.href,
3025
- download: true,
3026
- children: [
3027
- "download ",
3028
- artifact.label
3029
- ]
3030
- }),
3031
- " ",
3032
- "— ",
3033
- artifact.state
3034
- ]
3035
- }, artifact.id) : /* @__PURE__ */ jsxs2("p", {
3036
- children: [
3037
- /* @__PURE__ */ jsx2("img", {
3038
- src: artifact.href,
3039
- alt: artifact.label
3040
- }),
3041
- " ",
3042
- artifact.label,
3043
- " — ",
3044
- artifact.state
3045
- ]
3046
- }, artifact.id)),
3047
- /* @__PURE__ */ jsx2("ul", {
3048
- className: "kk-board-artifacts",
3049
- children: files.map((artifact) => /* @__PURE__ */ jsx2("li", {
3050
- children: artifact.href === null ? /* @__PURE__ */ jsxs2("span", {
3051
- children: [
3052
- artifact.label,
3053
- " — ",
3054
- artifact.state
3055
- ]
3056
- }) : /* @__PURE__ */ jsxs2("a", {
3057
- href: artifact.href,
3058
- children: [
3059
- artifact.label,
3060
- " — ",
3061
- artifact.state
3062
- ]
3063
- })
3064
- }, artifact.id))
3065
- }),
3066
- /* @__PURE__ */ jsx2(LegacyChannelList, {
3067
- channels
3068
- })
3069
- ]
2281
+ })
3070
2282
  });
3071
2283
  }
3072
- function LegacyProgressPanel({ progress }) {
3073
- if (progress === null || progress.nodes.length === 0) {
3074
- return /* @__PURE__ */ jsx2(EmptyState, {
3075
- children: "Recorded progress is unavailable for the selected run."
3076
- });
3077
- }
3078
- return /* @__PURE__ */ jsxs2("div", {
3079
- className: "kk-board-progress",
3080
- children: [
3081
- /* @__PURE__ */ jsx2("ul", {
3082
- children: progress.nodes.map((node) => /* @__PURE__ */ jsxs2("li", {
3083
- children: [
3084
- /* @__PURE__ */ jsx2("strong", {
3085
- children: node.id
3086
- }),
3087
- " — ",
3088
- node.status,
3089
- " · ",
3090
- node.timing,
3091
- node.attempts > 1 ? /* @__PURE__ */ jsxs2("span", {
3092
- className: "kk-board-state",
3093
- children: [
3094
- " ",
3095
- node.attempts,
3096
- " attempts"
3097
- ]
3098
- }) : null
3099
- ]
3100
- }, node.id))
3101
- }),
3102
- progress.edgesKnown && progress.edges !== null ? /* @__PURE__ */ jsx2("ul", {
3103
- className: "kk-board-edges",
3104
- children: progress.edges.map((edge) => /* @__PURE__ */ jsxs2("li", {
3105
- children: [
3106
- edge.from,
3107
- " → ",
3108
- edge.to
3109
- ]
3110
- }, `${edge.from}->${edge.to}`))
3111
- }) : /* @__PURE__ */ jsxs2("p", {
3112
- children: [
3113
- "Dependency edges are unknown — no digest-verified topology was captured. See",
3114
- " ",
3115
- /* @__PURE__ */ jsx2("a", {
3116
- href: withBase("/board/settings/workflows"),
3117
- children: "Settings → Workflows"
3118
- }),
3119
- " for the current graph."
3120
- ]
3121
- }),
3122
- progress.childRunId === null ? null : /* @__PURE__ */ jsxs2("p", {
3123
- children: [
3124
- "Nested safety run: ",
3125
- /* @__PURE__ */ jsx2("code", {
3126
- children: progress.childRunId
3127
- })
3128
- ]
3129
- })
3130
- ]
2284
+ function DailyVoiceModule() {
2285
+ const search = globalThis.location?.search ?? "";
2286
+ return /* @__PURE__ */ jsx(DailyVoiceConsole, {
2287
+ search
3131
2288
  });
3132
2289
  }
3133
2290
  var webModule = { apiVersion: 1, component: DailyVoiceModule };
2291
+ var modulePath = MODULE_PATH;
3134
2292
  export {
3135
2293
  DailyVoiceModule,
2294
+ modulePath,
3136
2295
  webModule
3137
2296
  };