@ouro.bot/cli 0.1.0-alpha.936 → 0.1.0-alpha.938

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.json CHANGED
@@ -1,6 +1,23 @@
1
1
  {
2
2
  "_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.938",
6
+ "changes": [
7
+ "Shepherd rejects provider-filtered, refused or incomplete judgments before parsing or input, and retains safe completion metadata without refusal text or bypassing provider safeguards.",
8
+ "Judge evaluation reports explicit provider and malformed-answer error codes plus known failed-call input usage without classification credit; native admission and full v1 remain unqualified."
9
+ ]
10
+ },
11
+ {
12
+ "version": "0.1.0-alpha.937",
13
+ "changes": [
14
+ "Add an explicit tool-free Shepherd judge evaluation command with a frozen 160-case corpus, three repetitions, unique-case metrics and private progress reports.",
15
+ "Reject malformed judge answers from classification credit, require safe text for continuation recall, and report output failures without claiming successful persistence.",
16
+ "Refuse model-selected menu, navigation and control keys before custody on every automatic trigger; keep explicit owner-requested keys separate and use a text-only judge rubric.",
17
+ "Keep remaining legacy text automation visibly unqualified: stored mandates do not yet govern every trigger, and native guarded input and full Shepherd v1 remain open gates.",
18
+ "Preserve meaningful sanitized error context for evaluation argument, output and entry failures."
19
+ ]
20
+ },
4
21
  {
5
22
  "version": "0.1.0-alpha.936",
6
23
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.936",
2
+ "runtimeVersion": "0.1.0-alpha.938",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <Container version="2">
3
3
  <Name>ouro-butler</Name>
4
- <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.936</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.938</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -7,7 +7,7 @@ exports.SHEPHERD_SUPERVISION_LIMIT = 200;
7
7
  exports.SHEPHERD_SUPERVISION_STALE_MS = 30_000;
8
8
  exports.SHEPHERD_OBSERVATION_FILE = "supervision-observation.json";
9
9
  exports.SHEPHERD_OBSERVATION_MAX_BYTES = 2 * 1024 * 1024;
10
- exports.SHEPHERD_ALPHA_AUTOMATION_WARNING = "This alpha retains unqualified legacy automation. Legacy immediate/network automation may still type or press keys without mandate enforcement. Absent or revoked mandates do not disable those paths. Disable Shepherd to stop legacy automation.";
10
+ exports.SHEPHERD_ALPHA_AUTOMATION_WARNING = "This alpha retains unqualified legacy automation. Legacy immediate/network automation may still type text without mandate enforcement. Automatic keys are refused. Absent or revoked mandates do not disable those text paths. Disable Shepherd to stop legacy automation.";
11
11
  exports.SHEPHERD_SUPERVISION_SOURCES = ["host", "guidance", "mandates", "returns", "custody", "notices"];
12
12
  function freshness(at, nowMs) {
13
13
  const ageMs = at === null ? NaN : nowMs - Date.parse(at);
@@ -581,6 +581,8 @@ async function streamChatCompletion(client, createParams, callbacks, signal, eag
581
581
  let toolCalls = {};
582
582
  let streamStarted = false;
583
583
  let usage;
584
+ let finishReason = null;
585
+ let refused = false;
584
586
  const answerStreamer = new SettleStreamer(callbacks, eagerSettleStreaming);
585
587
  const textOutput = new ProviderTextOutput(callbacks);
586
588
  // State machine for parsing inline <think> tags (MiniMax pattern)
@@ -666,7 +668,26 @@ async function streamChatCompletion(client, createParams, callbacks, signal, eag
666
668
  total_tokens: u.total_tokens,
667
669
  };
668
670
  }
669
- const d = chunk.choices[0]?.delta;
671
+ const choice = chunk.choices[0];
672
+ if (choice?.finish_reason != null) {
673
+ let reason;
674
+ switch (choice.finish_reason) {
675
+ case "stop":
676
+ case "length":
677
+ case "content_filter":
678
+ case "tool_calls":
679
+ case "function_call":
680
+ reason = choice.finish_reason;
681
+ break;
682
+ default:
683
+ reason = "unknown";
684
+ }
685
+ if (finishReason === null || finishReason === "stop" || reason === "content_filter")
686
+ finishReason = reason;
687
+ }
688
+ if (choice?.delta?.refusal)
689
+ refused = true;
690
+ const d = choice?.delta;
670
691
  if (!d)
671
692
  continue;
672
693
  // Handle reasoning_content (Azure AI models like DeepSeek-R1)
@@ -749,6 +770,7 @@ async function streamChatCompletion(client, createParams, callbacks, signal, eag
749
770
  toolCalls: completedToolCalls,
750
771
  outputItems: [],
751
772
  usage,
773
+ ...(finishReason !== null || refused ? { termination: { finishReason, refused } } : {}),
752
774
  settleStreamed: answerStreamer.streamed,
753
775
  ...(settleFinalization ? { settleFinalization } : {}),
754
776
  };
@@ -0,0 +1 @@
1
+ import{r as l,j as e,b as ut,c as H,L as pe,m as Qe,a as Ke,h as xt,d as mt,z as ht,y as Ze,e as pt}from"./vendor-CcN1XpQ9.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const d of o.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function a(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();const Je="/api";async function L(t,s){const n=await fetch(`${Je}${t}`,{headers:{accept:"application/json"},signal:s==null?void 0:s.signal});if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);return n.json()}function gt(t,s){const n=new EventSource(`${Je}/events`);let a=!1;s==null||s("connecting");const r=o=>{if(!(a||!(o instanceof MessageEvent)))try{const d=JSON.parse(o.data);t("state-changed",d)}catch{t("state-changed",{})}};return n.addEventListener("state-changed",r),n.onopen=()=>{a||(s==null||s("connected"),t("connected",{}))},n.onerror=()=>{a||s==null||s("reconnecting")},()=>{a=!0,n.removeEventListener("state-changed",r),n.onopen=null,n.onerror=null,n.close()}}function M(t){if(!t)return"unknown";const s=Date.now()-new Date(t).getTime();return s<0||s<6e4?"just now":s<36e5?`${Math.floor(s/6e4)}m ago`:s<864e5?`${Math.floor(s/36e5)}h ago`:`${Math.floor(s/864e5)}d ago`}function _(t,s){if(!t)return"";if(t.length<=s)return t;const n=t.lastIndexOf(" ",s);return(n>s*.6?t.slice(0,n):t.slice(0,s))+"…"}const Ye=l.createContext(()=>{});function X(){return l.useContext(Ye)}const ft=new Set(["overview","mail","sessions","work","connections","inner","notes","runtime"]);function Xe(t){const s=t.replace(/^#\/?/,"");if(!s.startsWith("agent/"))return null;const n=s.split("/"),a=n[1]?decodeURIComponent(n[1]):"";if(!a)return null;const r=n[2]??"overview",o=ft.has(r)?r:"overview",d=n.slice(3),b=d.length>0?d.map(decodeURIComponent).join("/"):void 0;return{agent:a,tab:o,focus:b}}function Ce(t){let s=`#/agent/${encodeURIComponent(t.agent)}`;return(t.tab!=="overview"||t.focus)&&(s+=`/${t.tab}`),t.focus&&(s+=`/${t.focus.split("/").map(encodeURIComponent).join("/")}`),s}function Te(t){const s=t.replace(/^#\/?/,"").split("/");if(s[0]!=="supervision"||s.length>3)return null;try{const n=s[1]?decodeURIComponent(s[1]):null;return n&&!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(n)?null:{agent:n,...s[2]?{focus:decodeURIComponent(s[2])}:{}}}catch{return null}}function bt(t,s){return`#/supervision${t?`/${encodeURIComponent(t)}`:""}`}const ge=l.forwardRef(function(s,n){return e.jsx(ut,{children:e.jsx("a",{...s,ref:n})})}),ee={base:["relative isolate inline-flex items-baseline justify-center gap-x-2 rounded-lg border text-base/6 font-semibold","px-[calc(--spacing(3.5)-1px)] py-[calc(--spacing(2.5)-1px)] sm:px-[calc(--spacing(3)-1px)] sm:py-[calc(--spacing(1.5)-1px)] sm:text-sm/6","focus:not-data-focus:outline-hidden data-focus:outline-2 data-focus:outline-offset-2 data-focus:outline-blue-500","data-disabled:opacity-50","*:data-[slot=icon]:-mx-0.5 *:data-[slot=icon]:my-0.5 *:data-[slot=icon]:size-5 *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:self-center *:data-[slot=icon]:text-(--btn-icon) sm:*:data-[slot=icon]:my-1 sm:*:data-[slot=icon]:size-4 forced-colors:[--btn-icon:ButtonText] forced-colors:data-hover:[--btn-icon:ButtonText]"],solid:["border-transparent bg-(--btn-border)","dark:bg-(--btn-bg)","before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-lg)-1px)] before:bg-(--btn-bg)","before:shadow-sm","dark:before:hidden","dark:border-white/5","after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-lg)-1px)]","after:shadow-[inset_0_1px_--theme(--color-white/15%)]","data-active:after:bg-(--btn-hover-overlay) data-hover:after:bg-(--btn-hover-overlay)","dark:after:-inset-px dark:after:rounded-lg","data-disabled:before:shadow-none data-disabled:after:shadow-none"],outline:["border-zinc-950/10 text-zinc-950 data-active:bg-zinc-950/2.5 data-hover:bg-zinc-950/2.5","dark:border-white/15 dark:text-white dark:[--btn-bg:transparent] dark:data-active:bg-white/5 dark:data-hover:bg-white/5","[--btn-icon:var(--color-zinc-500)] data-active:[--btn-icon:var(--color-zinc-700)] data-hover:[--btn-icon:var(--color-zinc-700)] dark:data-active:[--btn-icon:var(--color-zinc-400)] dark:data-hover:[--btn-icon:var(--color-zinc-400)]"],plain:["border-transparent text-zinc-950 data-active:bg-zinc-950/5 data-hover:bg-zinc-950/5","dark:text-white dark:data-active:bg-white/10 dark:data-hover:bg-white/10","[--btn-icon:var(--color-zinc-500)] data-active:[--btn-icon:var(--color-zinc-700)] data-hover:[--btn-icon:var(--color-zinc-700)] dark:[--btn-icon:var(--color-zinc-500)] dark:data-active:[--btn-icon:var(--color-zinc-400)] dark:data-hover:[--btn-icon:var(--color-zinc-400)]"],colors:{"dark/zinc":["text-white [--btn-bg:var(--color-zinc-900)] [--btn-border:var(--color-zinc-950)]/90 [--btn-hover-overlay:var(--color-white)]/10","dark:text-white dark:[--btn-bg:var(--color-zinc-600)] dark:[--btn-hover-overlay:var(--color-white)]/5","[--btn-icon:var(--color-zinc-400)] data-active:[--btn-icon:var(--color-zinc-300)] data-hover:[--btn-icon:var(--color-zinc-300)]"],light:["text-zinc-950 [--btn-bg:white] [--btn-border:var(--color-zinc-950)]/10 [--btn-hover-overlay:var(--color-zinc-950)]/2.5 data-active:[--btn-border:var(--color-zinc-950)]/15 data-hover:[--btn-border:var(--color-zinc-950)]/15","dark:text-white dark:[--btn-hover-overlay:var(--color-white)]/5 dark:[--btn-bg:var(--color-zinc-800)]","[--btn-icon:var(--color-zinc-500)] data-active:[--btn-icon:var(--color-zinc-700)] data-hover:[--btn-icon:var(--color-zinc-700)] dark:[--btn-icon:var(--color-zinc-500)] dark:data-active:[--btn-icon:var(--color-zinc-400)] dark:data-hover:[--btn-icon:var(--color-zinc-400)]"],"dark/white":["text-white [--btn-bg:var(--color-zinc-900)] [--btn-border:var(--color-zinc-950)]/90 [--btn-hover-overlay:var(--color-white)]/10","dark:text-zinc-950 dark:[--btn-bg:white] dark:[--btn-hover-overlay:var(--color-zinc-950)]/5","[--btn-icon:var(--color-zinc-400)] data-active:[--btn-icon:var(--color-zinc-300)] data-hover:[--btn-icon:var(--color-zinc-300)] dark:[--btn-icon:var(--color-zinc-500)] dark:data-active:[--btn-icon:var(--color-zinc-400)] dark:data-hover:[--btn-icon:var(--color-zinc-400)]"],dark:["text-white [--btn-bg:var(--color-zinc-900)] [--btn-border:var(--color-zinc-950)]/90 [--btn-hover-overlay:var(--color-white)]/10","dark:[--btn-hover-overlay:var(--color-white)]/5 dark:[--btn-bg:var(--color-zinc-800)]","[--btn-icon:var(--color-zinc-400)] data-active:[--btn-icon:var(--color-zinc-300)] data-hover:[--btn-icon:var(--color-zinc-300)]"],white:["text-zinc-950 [--btn-bg:white] [--btn-border:var(--color-zinc-950)]/10 [--btn-hover-overlay:var(--color-zinc-950)]/2.5 data-active:[--btn-border:var(--color-zinc-950)]/15 data-hover:[--btn-border:var(--color-zinc-950)]/15","dark:[--btn-hover-overlay:var(--color-zinc-950)]/5","[--btn-icon:var(--color-zinc-400)] data-active:[--btn-icon:var(--color-zinc-500)] data-hover:[--btn-icon:var(--color-zinc-500)]"],zinc:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-zinc-600)] [--btn-border:var(--color-zinc-700)]/90","dark:[--btn-hover-overlay:var(--color-white)]/5","[--btn-icon:var(--color-zinc-400)] data-active:[--btn-icon:var(--color-zinc-300)] data-hover:[--btn-icon:var(--color-zinc-300)]"],indigo:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-indigo-500)] [--btn-border:var(--color-indigo-600)]/90","[--btn-icon:var(--color-indigo-300)] data-active:[--btn-icon:var(--color-indigo-200)] data-hover:[--btn-icon:var(--color-indigo-200)]"],cyan:["text-cyan-950 [--btn-bg:var(--color-cyan-300)] [--btn-border:var(--color-cyan-400)]/80 [--btn-hover-overlay:var(--color-white)]/25","[--btn-icon:var(--color-cyan-500)]"],red:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-red-600)] [--btn-border:var(--color-red-700)]/90","[--btn-icon:var(--color-red-300)] data-active:[--btn-icon:var(--color-red-200)] data-hover:[--btn-icon:var(--color-red-200)]"],orange:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-orange-500)] [--btn-border:var(--color-orange-600)]/90","[--btn-icon:var(--color-orange-300)] data-active:[--btn-icon:var(--color-orange-200)] data-hover:[--btn-icon:var(--color-orange-200)]"],amber:["text-amber-950 [--btn-hover-overlay:var(--color-white)]/25 [--btn-bg:var(--color-amber-400)] [--btn-border:var(--color-amber-500)]/80","[--btn-icon:var(--color-amber-600)]"],yellow:["text-yellow-950 [--btn-hover-overlay:var(--color-white)]/25 [--btn-bg:var(--color-yellow-300)] [--btn-border:var(--color-yellow-400)]/80","[--btn-icon:var(--color-yellow-600)] data-active:[--btn-icon:var(--color-yellow-700)] data-hover:[--btn-icon:var(--color-yellow-700)]"],lime:["text-lime-950 [--btn-hover-overlay:var(--color-white)]/25 [--btn-bg:var(--color-lime-300)] [--btn-border:var(--color-lime-400)]/80","[--btn-icon:var(--color-lime-600)] data-active:[--btn-icon:var(--color-lime-700)] data-hover:[--btn-icon:var(--color-lime-700)]"],green:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-green-600)] [--btn-border:var(--color-green-700)]/90","[--btn-icon:var(--color-white)]/60 data-active:[--btn-icon:var(--color-white)]/80 data-hover:[--btn-icon:var(--color-white)]/80"],emerald:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-emerald-600)] [--btn-border:var(--color-emerald-700)]/90","[--btn-icon:var(--color-white)]/60 data-active:[--btn-icon:var(--color-white)]/80 data-hover:[--btn-icon:var(--color-white)]/80"],teal:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-teal-600)] [--btn-border:var(--color-teal-700)]/90","[--btn-icon:var(--color-white)]/60 data-active:[--btn-icon:var(--color-white)]/80 data-hover:[--btn-icon:var(--color-white)]/80"],sky:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-sky-500)] [--btn-border:var(--color-sky-600)]/80","[--btn-icon:var(--color-white)]/60 data-active:[--btn-icon:var(--color-white)]/80 data-hover:[--btn-icon:var(--color-white)]/80"],blue:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-blue-600)] [--btn-border:var(--color-blue-700)]/90","[--btn-icon:var(--color-blue-400)] data-active:[--btn-icon:var(--color-blue-300)] data-hover:[--btn-icon:var(--color-blue-300)]"],violet:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-violet-500)] [--btn-border:var(--color-violet-600)]/90","[--btn-icon:var(--color-violet-300)] data-active:[--btn-icon:var(--color-violet-200)] data-hover:[--btn-icon:var(--color-violet-200)]"],purple:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-purple-500)] [--btn-border:var(--color-purple-600)]/90","[--btn-icon:var(--color-purple-300)] data-active:[--btn-icon:var(--color-purple-200)] data-hover:[--btn-icon:var(--color-purple-200)]"],fuchsia:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-fuchsia-500)] [--btn-border:var(--color-fuchsia-600)]/90","[--btn-icon:var(--color-fuchsia-300)] data-active:[--btn-icon:var(--color-fuchsia-200)] data-hover:[--btn-icon:var(--color-fuchsia-200)]"],pink:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-pink-500)] [--btn-border:var(--color-pink-600)]/90","[--btn-icon:var(--color-pink-300)] data-active:[--btn-icon:var(--color-pink-200)] data-hover:[--btn-icon:var(--color-pink-200)]"],rose:["text-white [--btn-hover-overlay:var(--color-white)]/10 [--btn-bg:var(--color-rose-500)] [--btn-border:var(--color-rose-600)]/90","[--btn-icon:var(--color-rose-300)] data-active:[--btn-icon:var(--color-rose-200)] data-hover:[--btn-icon:var(--color-rose-200)]"]}};l.forwardRef(function({color:s,outline:n,plain:a,className:r,children:o,...d},b){let x=H(r,ee.base,n?ee.outline:a?ee.plain:H(ee.solid,ee.colors[s??"dark/zinc"]));return typeof d.href=="string"?e.jsx(ge,{...d,className:x,ref:b,children:e.jsx(V,{children:o})}):e.jsx(pe,{...d,className:H(x,"cursor-default"),ref:b,children:e.jsx(V,{children:o})})});function V({children:t}){return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute top-1/2 left-1/2 size-[max(100%,2.75rem)] -translate-x-1/2 -translate-y-1/2 pointer-fine:hidden","aria-hidden":"true"}),t]})}function vt({className:t,...s}){return e.jsx("nav",{...s,className:H(t,"flex flex-1 items-center gap-4 py-2.5")})}function jt({className:t,...s}){let n=l.useId();return e.jsx(Ke,{id:n,children:e.jsx("div",{...s,className:H(t,"flex items-center gap-3")})})}function wt({className:t,...s}){return e.jsx("div",{"aria-hidden":"true",...s,className:H(t,"-ml-4 flex-1")})}const $e=l.forwardRef(function({current:s,className:n,children:a,...r},o){let d=H("relative flex min-w-0 items-center gap-3 rounded-lg p-2 text-left text-base/6 font-medium text-zinc-950 sm:text-sm/5","*:data-[slot=icon]:size-6 *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:fill-zinc-500 sm:*:data-[slot=icon]:size-5","*:not-nth-2:last:data-[slot=icon]:ml-auto *:not-nth-2:last:data-[slot=icon]:size-5 sm:*:not-nth-2:last:data-[slot=icon]:size-4","*:data-[slot=avatar]:-m-0.5 *:data-[slot=avatar]:size-7 *:data-[slot=avatar]:[--avatar-radius:var(--radius-md)] sm:*:data-[slot=avatar]:size-6","data-hover:bg-zinc-950/5 data-hover:*:data-[slot=icon]:fill-zinc-950","data-active:bg-zinc-950/5 data-active:*:data-[slot=icon]:fill-zinc-950","dark:text-white dark:*:data-[slot=icon]:fill-zinc-400","dark:data-hover:bg-white/5 dark:data-hover:*:data-[slot=icon]:fill-white","dark:data-active:bg-white/5 dark:data-active:*:data-[slot=icon]:fill-white");return e.jsxs("span",{className:H(n,"relative"),children:[s&&e.jsx(Qe.span,{layoutId:"current-indicator",className:"absolute inset-x-2 -bottom-2.5 h-0.5 rounded-full bg-zinc-950 dark:bg-white"}),typeof r.href=="string"?e.jsx(ge,{...r,className:d,"data-current":s?"true":void 0,ref:o,children:e.jsx(V,{children:a})}):e.jsx(pe,{...r,className:H("cursor-default",d),"data-current":s?"true":void 0,ref:o,children:e.jsx(V,{children:a})})]})});function Nt(){return e.jsx("svg",{"data-slot":"icon",viewBox:"0 0 20 20","aria-hidden":"true",children:e.jsx("path",{d:"M2 6.75C2 6.33579 2.33579 6 2.75 6H17.25C17.6642 6 18 6.33579 18 6.75C18 7.16421 17.6642 7.5 17.25 7.5H2.75C2.33579 7.5 2 7.16421 2 6.75ZM2 13.25C2 12.8358 2.33579 12.5 2.75 12.5H17.25C17.6642 12.5 18 12.8358 18 13.25C18 13.6642 17.6642 14 17.25 14H2.75C2.33579 14 2 13.6642 2 13.25Z"})})}function yt(){return e.jsx("svg",{"data-slot":"icon",viewBox:"0 0 20 20","aria-hidden":"true",children:e.jsx("path",{d:"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z"})})}function kt({open:t,close:s,children:n}){return e.jsxs(xt,{open:t,onClose:s,className:"lg:hidden",children:[e.jsx(mt,{transition:!0,className:"fixed inset-0 bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in"}),e.jsx(ht,{transition:!0,className:"fixed inset-y-0 w-full max-w-80 p-2 transition duration-300 ease-in-out data-closed:-translate-x-full",children:e.jsxs("div",{className:"flex h-full flex-col rounded-lg bg-ouro-deep shadow-xl ring-1 ring-ouro-moss/40",children:[e.jsx("div",{className:"-mb-3 px-4 pt-3",children:e.jsx(Ze,{as:$e,"aria-label":"Close navigation",children:e.jsx(yt,{})})}),n]})})]})}function Ct({navbar:t,sidebar:s,children:n}){let[a,r]=l.useState(!1);return e.jsxs("div",{className:"relative isolate flex min-h-svh w-full bg-ouro-void max-lg:flex-col",children:[e.jsx("div",{className:"fixed inset-y-0 left-0 w-64 max-lg:hidden border-r border-zinc-200 dark:border-ouro-moss/30",children:s}),e.jsx(kt,{open:a,close:()=>r(!1),children:s}),e.jsxs("header",{className:"flex items-center px-4 lg:hidden",children:[e.jsx("div",{className:"py-2.5",children:e.jsx($e,{onClick:()=>r(!0),"aria-label":"Open navigation",children:e.jsx(Nt,{})})}),e.jsx("div",{className:"min-w-0 flex-1",children:t})]}),e.jsx("main",{className:"flex flex-1 flex-col lg:min-w-0 lg:pl-64",children:e.jsx("div",{className:"grow bg-ouro-deep p-4 lg:p-8",children:e.jsx("div",{className:"mx-auto max-w-6xl",children:n})})})]})}function St({className:t,...s}){return e.jsx("nav",{...s,className:H(t,"flex h-full min-h-0 flex-col")})}function $t({className:t,...s}){return e.jsx("div",{...s,className:H(t,"flex flex-col border-b border-zinc-950/5 p-4 dark:border-white/5 [&>[data-slot=section]+[data-slot=section]]:mt-2.5")})}function At({className:t,...s}){return e.jsx("div",{...s,className:H(t,"flex flex-1 flex-col overflow-y-auto p-4 [&>[data-slot=section]+[data-slot=section]]:mt-8")})}function Rt({className:t,...s}){return e.jsx("div",{...s,className:H(t,"flex flex-col border-t border-zinc-950/5 p-4 dark:border-white/5 [&>[data-slot=section]+[data-slot=section]]:mt-2.5")})}function Ee({className:t,...s}){let n=l.useId();return e.jsx(Ke,{id:n,children:e.jsx("div",{...s,"data-slot":"section",className:H(t,"flex flex-col gap-0.5")})})}function Le({className:t,...s}){return e.jsx("h3",{...s,className:H(t,"mb-1 px-2 text-xs/6 font-medium text-zinc-500 dark:text-zinc-400")})}const Oe=l.forwardRef(function({current:s,className:n,children:a,...r},o){let d=H("flex w-full items-center gap-3 rounded-lg px-2 py-2.5 text-left text-base/6 font-medium text-zinc-950 sm:py-2 sm:text-sm/5","*:data-[slot=icon]:size-6 *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:fill-zinc-500 sm:*:data-[slot=icon]:size-5","*:last:data-[slot=icon]:ml-auto *:last:data-[slot=icon]:size-5 sm:*:last:data-[slot=icon]:size-4","*:data-[slot=avatar]:-m-0.5 *:data-[slot=avatar]:size-7 sm:*:data-[slot=avatar]:size-6","data-hover:bg-zinc-950/5 data-hover:*:data-[slot=icon]:fill-zinc-950","data-active:bg-zinc-950/5 data-active:*:data-[slot=icon]:fill-zinc-950","data-current:*:data-[slot=icon]:fill-zinc-950","dark:text-white dark:*:data-[slot=icon]:fill-zinc-400","dark:data-hover:bg-white/5 dark:data-hover:*:data-[slot=icon]:fill-white","dark:data-active:bg-white/5 dark:data-active:*:data-[slot=icon]:fill-white","dark:data-current:*:data-[slot=icon]:fill-white");return e.jsxs("span",{className:H(n,"relative"),children:[s&&e.jsx(Qe.span,{layoutId:"current-indicator",className:"absolute inset-y-2 -left-4 w-0.5 rounded-full bg-zinc-950 dark:bg-white"}),typeof r.href=="string"?e.jsx(Ze,{as:ge,...r,className:d,"data-current":s?"true":void 0,ref:o,children:e.jsx(V,{children:a})}):e.jsx(pe,{...r,className:H("cursor-default",d),"data-current":s?"true":void 0,ref:o,children:e.jsx(V,{children:a})})]})});function Me({className:t,...s}){return e.jsx("span",{...s,className:H(t,"truncate")})}const zt={red:"bg-red-500/15 text-red-700 group-data-hover:bg-red-500/25 dark:bg-red-500/10 dark:text-red-400 dark:group-data-hover:bg-red-500/20",orange:"bg-orange-500/15 text-orange-700 group-data-hover:bg-orange-500/25 dark:bg-orange-500/10 dark:text-orange-400 dark:group-data-hover:bg-orange-500/20",amber:"bg-amber-400/20 text-amber-700 group-data-hover:bg-amber-400/30 dark:bg-amber-400/10 dark:text-amber-400 dark:group-data-hover:bg-amber-400/15",yellow:"bg-yellow-400/20 text-yellow-700 group-data-hover:bg-yellow-400/30 dark:bg-yellow-400/10 dark:text-yellow-300 dark:group-data-hover:bg-yellow-400/15",lime:"bg-lime-400/20 text-lime-700 group-data-hover:bg-lime-400/30 dark:bg-lime-400/10 dark:text-lime-300 dark:group-data-hover:bg-lime-400/15",green:"bg-green-500/15 text-green-700 group-data-hover:bg-green-500/25 dark:bg-green-500/10 dark:text-green-400 dark:group-data-hover:bg-green-500/20",emerald:"bg-emerald-500/15 text-emerald-700 group-data-hover:bg-emerald-500/25 dark:bg-emerald-500/10 dark:text-emerald-400 dark:group-data-hover:bg-emerald-500/20",teal:"bg-teal-500/15 text-teal-700 group-data-hover:bg-teal-500/25 dark:bg-teal-500/10 dark:text-teal-300 dark:group-data-hover:bg-teal-500/20",cyan:"bg-cyan-400/20 text-cyan-700 group-data-hover:bg-cyan-400/30 dark:bg-cyan-400/10 dark:text-cyan-300 dark:group-data-hover:bg-cyan-400/15",sky:"bg-sky-500/15 text-sky-700 group-data-hover:bg-sky-500/25 dark:bg-sky-500/10 dark:text-sky-300 dark:group-data-hover:bg-sky-500/20",blue:"bg-blue-500/15 text-blue-700 group-data-hover:bg-blue-500/25 dark:text-blue-400 dark:group-data-hover:bg-blue-500/25",indigo:"bg-indigo-500/15 text-indigo-700 group-data-hover:bg-indigo-500/25 dark:text-indigo-400 dark:group-data-hover:bg-indigo-500/20",violet:"bg-violet-500/15 text-violet-700 group-data-hover:bg-violet-500/25 dark:text-violet-400 dark:group-data-hover:bg-violet-500/20",purple:"bg-purple-500/15 text-purple-700 group-data-hover:bg-purple-500/25 dark:text-purple-400 dark:group-data-hover:bg-purple-500/20",fuchsia:"bg-fuchsia-400/15 text-fuchsia-700 group-data-hover:bg-fuchsia-400/25 dark:bg-fuchsia-400/10 dark:text-fuchsia-400 dark:group-data-hover:bg-fuchsia-400/20",pink:"bg-pink-400/15 text-pink-700 group-data-hover:bg-pink-400/25 dark:bg-pink-400/10 dark:text-pink-400 dark:group-data-hover:bg-pink-400/20",rose:"bg-rose-400/15 text-rose-700 group-data-hover:bg-rose-400/25 dark:bg-rose-400/10 dark:text-rose-400 dark:group-data-hover:bg-rose-400/20",zinc:"bg-zinc-600/10 text-zinc-700 group-data-hover:bg-zinc-600/20 dark:bg-white/5 dark:text-zinc-400 dark:group-data-hover:bg-white/10"};function k({color:t="zinc",className:s,...n}){return e.jsx("span",{...n,className:H(s,"inline-flex items-center gap-x-1.5 rounded-md px-1.5 py-0.5 text-sm/5 font-medium sm:text-xs/5 forced-colors:outline",zt[t])})}l.forwardRef(function({color:s="zinc",className:n,children:a,...r},o){let d=H(n,"group relative inline-flex rounded-md focus:not-data-focus:outline-hidden data-focus:outline-2 data-focus:outline-offset-2 data-focus:outline-blue-500");return typeof r.href=="string"?e.jsx(ge,{...r,className:d,ref:o,children:e.jsx(V,{children:e.jsx(k,{color:s,children:a})})}):e.jsx(pe,{...r,className:d,ref:o,children:e.jsx(V,{children:e.jsx(k,{color:s,children:a})})})});function It(t){l.useEffect(()=>{if(!t)return;const s=t;function n(a){if(!(a.target instanceof HTMLInputElement||a.target instanceof HTMLTextAreaElement))switch(a.key){case"1":s({tab:"overview"});break;case"2":s({tab:"mail"});break;case"3":s({tab:"sessions"});break;case"4":s({tab:"work"});break;case"5":s({tab:"connections"});break;case"6":s({tab:"inner"});break;case"7":s({tab:"notes"});break;case"8":s({tab:"runtime"});break;case"Escape":{document.activeElement instanceof HTMLElement&&document.activeElement.blur();break}}}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t])}const Tt={"owed-reply":"red","blocking-obligation":"red","broken-return":"red","stale-delegation":"yellow","return-ready":"lime","overdue-habit":"yellow"},Et={"owed-reply":"owed reply","blocking-obligation":"blocking","broken-return":"broken return","stale-delegation":"stale","return-ready":"ready to return","overdue-habit":"overdue"},Lt={"owed-reply":"Someone spoke last and is waiting for your response","blocking-obligation":"This obligation is open and blocking forward progress","broken-return":"Work was done but the result was never returned to the requester","stale-delegation":"This was delegated to you and hasn't been addressed","return-ready":"The result is ready — deliver it to close the loop","overdue-habit":"This routine is past its scheduled cadence"},Ot=new Set(["stale-delegation"]),Mt=new Set(["owed-reply","blocking-obligation","broken-return","return-ready","overdue-habit"]),Ut=new Set(["spawning","running","waiting_input","stalled"]);function Ht({view:t,deskPrefs:s,refreshGeneration:n}){const a=X(),[r,o]=l.useState(null),[d,b]=l.useState(null),[x,f]=l.useState(null),[h,w]=l.useState(null),[A,c]=l.useState(null),g=t.agent,m=t.work,v=t.inner,y=t.activity,j=g.degraded,I=g.attention,i=m.tasks,S=m.obligations,T=m.sessions,z=m.coding,O=g.senses,p=m.bridges;return l.useEffect(()=>{L(`/agents/${encodeURIComponent(g.agentName)}/needs-me`).then(o),L(`/agents/${encodeURIComponent(g.agentName)}/coding`).then(b),L(`/agents/${encodeURIComponent(g.agentName)}/continuity`).then(f).catch(()=>{}),L(`/agents/${encodeURIComponent(g.agentName)}/orientation`).then(w).catch(()=>{}),L(`/agents/${encodeURIComponent(g.agentName)}/changes`).then(c).catch(()=>{})},[g.agentName,n]),e.jsxs("div",{className:"space-y-6",children:[r&&r.items.length>0&&(()=>{const u=r.items.filter(R=>Mt.has(R.urgency)),N=r.items.filter(R=>Ot.has(R.urgency));return e.jsxs("div",{className:"space-y-3",children:[u.length>0&&e.jsxs("div",{className:"rounded-xl bg-ouro-fang/5 p-4 ring-1 ring-ouro-fang/15",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-fang",children:["Action now (",u.length,")"]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:u.map((R,$)=>e.jsx(Ue,{item:R,nav:a,agentName:g.agentName,onDismiss:()=>{o(E=>E&&{items:E.items.filter((q,Q)=>r.items.indexOf(R)!==Q)})}},`action-${$}`))})]}),N.length>0&&e.jsxs("div",{className:"rounded-xl bg-ouro-gold/5 p-4 ring-1 ring-ouro-gold/15",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-gold",children:["Stale (",N.length,")"]}),e.jsx("button",{onClick:async()=>{var R;for(const $ of N)(R=$.ref)!=null&&R.focus&&await fetch(`/api/agents/${encodeURIComponent(g.agentName)}/dismiss-obligation`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({obligationId:$.ref.focus})});L(`/agents/${encodeURIComponent(g.agentName)}/needs-me`).then(o)},className:"text-xs text-ouro-gold underline underline-offset-2 hover:text-ouro-bone transition-colors",children:"Clear all stale"})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:N.map((R,$)=>e.jsx(Ue,{item:R,nav:a,agentName:g.agentName,onDismiss:()=>{L(`/agents/${encodeURIComponent(g.agentName)}/needs-me`).then(o)}},`stale-${$}`))})]})]})})(),(s==null?void 0:s.carrying)&&e.jsxs("div",{className:"rounded-xl bg-ouro-moss/10 p-4 ring-1 ring-ouro-glow/8",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:"What I'm carrying"}),e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-ouro-bone",children:s.carrying})]}),(()=>{const u=(s==null?void 0:s.pinnedConstellations)??[];return u.length===0?null:e.jsxs("div",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Pinned threads"}),e.jsx("div",{className:"mt-2 space-y-2",children:u.map((N,R)=>e.jsxs("div",{className:"rounded-lg bg-ouro-void/40 px-3 py-2.5 ring-1 ring-ouro-moss/15",children:[e.jsx("p",{className:"font-medium text-ouro-bone",children:N.label}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[N.friendIds.map($=>e.jsxs("button",{onClick:()=>a({tab:"sessions"}),className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2",children:["friend:",$.slice(0,8),"…"]},$)),N.taskRefs.map($=>e.jsxs("button",{onClick:()=>a({tab:"work"}),className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2",children:["task:",$]},$)),N.bridgeIds.map($=>e.jsxs("button",{onClick:()=>a({tab:"connections",focus:$}),className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2",children:["bridge:",$.slice(0,8),"…"]},$))]})]},R))})]})})(),e.jsxs("div",{className:"rounded-xl bg-ouro-moss/15 p-4 ring-1 ring-ouro-glow/10 sm:p-5",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:"Center of gravity"}),e.jsx("p",{className:"mt-1 font-display text-xl italic font-semibold text-ouro-bone sm:text-2xl",children:I.label}),e.jsxs("p",{className:"mt-2 text-sm leading-relaxed text-ouro-mist",children:[g.agentName," has"," ",e.jsxs(ue,{tab:"work",children:[i.liveCount," live tasks"]}),","," ",e.jsxs(ue,{tab:"work",children:[S.openCount," obligations"]}),","," ",e.jsxs(ue,{tab:"work",children:[z.activeCount," coding lanes"]}),", and"," ",e.jsxs(ue,{tab:"sessions",children:[T.liveCount," live sessions"]}),"."]}),j.status==="degraded"&&j.issues.length>0&&e.jsxs("div",{className:"mt-3 space-y-1",children:[j.issues.slice(0,5).map((u,N)=>e.jsxs("button",{onClick:()=>a({tab:"runtime"}),className:"flex w-full items-start gap-2 rounded-lg bg-ouro-fang/5 px-3 py-2 text-left text-sm ring-1 ring-ouro-fang/10 hover:ring-ouro-fang/25 transition-colors",children:[e.jsx("span",{className:"mt-0.5 h-2 w-2 shrink-0 rounded-full bg-ouro-fang"}),e.jsxs("span",{className:"text-ouro-mist",children:[e.jsx("span",{className:"font-semibold text-ouro-fang",children:u.code}),e.jsxs("span",{className:"text-ouro-shadow",children:[" — ",_(u.detail,80)]})]})]},N)),j.issues.length>5&&e.jsxs("button",{onClick:()=>a({tab:"runtime"}),className:"text-xs text-ouro-glow underline underline-offset-2",children:["+",j.issues.length-5," more issues"]})]})]}),h&&e.jsxs("div",{className:"rounded-xl bg-ouro-moss/10 p-4 ring-1 ring-ouro-glow/8",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:"Orientation"}),(()=>{const u=h.currentSession;return u?e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(k,{color:"lime",children:"active session"}),e.jsxs("button",{onClick:()=>a({tab:"sessions",focus:`${u.friendId}/${u.channel}/${u.key}`}),className:"text-sm text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2",children:[u.channel,"/",u.key]}),u.lastActivityAt&&e.jsx("span",{className:"text-xs text-ouro-shadow",children:M(u.lastActivityAt)})]}):null})(),h.primaryObligation&&e.jsxs("div",{className:"mt-2 rounded-lg bg-ouro-void/40 px-3 py-2 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{color:"yellow",children:h.primaryObligation.status}),e.jsx("span",{className:"text-sm font-medium text-ouro-bone",children:_(h.primaryObligation.content,80)})]}),h.primaryObligation.nextAction&&e.jsxs("p",{className:"mt-1 text-xs text-ouro-mist",children:["Next: ",h.primaryObligation.nextAction]}),h.primaryObligation.waitingOn&&e.jsxs("p",{className:"mt-0.5 text-xs text-ouro-shadow",children:["Waiting on: ",h.primaryObligation.waitingOn]})]}),h.resumeHandle&&e.jsxs("div",{className:"mt-2 rounded-lg bg-ouro-void/40 px-3 py-2 ring-1 ring-ouro-moss/15",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:"Resume handle"}),e.jsxs("div",{className:"mt-1 space-y-0.5 text-sm",children:[h.resumeHandle.lane&&e.jsxs("p",{className:"text-ouro-bone",children:["Lane: ",h.resumeHandle.lane]}),h.resumeHandle.artifact&&e.jsxs("p",{className:"text-ouro-mist",children:["Artifact: ",h.resumeHandle.artifact]}),h.resumeHandle.nextAction&&e.jsxs("p",{className:"text-ouro-mist",children:["Next: ",h.resumeHandle.nextAction]}),h.resumeHandle.blockerOrWaitingOn&&e.jsxs("p",{className:"text-ouro-shadow",children:["Blocked: ",h.resumeHandle.blockerOrWaitingOn]}),e.jsxs(k,{color:h.resumeHandle.confidence==="high"?"lime":h.resumeHandle.confidence==="medium"?"yellow":"zinc",children:[h.resumeHandle.confidence," confidence"]})]})]}),h.otherActiveSessions.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-ouro-shadow",children:["Other sessions (",h.otherActiveSessions.length,")"]}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1.5",children:h.otherActiveSessions.slice(0,5).map(u=>e.jsx("button",{onClick:()=>a({tab:"sessions",focus:`${u.friendId}/${u.channel}/${u.key}`}),className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2",children:u.friendName},`${u.friendId}/${u.channel}/${u.key}`))})]})]}),A&&A.changeCount>0&&e.jsxs("div",{className:"rounded-xl bg-ouro-gold/5 p-4 ring-1 ring-ouro-gold/15",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-gold",children:["What changed (",A.changeCount,")"]}),A.snapshotAge&&e.jsxs("p",{className:"mt-0.5 text-xs text-ouro-shadow",children:["Since ",M(A.snapshotAge)]}),e.jsxs("div",{className:"mt-2 space-y-1",children:[A.items.slice(0,8).map((u,N)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(k,{color:u.kind.includes("status")?"yellow":"zinc",children:u.kind.replace(/_/g," ")}),e.jsx("span",{className:"truncate text-ouro-mist",children:u.summary})]},N)),A.items.length>8&&e.jsxs("p",{className:"text-xs text-ouro-shadow",children:["+",A.items.length-8," more changes"]})]})]}),x&&e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-xl bg-ouro-void/50 p-4 ring-1 ring-ouro-moss/20",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:"Presence"}),x.presence.self?e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-ouro-bone",children:x.presence.self.availability}),x.presence.self.lane&&e.jsxs("p",{className:"text-xs text-ouro-shadow",children:["Lane: ",x.presence.self.lane]}),x.presence.self.tempo&&e.jsxs("p",{className:"text-xs text-ouro-shadow",children:["Tempo: ",x.presence.self.tempo]})]}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No presence data"}),x.presence.peers.length>0&&e.jsxs("div",{className:"mt-2 border-t border-ouro-moss/20 pt-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-ouro-shadow",children:"Peers"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1.5",children:x.presence.peers.map(u=>e.jsx(k,{color:u.availability==="active"?"lime":"zinc",children:u.agentName},u.agentName))})]})]}),e.jsxs("div",{className:"rounded-xl bg-ouro-void/50 p-4 ring-1 ring-ouro-moss/20",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:["Cares (",x.cares.activeCount,")"]}),x.cares.items.length>0?e.jsx("div",{className:"mt-2 space-y-1.5",children:x.cares.items.slice(0,5).map(u=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{color:u.salience==="high"?"red":u.salience==="medium"?"yellow":"zinc",children:u.salience}),e.jsx("p",{className:"truncate text-sm text-ouro-bone",children:u.label})]},u.id))}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No active cares"})]}),e.jsxs("div",{className:"rounded-xl bg-ouro-void/50 p-4 ring-1 ring-ouro-moss/20",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:["Episodes (",x.episodes.recentCount,")"]}),x.episodes.items.length>0?e.jsx("div",{className:"mt-2 space-y-1.5",children:x.episodes.items.slice(0,5).map(u=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(k,{color:"zinc",children:u.kind}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm text-ouro-bone",children:u.summary}),e.jsx("p",{className:"text-xs text-ouro-shadow",children:M(u.timestamp)})]})]},u.id))}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No recent episodes"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[e.jsx(xe,{label:"Tasks",value:i.liveCount,sub:`${i.blockedCount} blocked`,onClick:()=>a({tab:"work"})}),e.jsx(xe,{label:"Obligations",value:S.openCount,sub:`${T.liveCount} sessions`,onClick:()=>a({tab:"work"})}),e.jsx(xe,{label:"Coding",value:z.activeCount,sub:`${z.blockedCount} blocked`,onClick:()=>a({tab:"work"})}),e.jsx(xe,{label:"Private Runtime",value:v.status,sub:_(v.summary??"",30),onClick:()=>a({tab:"inner"})})]}),d&&d.items.length>0&&(()=>{const u=d.items.filter(N=>Ut.has(N.status));return u.length===0?null:e.jsx(te,{title:`Active coding (${u.length})`,children:e.jsx("div",{className:"space-y-1.5",children:u.map(N=>e.jsxs("button",{onClick:()=>a({tab:"work"}),className:"flex w-full items-center gap-2 rounded-lg bg-ouro-void/40 px-3 py-2 text-left ring-1 ring-ouro-moss/15 hover:ring-ouro-glow/20 transition-colors",children:[e.jsx(k,{color:N.status==="running"?"lime":N.status==="waiting_input"?"yellow":"zinc",children:N.status}),e.jsxs("span",{className:"truncate text-sm text-ouro-bone",children:[N.runner," — ",_(N.workdir,40)]}),e.jsx("span",{className:"shrink-0 text-xs text-ouro-shadow",children:M(N.lastActivityAt)})]},N.id))})})})(),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(te,{title:"Senses",children:O.length>0?e.jsx(_t,{items:O}):e.jsx(fe,{children:"No active senses"})}),e.jsx(te,{title:"Bridges",children:p.length>0?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:p.map(u=>e.jsx("button",{onClick:()=>a({tab:"connections",focus:u}),children:e.jsx(k,{color:"lime",children:u})},u))}):e.jsx(fe,{children:"No active bridges"})})]}),(()=>{const u=S.items.filter(N=>N.status==="fulfilled");return u.length===0?null:e.jsx(te,{title:"Recently closed",children:e.jsx("div",{className:"space-y-1",children:u.slice(0,3).map((N,R)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-3 py-2 bg-ouro-glow/5 ring-1 ring-ouro-glow/10",children:[e.jsx(k,{color:"lime",children:"closed"}),e.jsx("p",{className:"text-sm text-ouro-mist truncate",children:_(N.content,80)}),e.jsx("span",{className:"shrink-0 text-xs text-ouro-shadow",children:M(N.updatedAt)})]},R))})})})(),e.jsx(te,{title:"Recent activity",children:y.recent.length>0?e.jsx("div",{className:"space-y-1",children:y.recent.map((u,N)=>{const R=u.kind==="coding"||u.kind==="obligation"?"work":u.kind==="session"?"sessions":"inner";return e.jsxs("button",{onClick:()=>a({tab:R}),className:"flex w-full flex-col gap-0.5 rounded-lg px-3 py-2.5 text-left hover:bg-ouro-moss/10 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{children:u.kind}),e.jsx("span",{className:"text-xs text-ouro-shadow",children:M(u.at)})]}),e.jsx("p",{className:"truncate text-sm font-medium text-ouro-bone",children:_(u.label,100)}),e.jsx("p",{className:"truncate text-xs text-ouro-shadow",children:_(u.detail,80)})]},N)})}):e.jsx(fe,{children:"No recent activity yet."})})]})}function Ue({item:t,nav:s,agentName:n,onDismiss:a}){var d;const r=t.urgency==="return-ready",o=(d=t.ref)==null?void 0:d.focus;return e.jsxs("div",{className:`flex w-full items-start gap-2.5 rounded-lg px-3 py-2.5 text-left ring-1 transition-colors ${r?"bg-ouro-glow/5 ring-ouro-glow/15":"bg-ouro-void/40 ring-ouro-moss/10"}`,children:[e.jsxs("button",{onClick:()=>t.ref&&s({tab:t.ref.tab,focus:t.ref.focus}),className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx(k,{color:Tt[t.urgency]??"zinc",children:Et[t.urgency]??t.urgency}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:`text-sm font-medium ${r?"text-ouro-glow":"text-ouro-bone"}`,children:t.label}),e.jsx("p",{className:"text-xs text-ouro-shadow truncate",children:t.detail}),e.jsx("p",{className:"text-[10px] italic text-ouro-shadow/60 mt-0.5",children:Lt[t.urgency]??""})]}),t.ageMs!=null&&e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-ouro-shadow",children:t.ageMs<36e5?`${Math.floor(t.ageMs/6e4)}m`:t.ageMs<864e5?`${Math.floor(t.ageMs/36e5)}h`:`${Math.floor(t.ageMs/864e5)}d`})]}),o&&e.jsx("button",{onClick:async b=>{b.stopPropagation(),await fetch(`/api/agents/${encodeURIComponent(n)}/dismiss-obligation`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({obligationId:o})}),a()},className:"shrink-0 text-xs text-ouro-shadow hover:text-ouro-fang transition-colors",title:"Dismiss",children:"✕"})]})}function ue({tab:t,children:s}){const n=X();return e.jsx("button",{onClick:()=>n({tab:t}),className:"text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow transition-colors",children:s})}function xe({label:t,value:s,sub:n,onClick:a}){return e.jsxs("button",{onClick:a,className:"rounded-xl bg-ouro-void/50 p-3 text-left ring-1 ring-ouro-moss/20 hover:ring-ouro-glow/20 transition-all",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-ouro-shadow",children:t}),e.jsx("p",{className:"mt-1 text-xl font-semibold tabular-nums text-ouro-bone",children:s}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-ouro-shadow",children:n})]})}function te({title:t,children:s}){return e.jsxs("div",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:t}),e.jsx("div",{className:"mt-2",children:s})]})}function _t({items:t}){return e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(s=>e.jsx(k,{color:"lime",children:s},s))})}function fe({children:t}){return e.jsx("p",{className:"text-sm text-ouro-shadow",children:t})}function ae(t){return t.length>0?t.join(", "):"(unknown)"}function Dt(t,s){if(s==="all")return!0;if(["imbox","screener","discarded","quarantine"].includes(s))return t.placement===s;if(s==="native"||s==="delegated")return t.compartmentKind===s;if(s.startsWith("source:")){const n=s.slice(7),a=n.indexOf(":");if(a===-1)return t.source===n;const r=n.slice(0,a),o=n.slice(a+1);return t.source===r&&(t.ownerEmail??"unknown-owner")===o}return!1}function Ge(t){return t.subject||"(no subject)"}function qt(t,s){return{status:"error",agentName:t,mailboxAddress:null,generatedAt:new Date().toISOString(),store:null,folders:[],messages:[],screener:[],outbound:[],recovery:{discardedCount:0,quarantineCount:0,undecryptableCount:0,missingKeyIds:[]},accessLog:[],error:s}}function Ft(t,s,n){return{status:"error",agentName:t,mailboxAddress:s,generatedAt:new Date().toISOString(),message:null,accessLog:[],error:n}}function et(t){return t.provenance.compartmentKind==="delegated"?`delegated human mailbox · ${t.provenance.ownerEmail??"unknown owner"} / ${t.provenance.source??"unknown source"}`:"native agent mailbox"}function Bt(t){return t.mailboxRole==="delegated-human-mailbox"?`delegated human mailbox · ${t.ownerEmail??"unknown owner"} / ${t.source??"unknown source"}`:t.mailboxRole==="agent-native-mailbox"?"native agent mailbox":"mailbox"}function Pt(t){return t.sendAuthority==="agent-native"?"native agent mailbox":t.mailboxRole}function Wt(t){return t.transport??t.provider??"not sent"}function Vt(t){return t.deliveredAt??t.failedAt??t.acceptedAt??t.sentAt??t.submittedAt??t.updatedAt}function Ae(t){return t==="screener"?"bg-[#fff7d6] text-[#6f5200] ring-[#e7c85c]":t==="discarded"||t==="quarantine"?"bg-[#ffe8e2] text-[#8a2f1f] ring-[#ef9a84]":t==="sent"?"bg-[#dff7ea] text-[#17613a] ring-[#82caa1]":t==="draft"?"bg-[#e7ecff] text-[#263f95] ring-[#a7b5f5]":"bg-[#e9f3ef] text-[#1e5840] ring-[#9fc7b5]"}function Qt(t){return(t==null?void 0:t.messages.length)??0}function Kt({agentName:t,focus:s,onFocusConsumed:n,refreshGeneration:a}){var y;const[r,o]=l.useState(null),[d,b]=l.useState("all"),[x,f]=l.useState(s??null),[h,w]=l.useState(null),[A,c]=l.useState(!1);l.useEffect(()=>{b("all"),f(s??null),w(null)},[t]),l.useEffect(()=>{o(null),L(`/agents/${encodeURIComponent(t)}/mail`).then(o).catch(()=>o(qt(t,"mail unavailable")))},[t,a]),l.useEffect(()=>{s&&(f(s),n==null||n())},[s,n]),l.useEffect(()=>{if(!x){w(null);return}c(!0),L(`/agents/${encodeURIComponent(t)}/mail/${encodeURIComponent(x)}`).then(w).catch(()=>w(Ft(t,(r==null?void 0:r.mailboxAddress)??null,"message unavailable"))).finally(()=>c(!1))},[t,x,a]);const g=l.useMemo(()=>{const j=(r==null?void 0:r.folders)??[];return[{id:"all",label:"All",count:Qt(r)},...j]},[r]),m=l.useMemo(()=>((r==null?void 0:r.messages)??[]).filter(j=>Dt(j,d)),[d,r]),v=l.useMemo(()=>d!=="draft"&&d!=="sent"?[]:((r==null?void 0:r.outbound)??[]).filter(j=>d==="draft"?j.status==="draft":j.status!=="draft"),[d,r]);return r?r.status!=="ready"?e.jsx("div",{className:"mailbox-shell grid min-h-[58vh] place-items-center rounded-md bg-[#f2f6ef] p-8 text-[#1f2720] ring-1 ring-black/10",children:e.jsxs("div",{className:"max-w-lg text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-[#667067]",children:"Mailbox"}),e.jsx("h2",{className:"mt-2 text-2xl font-semibold",children:r.status==="auth-required"?"Locked":"Unavailable"}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[#59645c]",children:r.error})]})}):e.jsxs("div",{className:"mailbox-shell overflow-hidden rounded-md bg-[#f2f6ef] text-[#172018] ring-1 ring-black/10",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-[#cbd8c8] bg-[#e4ecdf] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-[#687062]",children:"Agent mailbox"}),e.jsx("p",{className:"truncate text-sm text-[#2d3a30]",children:r.mailboxAddress})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{color:"zinc",children:"read-only"}),e.jsxs("span",{className:"text-xs tabular-nums text-[#687062]",children:[r.messages.length," messages"]}),e.jsxs("span",{className:"text-xs tabular-nums text-[#687062]",children:[r.outbound.length," outbound"]})]})]}),e.jsxs("div",{className:"grid min-h-[66vh] grid-cols-1 lg:grid-cols-[14.5rem_minmax(19rem,25rem)_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"border-b border-[#cbd8c8] bg-[#e4ecdf] p-3 lg:border-b-0 lg:border-r",children:[e.jsx(Zt,{folders:g,activeFolder:d,setActiveFolder:b}),e.jsx(Jt,{discarded:r.recovery.discardedCount,quarantine:r.recovery.quarantineCount,undecryptable:r.recovery.undecryptableCount,missingKeyIds:r.recovery.missingKeyIds}),e.jsx(Yt,{candidates:r.screener,onOpen:j=>{b("screener"),f(j)}}),e.jsx(Xt,{entries:r.accessLog})]}),e.jsxs("section",{className:"border-b border-[#cbd8c8] bg-[#fbfdf8] lg:border-b-0 lg:border-r",children:[e.jsxs("div",{className:"border-b border-[#d8e2d4] px-4 py-3",children:[e.jsx("p",{className:"text-sm font-semibold text-[#172018]",children:((y=g.find(j=>j.id===d))==null?void 0:y.label)??"All"}),e.jsx("p",{className:"text-xs text-[#687062]",children:v.length>0?`${v.length} outbound records`:`${m.length} messages`})]}),e.jsxs("div",{className:"max-h-[66vh] overflow-y-auto",children:[v.map(j=>e.jsx(es,{record:j},j.id)),v.length===0&&m.map(j=>e.jsx(Gt,{message:j,selected:x===j.id,onSelect:()=>f(j.id)},j.id)),v.length===0&&m.length===0&&e.jsx("div",{className:"px-4 py-10 text-center text-sm text-[#687062]",children:"No records here."})]})]}),e.jsxs("main",{className:"min-w-0 bg-[#fbfdf8]",children:[!x&&e.jsx(ss,{}),x&&A&&e.jsx(He,{label:"Opening message"}),x&&!A&&(h==null?void 0:h.status)!=="ready"&&e.jsx("div",{className:"grid min-h-[54vh] place-items-center p-8 text-center",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[#172018]",children:"Message unavailable"}),e.jsx("p",{className:"mt-2 text-sm text-[#687062]",children:h==null?void 0:h.error})]})}),(h==null?void 0:h.status)==="ready"&&h.message&&e.jsx(ts,{detail:h})]})]})]}):e.jsx(He,{label:"Opening mailbox"})}function Zt({folders:t,activeFolder:s,setActiveFolder:n}){return e.jsx("div",{className:"space-y-1",children:t.map(a=>e.jsxs("button",{type:"button",onClick:()=>n(a.id),className:`flex h-9 w-full items-center justify-between rounded px-3 text-left text-sm transition-colors ${s===a.id?"bg-[#fbfdf8] text-[#172018] shadow-sm":"text-[#536157] hover:bg-[#fbfdf8]/65"}`,children:[e.jsx("span",{className:"truncate",children:a.label}),e.jsx("span",{className:"text-xs tabular-nums text-[#687062]",children:a.count})]},a.id))})}function Jt({discarded:t,quarantine:s,undecryptable:n,missingKeyIds:a}){return e.jsxs("div",{className:"mt-5 border-t border-[#cbd8c8] pt-4",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#687062]",children:"Recovery drawers"}),e.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"rounded border border-[#cbd8c8] bg-[#fbfdf8] px-3 py-2",children:[e.jsx("p",{className:"text-xs text-[#687062]",children:"Discarded"}),e.jsx("p",{className:"text-lg font-semibold tabular-nums text-[#172018]",children:t})]}),e.jsxs("div",{className:"rounded border border-[#cbd8c8] bg-[#fbfdf8] px-3 py-2",children:[e.jsx("p",{className:"text-xs text-[#687062]",children:"Quarantine"}),e.jsx("p",{className:"text-lg font-semibold tabular-nums text-[#172018]",children:s})]}),e.jsxs("div",{className:"rounded border border-[#cbd8c8] bg-[#fbfdf8] px-3 py-2",children:[e.jsx("p",{className:"text-xs text-[#687062]",children:"Undecryptable"}),e.jsx("p",{className:"text-lg font-semibold tabular-nums text-[#172018]",children:n})]})]}),n>0&&e.jsxs("p",{className:"mt-2 text-[11px] leading-4 text-[#687062]",children:["missing key ",a[0],a.length>1?` +${a.length-1} more`:""]})]})}function Yt({candidates:t,onOpen:s}){return e.jsxs("div",{className:"mt-5 border-t border-[#cbd8c8] pt-4",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#687062]",children:"Screener"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[t.slice(0,5).map(n=>e.jsxs("button",{type:"button",onClick:()=>s(n.messageId),className:"block w-full rounded border border-[#cbd8c8] bg-[#fbfdf8] px-3 py-2 text-left hover:border-[#9fb8a7]",children:[e.jsx("p",{className:"truncate text-xs font-semibold text-[#172018]",children:n.senderEmail}),e.jsx("p",{className:"mt-1 truncate text-xs text-[#687062]",children:n.trustReason})]},n.id)),t.length===0&&e.jsx("p",{className:"text-xs text-[#687062]",children:"No pending senders."})]})]})}function Xt({entries:t}){return e.jsxs("div",{className:"mt-5 border-t border-[#cbd8c8] pt-4",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#687062]",children:"Access audit"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[t.slice(0,4).map(s=>e.jsxs("div",{className:"text-xs leading-4 text-[#687062]",children:[e.jsx("p",{className:"truncate font-medium text-[#3f4b42]",children:s.tool}),e.jsx("p",{className:"truncate",children:Bt(s)}),e.jsx("p",{className:"truncate",children:s.reason})]},s.id)),t.length===0&&e.jsx("p",{className:"text-xs text-[#687062]",children:"No reads yet."})]})]})}function Gt({message:t,selected:s,onSelect:n}){return e.jsxs("button",{type:"button",onClick:n,className:`block w-full border-b border-[#d8e2d4] px-4 py-3 text-left transition-colors ${s?"bg-[#eaf4ee]":"hover:bg-[#eef4ec]"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 truncate text-sm font-semibold text-[#172018]",children:ae(t.from)}),e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-[#687062]",children:M(t.receivedAt)})]}),e.jsx("p",{className:"mt-1 truncate text-sm text-[#26352a]",children:Ge(t)}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-5 text-[#687062]",children:_(t.snippet,150)}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`rounded px-2 py-0.5 text-[11px] ring-1 ${Ae(t.placement)}`,children:t.placement}),e.jsx("span",{className:"truncate text-[11px] text-[#687062]",children:et(t)})]})]})}function es({record:t}){const s=t.deliveryEvents[t.deliveryEvents.length-1];return e.jsxs("div",{className:"border-b border-[#d8e2d4] px-4 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 truncate text-sm font-semibold text-[#172018]",children:t.subject||"(no subject)"}),e.jsx("span",{className:`shrink-0 rounded px-2 py-0.5 text-[11px] ring-1 ${Ae(t.status)}`,children:t.status})]}),e.jsxs("p",{className:"mt-1 truncate text-xs text-[#536157]",children:["to ",ae(t.to)]}),e.jsxs("p",{className:"mt-1 text-xs text-[#687062]",children:[Wt(t)," · ",M(Vt(t))]}),e.jsxs("p",{className:"mt-1 truncate text-xs text-[#687062]",children:[Pt(t)," · ",t.sendMode??"mode unknown",t.policyDecision?` · policy ${t.policyDecision.code} / ${t.policyDecision.fallback}`:""]}),(t.providerMessageId||t.providerRequestId)&&e.jsxs("p",{className:"mt-1 truncate text-xs text-[#687062]",children:["provider ",t.providerMessageId??"unknown",t.providerRequestId?` · request ${t.providerRequestId}`:""]}),s&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-5 text-[#687062]",children:s.bodySafeSummary})]})}function ts({detail:t}){const s=t.message;return e.jsxs("article",{className:"min-h-[66vh]",children:[e.jsxs("header",{className:"border-b border-[#cbd8c8] bg-[#fbfdf8] px-6 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("h2",{className:"min-w-0 text-xl font-semibold leading-tight text-[#172018]",children:Ge(s)}),e.jsx("span",{className:`rounded px-2 py-0.5 text-xs ring-1 ${Ae(s.placement)}`,children:s.placement})]}),e.jsxs("div",{className:"mt-4 grid gap-1 text-sm text-[#536157]",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"From:"})," ",ae(s.from)]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"To:"})," ",ae(s.to)]}),s.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"Cc:"})," ",ae(s.cc)]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"Received:"})," ",new Date(s.receivedAt).toLocaleString()]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"Provenance:"})," ",et(s)]})]})]}),e.jsx("div",{className:"border-b border-[#f0d0bd] bg-[#fff4e4] px-6 py-3 text-sm text-[#8a4a18]",children:s.untrustedContentWarning}),e.jsxs("div",{className:"px-6 py-6",children:[e.jsx("pre",{className:"whitespace-pre-wrap break-words font-body text-sm leading-7 text-[#26352a]",children:s.text||"(no text body)"}),s.bodyTruncated&&e.jsx("p",{className:"mt-4 text-xs text-[#687062]",children:"Body truncated in Mailbox."}),e.jsxs("div",{className:"mt-6 grid gap-3 border-t border-[#cbd8c8] pt-4 text-xs text-[#687062] md:grid-cols-2",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"Read reason:"})," ",s.access.reason]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"Read at:"})," ",new Date(s.access.accessedAt).toLocaleString()]})]}),s.attachments.length>0&&e.jsxs("div",{className:"mt-6 border-t border-[#cbd8c8] pt-4",children:[e.jsx("p",{className:"text-xs font-semibold text-[#687062]",children:"Attachments"}),e.jsx("div",{className:"mt-2 space-y-2",children:s.attachments.map(n=>e.jsxs("div",{className:"rounded border border-[#cbd8c8] bg-[#fbfdf8] px-3 py-2 text-sm text-[#3f4b42]",children:[n.filename," · ",n.contentType," · ",n.size.toLocaleString()," bytes"]},`${n.filename}-${n.size}`))})]})]})]})}function ss(){return e.jsx("div",{className:"grid min-h-[54vh] place-items-center p-8 text-center",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[#172018]",children:"No message selected"}),e.jsx("p",{className:"mt-2 text-sm text-[#687062]",children:"Reading pane idle."})]})})}function He({label:t}){return e.jsxs("div",{className:"flex items-center gap-2 p-6",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-[#2f8f4e]"}),e.jsxs("span",{className:"text-xs text-[#687062]",children:[t,"..."]})]})}function Se(t){const s=t.function.name,n=ns(t.function.arguments);return s==="settle"?{kind:"response",name:s,id:t.id,deliveredText:n.answer??null,delegatedThought:null,metadata:n.intent??null,rawArgs:null}:s==="ponder"?{kind:"delegation",name:s,id:t.id,deliveredText:n.say??null,delegatedThought:n.thought??null,metadata:null,rawArgs:null}:s==="rest"?{kind:"rest",name:s,id:t.id,deliveredText:null,delegatedThought:null,metadata:null,rawArgs:null}:s==="observe"?{kind:"observe",name:s,id:t.id,deliveredText:null,delegatedThought:null,metadata:n.reason??null,rawArgs:null}:s==="surface"?{kind:"surface",name:s,id:t.id,deliveredText:n.content??null,delegatedThought:null,metadata:n.delegationId??n.friendId??null,rawArgs:null}:{kind:"action",name:s,id:t.id,deliveredText:null,delegatedThought:null,metadata:null,rawArgs:t.function.arguments}}function ns(t){try{const s=JSON.parse(t);if(s&&typeof s=="object")return s}catch{}return{}}const os=48;function rs(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=os}function tt(t){const s=l.useRef(null),n=l.useRef(!0),a=l.useCallback(()=>{const o=s.current;o&&(n.current=rs(o))},[]),r=l.useCallback(()=>{n.current=!1},[]);return l.useEffect(()=>{const o=s.current;!o||!n.current||(o.scrollTop=o.scrollHeight)},[t]),{ref:s,onScroll:a,preserveScroll:r}}function as(t){return typeof t=="string"?t:Array.isArray(t)?t.map(s=>s.type==="text"&&typeof s.text=="string"?s.text:"").filter(s=>s.length>0).join(""):""}function ie(t){return as(t.content)}function st(t){return t.time.authoredAt??t.time.observedAt??t.time.recordedAt}const nt=t=>/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(t),ot=t=>/^[a-f0-9]{64}$/.test(t);function _e(t,s){return!nt(t)||s!==void 0&&!ot(s)?null:s===void 0?`ouro shepherd status --agent '${t}' --json`:`ouro shepherd inspect --agent '${t}' --id '${s}' --json`}function is(t,s,n){return!nt(t)||!ot(s)||n===null||!Number.isSafeInteger(n)||n<0?null:`ouro shepherd reconcile --agent '${t}' --id '${s}' --resolution retired --expected-revision ${n} --request-id 'supervision-retire-${s}-r${n}' --json`}const ls="This alpha retains unqualified legacy automation. Legacy immediate/network automation may still type text without mandate enforcement. Automatic keys are refused. Absent or revoked mandates do not disable those text paths. Disable Shepherd to stop legacy automation.",De={"needs-reply":{color:"red",label:"needs reply"},"on-hold":{color:"yellow",label:"on hold"},monitoring:{color:"zinc",label:"monitoring"},idle:{color:"zinc",label:"idle"}};function rt(t){return t==="bluebubbles"?"iMessage":t==="teams"?"Teams":t==="cli"?"CLI":t==="mail"?"Mail":t==="voice"?"Voice":t}function cs(t){return t==="bluebubbles"?"imessage":t==="teams"?"teams":t==="cli"?"terminal":"default"}function ds(t){return t==="imessage"?"overflow-hidden rounded-xl bg-[#f5f5f7] text-[#1d1d1f] ring-1 ring-black/10":t==="teams"?"overflow-hidden rounded-xl bg-[#f7f5ff] text-[#242424] ring-1 ring-[#d8d1ff]":t==="terminal"?"overflow-hidden rounded-lg bg-[#050807] font-mono text-[#d1fae5] ring-1 ring-[#1f3a2c]":"overflow-hidden rounded-lg bg-ouro-void/60 text-ouro-bone ring-1 ring-ouro-moss/15"}function us(t){return t==="imessage"?"border-b border-black/10 bg-[#fbfbfd] px-4 py-3 text-center":t==="teams"?"border-b border-[#d8d1ff] bg-[#4f3bb3] px-4 py-3 text-white":t==="terminal"?"border-b border-[#1f3a2c] bg-[#101815] px-4 py-2 text-[#86efac]":"border-b border-ouro-moss/15 px-4 py-3"}function xs(t){return t==="imessage"?"max-w-[85%] sm:max-w-[75%] rounded-2xl rounded-bl-md bg-[#e9e9eb] px-3.5 py-2 text-[#1d1d1f]":t==="teams"?"max-w-[85%] sm:max-w-[75%] rounded-md bg-white px-3.5 py-2 text-[#242424] shadow-sm ring-1 ring-[#e5e5e5]":t==="terminal"?"max-w-full rounded-none border-l-2 border-[#60a5fa] bg-transparent px-3 py-2 text-[#dbeafe]":"max-w-[85%] sm:max-w-[75%] rounded-2xl rounded-bl-sm bg-ouro-moss/25 px-3.5 py-2 ring-1 ring-ouro-moss/15"}function me(t,s="normal"){return t==="imessage"?"max-w-[85%] sm:max-w-[75%] rounded-2xl rounded-br-md bg-[#0a84ff] px-3.5 py-2 text-white":t==="teams"?"max-w-[85%] sm:max-w-[75%] rounded-md bg-[#ede9fe] px-3.5 py-2 text-[#242424] shadow-sm ring-1 ring-[#c4b5fd]":t==="terminal"?"max-w-full rounded-none border-l-2 border-[#22c55e] bg-transparent px-3 py-2 text-[#bbf7d0]":s==="surface"?"max-w-[85%] sm:max-w-[75%] rounded-2xl rounded-br-sm bg-ouro-scale/12 px-3.5 py-2 ring-1 ring-ouro-scale/15":"max-w-[85%] sm:max-w-[75%] rounded-2xl rounded-br-sm bg-ouro-glow/8 px-3.5 py-2 ring-1 ring-ouro-glow/12"}function oe(t,s){return t==="imessage"?s==="agent"?"font-mono text-[9px] text-white/70":"font-mono text-[9px] text-[#6b7280]":t==="teams"?"font-mono text-[9px] uppercase tracking-wider text-[#5b5fc7]":t==="terminal"?s==="agent"?"font-mono text-[11px] text-[#22c55e]":"font-mono text-[11px] text-[#60a5fa]":s==="surface"||s==="agent"?"font-mono text-[9px] uppercase tracking-wider text-ouro-glow/70":"font-mono text-[9px] uppercase tracking-wider text-ouro-gold/70"}function re(t,s="agent"){return t==="imessage"?"text-sm leading-relaxed whitespace-pre-wrap break-words":t==="teams"?"text-sm leading-relaxed text-[#242424] whitespace-pre-wrap break-words":t==="terminal"?`font-mono text-[12px] leading-6 whitespace-pre-wrap break-words ${s==="agent"?"text-[#bbf7d0]":"text-[#dbeafe]"}`:"text-sm leading-relaxed text-ouro-bone whitespace-pre-wrap break-words"}function ms(t){return st(t)}function Y(t){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(ms(t)))}function hs({agentName:t,focus:s,onFocusConsumed:n,deskPrefs:a,refreshGeneration:r}){X();const[o,d]=l.useState(null),[b,x]=l.useState(null),[f,h]=l.useState(null),[w,A]=l.useState(!1),c=l.useRef(null);l.useEffect(()=>{L(`/agents/${encodeURIComponent(t)}/sessions`).then(d)},[t,r]),l.useEffect(()=>{s&&(c.current=null,x(s),h(null),A(!0),n==null||n())},[t,s,n]),l.useEffect(()=>{if(!b)return;const i=`${b}:${r}`;if(c.current===i)return;c.current=i,A(!0);const[S,T,z]=b.split("/");L(`/agents/${encodeURIComponent(t)}/sessions/${encodeURIComponent(S)}/${encodeURIComponent(T)}/${encodeURIComponent(z)}`).then(h).catch(()=>h(null)).finally(()=>A(!1))},[t,b,r,s]);function g(i){if(b===i){x(null),h(null),c.current=null;return}x(i),h(null),A(!0)}const m=new Set((a==null?void 0:a.starredFriends)??[]);if(!o)return e.jsx(at,{label:"Loading sessions"});const v=new Map;for(const i of o.items)v.has(i.friendId)||v.set(i.friendId,[]),v.get(i.friendId).push(i);const y=[...v.entries()].sort((i,S)=>{const T=m.has(i[0])?0:1,z=m.has(S[0])?0:1;return T!==z?T-z:S[1].length-i[1].length}),j=[],I=new Map;for(const[i,S]of y)I.set(j.length,{name:S[0].friendName,channels:S.length,starred:m.has(i)}),j.push(...S);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:[o.totalCount," sessions · ",o.activeCount," active · ",o.staleCount," stale"]}),e.jsx("div",{className:"space-y-1.5",children:j.map((i,S)=>{var E;const T=I.get(S),z=m.has(i.friendId),O=`${i.friendId}/${i.channel}/${i.key}`,p=b===O,u=De[i.replyState]??De.idle,N=((E=i.lastUsage)==null?void 0:E.total_tokens)??i.estimatedTokens??0,$=N>0?Math.min(100,Math.round(N/8e4*100)):0;return e.jsxs("div",{children:[T&&T.channels>1&&e.jsxs("div",{className:"flex items-center gap-2 pt-3 pb-1",children:[T.starred&&e.jsx("span",{className:"text-ouro-gold text-sm",children:"★"}),e.jsx("span",{className:"font-medium text-ouro-bone text-sm",children:T.name}),e.jsxs("span",{className:"text-xs text-ouro-shadow",children:[T.channels," channels"]})]}),e.jsxs("button",{onClick:()=>g(O),className:`flex w-full flex-col gap-1.5 rounded-lg px-3 py-3 text-left transition-colors ring-1 ${p?"bg-ouro-moss/15 ring-ouro-glow/20":"ring-ouro-moss/15 hover:bg-ouro-moss/8"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[z&&e.jsx("span",{className:"text-ouro-gold",title:"Starred",children:"★"}),e.jsx("span",{className:"truncate font-medium text-ouro-bone",children:i.friendName}),e.jsxs("span",{className:"shrink-0 text-xs text-ouro-shadow",children:["via ",rt(i.channel)]}),e.jsx(k,{color:u.color,children:u.label})]}),e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-ouro-shadow",children:M(i.lastActivityAt)})]}),i.latestUserExcerpt&&e.jsxs("p",{className:"truncate text-xs text-ouro-gold/70",children:[e.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wider",children:"in:"})," ",_(i.latestUserExcerpt,100)]}),i.latestAssistantExcerpt&&e.jsxs("p",{className:"truncate text-xs text-ouro-glow/60",children:[e.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wider",children:"out:"})," ",_(i.latestAssistantExcerpt,100)]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-ouro-shadow",children:[e.jsxs("span",{className:"tabular-nums",children:[i.messageCount," msgs"]}),i.lastUsage&&e.jsxs("span",{className:"tabular-nums",children:[i.lastUsage.total_tokens.toLocaleString()," tok"]}),$>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-1 max-w-32",title:"Context pressure — steady state oscillates between 80-100%",children:[e.jsx("div",{className:"h-1 flex-1 rounded-full bg-ouro-moss/20",children:e.jsx("div",{className:`h-1 rounded-full transition-all ${$>100?"bg-ouro-fang":$>80?"bg-ouro-gold":"bg-ouro-glow"}`,style:{width:`${Math.min(100,$)}%`}})}),e.jsxs("span",{className:"tabular-nums text-[10px]",children:[$,"%"]})]})]})]}),p&&e.jsx(ps,{loading:w,transcript:f})]},O)})})]})}function ps({loading:t,transcript:s}){var o;const n=((o=s==null?void 0:s.messages[s.messages.length-1])==null?void 0:o.id)??null,{ref:a,onScroll:r}=tt(n);return e.jsxs("div",{ref:a,"data-testid":"session-transcript-scroll",onScroll:r,className:"mt-1 max-h-[70vh] overflow-y-auto rounded-lg",children:[t&&!s&&e.jsx(at,{label:"Loading transcript"}),s&&e.jsx(gs,{transcript:s})]})}function gs({transcript:t}){const{messages:s,lastUsage:n}=t,a=cs(t.channel),r=s.filter(f=>f.role==="system"),o=s.filter(f=>f.role!=="system"),[d,b]=l.useState(!1),x=new Map;for(const f of o)f.role==="tool"&&f.toolCallId&&x.set(f.toolCallId,f);return e.jsxs("div",{className:ds(a),children:[e.jsxs("div",{className:us(a),children:[e.jsx("p",{className:a==="terminal"?"font-mono text-xs":"text-sm font-semibold",children:rt(t.channel)}),e.jsxs("p",{className:a==="terminal"?"mt-0.5 font-mono text-[10px] text-[#6ee7b7]":"mt-0.5 text-xs opacity-70",children:[t.friendName," · ",t.messageCount," messages"]})]}),e.jsxs("div",{className:"space-y-0.5 p-3",children:[n&&e.jsxs("p",{className:a==="terminal"?"pb-2 font-mono text-[10px] text-[#6ee7b7]":"pb-2 font-mono text-[10px] opacity-60",children:[n.input_tokens.toLocaleString()," in · ",n.output_tokens.toLocaleString()," out · ",n.total_tokens.toLocaleString()," total"]}),t.truncatedHistory&&e.jsx("p",{className:a==="terminal"?"pb-2 font-mono text-[10px] text-[#facc15]":"pb-2 font-mono text-[10px] text-ouro-gold/80",children:"Model context is trimmed; retained history is shown below."}),r.length>0&&e.jsxs("div",{className:"pb-2 mb-2 border-b border-current/10",children:[e.jsxs("button",{onClick:()=>b(!d),className:"font-mono text-[10px] uppercase tracking-wider opacity-60 transition-opacity hover:opacity-90",children:[d?"▼":"▶"," system context (",r.length,")"]}),d&&r.map(f=>e.jsxs("div",{className:"mt-2 max-h-60 overflow-y-auto rounded bg-black/5 p-2 text-xs opacity-75 whitespace-pre-wrap break-words",children:[e.jsx("p",{className:"mb-1 font-mono text-[9px] opacity-70",children:Y(f)}),ie(f)]},f.id))]}),o.map(f=>f.role==="tool"?null:f.role==="user"?e.jsx(fs,{msg:f,surface:a},f.id):f.role==="assistant"?e.jsx(bs,{msg:f,toolResults:x,surface:a},f.id):null)]})]})}function fs({msg:t,surface:s}){const n=ie(t);return e.jsx("div",{className:"flex justify-start py-1",children:e.jsxs("div",{className:xs(s),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("p",{className:oe(s,"user"),children:s==="terminal"?"human $":"user"}),e.jsxs("span",{className:"font-mono text-[9px] text-ouro-shadow/40",children:["#",t.sequence]}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:Y(t)})]}),e.jsx("p",{className:re(s,"user"),children:n})]})})}function bs({msg:t,toolResults:s,surface:n}){const a=ie(t),r=(t.toolCalls??[]).map(Se),o=r.filter(x=>x.kind!=="action"),d=r.filter(x=>x.kind==="action"),b=[];for(const x of o)x.kind==="response"?b.push(e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:me(n),children:[e.jsxs("div",{className:"mb-0.5 flex items-center gap-2",children:[e.jsx("p",{className:oe(n,"agent"),children:n==="terminal"?"agent >":"agent"}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:Y(t)})]}),e.jsx("p",{className:re(n),children:x.deliveredText}),x.metadata&&x.metadata!=="complete"&&e.jsxs("p",{className:"mt-1 font-mono text-[9px] text-ouro-shadow",children:["intent: ",x.metadata]})]})},x.id)):x.kind==="delegation"?b.push(e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:me(n),children:[e.jsxs("div",{className:"mb-0.5 flex items-center gap-2",children:[e.jsx("p",{className:oe(n,"agent"),children:n==="terminal"?"agent >":"agent"}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:Y(t)})]}),x.deliveredText&&e.jsx("p",{className:re(n),children:x.deliveredText}),x.delegatedThought&&e.jsxs("div",{className:"mt-2 rounded bg-black/10 px-2.5 py-1.5 ring-1 ring-current/10",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider opacity-70",children:"→ private runtime"}),e.jsx("p",{className:"mt-0.5 text-xs opacity-80",children:x.delegatedThought})]})]})},x.id)):x.kind==="surface"?b.push(e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:me(n,"surface"),children:[e.jsxs("div",{className:"mb-0.5 flex items-center gap-2",children:[e.jsx("p",{className:oe(n,"surface"),children:"surfaced"}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:Y(t)})]}),e.jsx("p",{className:re(n),children:x.deliveredText}),x.metadata&&e.jsxs("p",{className:"mt-1 font-mono text-[9px] text-ouro-shadow",children:["→ ",x.metadata]})]})},x.id)):x.kind==="rest"?b.push(e.jsx("div",{className:"py-1 text-center font-mono text-[10px] text-ouro-shadow/50",children:"— resting —"},x.id)):x.kind==="observe"&&b.push(e.jsxs("div",{className:"py-1 text-center font-mono text-[10px] text-ouro-shadow/50",children:["— observed",x.metadata?`: ${x.metadata}`:""," —"]},x.id));return a&&o.length===0&&b.push(e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:me(n),children:[e.jsxs("div",{className:"mb-0.5 flex items-center gap-2",children:[e.jsx("p",{className:oe(n,"agent"),children:n==="terminal"?"agent >":"agent"}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:Y(t)})]}),e.jsx("p",{className:re(n),children:a})]})},`${t.id}-content`)),d.length>0&&b.push(e.jsx("div",{className:"flex justify-end py-1",children:e.jsx("div",{className:"max-w-[85%] sm:max-w-[75%] space-y-1",children:d.map(x=>e.jsx(vs,{call:x,result:s.get(x.id),surface:n},x.id))})},`${t.id}-tools`)),e.jsx(e.Fragment,{children:b})}function vs({call:t,result:s,surface:n}){const[a,r]=l.useState(!1),o=s?ie(s):null;return e.jsxs("button",{onClick:()=>r(!a),className:`w-full text-left rounded px-2.5 py-1.5 text-sm transition-colors ${n==="terminal"?"bg-[#0f1a15] font-mono text-[#bbf7d0] ring-1 ring-[#1f3a2c] hover:ring-[#22c55e]/40":n==="teams"?"bg-white text-[#242424] ring-1 ring-[#d8d1ff] hover:ring-[#5b5fc7]/40":n==="imessage"?"bg-white text-[#1d1d1f] ring-1 ring-black/10 hover:ring-[#0a84ff]/30":"bg-ouro-moss/10 ring-1 ring-ouro-moss/12 hover:ring-ouro-glow/15"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-ouro-glow",children:t.name}),!a&&e.jsx("span",{className:"text-[10px] text-ouro-shadow",children:"tap to inspect"})]}),a&&e.jsxs(e.Fragment,{children:[t.rawArgs&&e.jsx("pre",{className:"mt-1.5 max-h-24 overflow-y-auto rounded bg-ouro-void/40 p-1.5 font-mono text-[11px] text-ouro-shadow whitespace-pre-wrap break-words",children:t.rawArgs}),s&&e.jsxs("div",{className:"mt-1.5 border-t border-ouro-moss/15 pt-1.5",children:[e.jsx(k,{children:"result"}),e.jsx("pre",{className:"mt-1 max-h-32 overflow-y-auto rounded bg-ouro-void/40 p-1.5 font-mono text-[11px] text-ouro-mist whitespace-pre-wrap break-words",children:o})]})]})]})}function at({label:t}){return e.jsxs("div",{className:"flex items-center gap-2 py-6",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-ouro-glow"}),e.jsxs("span",{className:"font-mono text-xs text-ouro-shadow",children:[t,"…"]})]})}function js({agentName:t,view:s,focus:n,onFocusConsumed:a,refreshGeneration:r}){var z,O;const o=X(),[d,b]=l.useState(null),[x,f]=l.useState(null),[h,w]=l.useState(null),[A,c]=l.useState(null),[g,m]=l.useState(null),v=s.work,y=v.obligations,j=v.tasks;l.useEffect(()=>{let p=!1;return b(null),f(null),w(null),c(null),m(null),L(`/agents/${encodeURIComponent(t)}/coding`).then(u=>{p||b(u)}).catch(()=>{}),L(`/agents/${encodeURIComponent(t)}/obligations`).then(u=>{p||f(u)}).catch(()=>{}),L(`/agents/${encodeURIComponent(t)}/self-fix`).then(u=>{p||w(u)}).catch(()=>{}),L(`/agents/${encodeURIComponent(t)}/sentinel`).then(u=>{p||(c(u),m(null))}).catch(u=>{p||(c(null),m(u instanceof Error?u.message:"sentinel unavailable"))}),()=>{p=!0}},[t,r]);const I=(x==null?void 0:x.items)??y.items,i=(x==null?void 0:x.openCount)??y.openCount,S=(d==null?void 0:d.items)??[],T=new Map;for(const p of S){const u=p.obligationId;if(u){const N=T.get(u);N?N.push(p):T.set(u,[p])}}return e.jsxs("div",{className:"space-y-8",children:[(A||g)&&e.jsxs("section",{children:[e.jsx(se,{label:"Recovery Sentinel"}),e.jsx(ws,{view:A,error:g})]}),e.jsxs("section",{children:[e.jsx(se,{label:`Obligations (${i} open)`}),(x==null?void 0:x.primarySelectionReason)&&e.jsxs("p",{className:"mt-1 text-xs text-ouro-shadow",children:["Primary: ",x.primarySelectionReason]}),I.length>0?e.jsx("div",{className:"mt-3 space-y-3",children:I.map(p=>{const u=T.get(p.id)??[],N=Cs(p)?p:null,R=(N==null?void 0:N.isPrimary)??!1,$=(N==null?void 0:N.meaning)??null,E=p.origin;return e.jsxs("div",{className:`rounded-lg px-3 py-3 ring-1 ${R?"bg-ouro-glow/5 ring-ouro-glow/20":"bg-ouro-void/40 ring-ouro-moss/15"}`,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[R&&e.jsx(k,{color:"lime",children:"primary"}),e.jsx(k,{color:p.status==="pending"?"yellow":p.status==="fulfilled"?"lime":"zinc",children:p.status}),e.jsx("span",{className:"text-sm font-medium text-ouro-bone",children:_(p.content,120)})]}),E&&e.jsxs("button",{onClick:()=>o({tab:"sessions",focus:`${E.friendId}/${E.channel}/${E.key}`}),className:"mt-2 flex w-full items-center gap-2 rounded-md bg-ouro-moss/8 px-2.5 py-1.5 text-left text-xs ring-1 ring-ouro-moss/10 hover:ring-ouro-glow/20 transition-colors",children:[e.jsx("span",{className:"text-ouro-shadow",children:"from"}),e.jsx("span",{className:"font-medium text-ouro-glow",children:E.channel}),e.jsx("span",{className:"text-ouro-shadow",children:"→"}),e.jsx("span",{className:"text-ouro-mist truncate",children:E.key}),e.jsx("span",{className:"ml-auto text-ouro-shadow",children:"open session →"})]}),p.currentSurface&&e.jsxs("div",{className:"mt-1 text-xs text-ouro-mist",children:["surface: ",e.jsx("span",{className:"text-ouro-bone",children:p.currentSurface.kind})," — ",p.currentSurface.label]}),($==null?void 0:$.waitingOn)&&e.jsxs("p",{className:"mt-1 text-xs text-ouro-shadow",children:["Waiting on: ",$.waitingOn]}),u.length>0&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:"Linked coding"}),u.map(q=>e.jsxs("div",{className:"flex items-center gap-2 rounded bg-ouro-moss/10 px-2 py-1 text-xs",children:[e.jsx(k,{color:q.status==="failed"?"red":q.status==="running"?"lime":"zinc",children:q.status}),e.jsxs("span",{className:"text-ouro-mist truncate",children:[q.runner," — ",q.workdir]})]},q.id))]}),p.nextAction&&e.jsxs("p",{className:"mt-1.5 text-xs text-ouro-mist",children:["Next: ",p.nextAction]}),e.jsx("p",{className:"mt-1 text-xs text-ouro-shadow",children:M(p.updatedAt)})]},p.id)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No open obligations."})]}),h&&h.steps.length>0&&e.jsxs("section",{children:[e.jsx(se,{label:`Self-fix ${h.active?"(active)":"(inactive)"}`}),h.currentStep&&e.jsxs("p",{className:"mt-1 text-xs text-ouro-glow",children:["Current: ",h.currentStep]}),e.jsx("div",{className:"mt-3 space-y-1.5",children:h.steps.map((p,u)=>e.jsxs("div",{className:`flex items-center gap-2.5 rounded-lg px-3 py-2 ring-1 ${p.status==="active"?"bg-ouro-glow/5 ring-ouro-glow/20":p.status==="done"?"bg-ouro-void/40 ring-ouro-glow/10":"bg-ouro-void/40 ring-ouro-moss/10"}`,children:[e.jsx(k,{color:p.status==="done"?"lime":p.status==="active"?"yellow":(p.status==="skipped","zinc"),children:p.status}),e.jsx("span",{className:`text-sm ${p.status==="active"?"font-medium text-ouro-bone":"text-ouro-mist"}`,children:p.label}),p.detail&&e.jsx("span",{className:"ml-auto text-xs text-ouro-shadow",children:p.detail})]},u))})]}),e.jsxs("section",{children:[e.jsx(se,{label:`Coding lanes (${S.length})`}),S.length>0?e.jsx("div",{className:"mt-3 space-y-2",children:S.map(p=>{const u=p.status,N=u==="failed",R=p.failure,$=p.obligationId,E=p.originSession;return e.jsxs("div",{className:"rounded-lg bg-ouro-void/40 px-3 py-3 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{color:N?"red":u==="running"?"lime":u==="completed"?"zinc":"yellow",children:u}),e.jsx("span",{className:"text-sm font-medium text-ouro-bone",children:p.runner}),e.jsx("span",{className:"truncate text-xs text-ouro-shadow",children:p.workdir})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-2",children:[$&&e.jsxs("button",{onClick:()=>o({tab:"work",focus:$}),className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:["obligation: ",$.slice(0,20),"…"]}),p.taskRef&&e.jsxs("span",{className:"text-xs text-ouro-glow",children:["task: ",p.taskRef]}),E&&e.jsx("button",{onClick:()=>{o({tab:"sessions",focus:`${E.friendId}/${E.channel}/${E.key}`})},className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:"origin session"})]}),p.checkpoint&&e.jsx("p",{className:"mt-1.5 text-xs text-ouro-mist",children:_(p.checkpoint,100)}),e.jsxs("p",{className:"mt-1 text-xs text-ouro-shadow",children:["pid ",p.pid??"–"," · restarts ",p.restartCount," · ",M(p.lastActivityAt)]}),N&&R&&e.jsxs("div",{className:"mt-2 rounded bg-ouro-fang/5 p-2 text-xs ring-1 ring-ouro-fang/15",children:[e.jsx("span",{className:"font-semibold text-ouro-fang",children:"FAILURE:"})," ",e.jsxs("span",{className:"text-ouro-mist",children:[R.command," exited ",String(R.code??R.signal)]}),R.stderrTail&&e.jsx("pre",{className:"mt-1 max-h-20 overflow-y-auto font-mono text-[11px] text-ouro-shadow whitespace-pre-wrap",children:R.stderrTail})]})]},p.id)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No coding sessions."})]}),e.jsxs("section",{children:[e.jsx(se,{label:`Tasks (${j.liveCount} live, ${j.blockedCount} blocked)`}),((z=j.liveTaskNames)==null?void 0:z.length)>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:j.liveTaskNames.map(p=>e.jsx(k,{children:p},p))}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No live tasks."}),((O=j.actionRequired)==null?void 0:O.length)>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-ouro-fang",children:"Action required"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:j.actionRequired.map(p=>e.jsx(k,{color:"red",children:p},p))})]})]})]})}function se({label:t}){return e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:t})}function ws({view:t,error:s}){const n=(t==null?void 0:t.latest)??null,a=(t==null?void 0:t.latestReady)??null,r=new Set([n,a].filter(d=>!!d).map(be)),o=((t==null?void 0:t.history)??[]).filter(d=>!r.has(be(d)));return e.jsx("div",{className:"mt-3 rounded-lg bg-ouro-void/40 px-3 py-3 ring-1 ring-ouro-moss/15",children:s&&!t?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{color:"red",children:"unavailable"}),e.jsx("span",{className:"min-w-0 flex-1 break-words text-sm text-ouro-mist",children:s})]}):t?e.jsxs(e.Fragment,{children:[s&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2 border-b border-ouro-moss/10 pb-2",children:[e.jsx(k,{color:"red",children:"unavailable"}),e.jsx("span",{className:"min-w-0 flex-1 break-words text-xs text-ouro-mist",children:s})]}),n?e.jsx(qe,{label:"Latest",receipt:n,prominent:!0}):e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{children:"missing"}),e.jsx("span",{className:"text-sm text-ouro-shadow",children:"Latest"})]}),a&&e.jsx("div",{className:"mt-3 border-t border-ouro-moss/10 pt-3",children:e.jsx(qe,{label:"Latest ready",receipt:a})}),o.length>0&&e.jsxs("div",{className:"mt-3 border-t border-ouro-moss/10 pt-3",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:"History"}),e.jsx("div",{className:"mt-2 divide-y divide-ouro-moss/10",children:o.map(d=>e.jsx(ys,{receipt:d},be(d)))})]}),t.degraded.issues.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 border-t border-ouro-moss/10 pt-3",children:[e.jsx(k,{color:"yellow",children:"degraded"}),t.degraded.issues.map(d=>e.jsx("span",{className:"break-words text-xs text-ouro-shadow",children:d},d))]})]}):null})}function qe({label:t,receipt:s,prominent:n=!1}){return e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:t}),e.jsx(k,{color:it(s.verdict),children:s.verdict}),e.jsx("span",{className:"font-mono text-xs text-ouro-bone",children:lt(s.trigger)}),e.jsxs("span",{className:"text-xs text-ouro-shadow",children:["updated ",M(s.generatedAt)]})]}),e.jsx("p",{className:`${n?"mt-2 text-sm font-medium text-ouro-bone":"mt-1.5 text-sm text-ouro-mist"} break-words`,children:s.summary}),e.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[e.jsx(Fe,{label:"Current ask",value:s.recoveryAnchor.currentAsk}),e.jsx(Fe,{label:"Next safe action",value:s.recoveryAnchor.nextSafeAction})]}),s.signals.length>0&&e.jsx("div",{className:"mt-3 divide-y divide-ouro-moss/10 border-t border-ouro-moss/10 pt-1",children:s.signals.map(a=>e.jsx(Ns,{signal:a},a.id))}),Be(s.sourceLocators).length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1",children:[e.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:"Sources"}),Be(s.sourceLocators).map(a=>e.jsx("span",{className:"max-w-full truncate font-mono text-[10px] text-ouro-moss",children:a},a))]})]})}function Fe({label:t,value:s}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:t}),e.jsx("p",{className:"mt-1 break-words text-sm text-ouro-bone",children:s?_(s,140):"unknown"})]})}function Ns({signal:t}){return e.jsxs("div",{className:"grid gap-2 py-2 md:grid-cols-[150px_1fr] md:items-start",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{color:ks(t),children:t.status}),e.jsx("span",{className:"font-mono text-[10px] text-ouro-shadow",children:t.kind.replace(/_/g," ")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"break-words text-xs text-ouro-mist",children:t.summary}),e.jsx("p",{className:"mt-1 truncate font-mono text-[10px] text-ouro-moss",children:t.source.locator}),t.repair&&e.jsxs("p",{className:"mt-1 break-words text-xs text-ouro-shadow",children:[t.repair.actor,": ",t.repair.command??t.repair.detail]})]})]})}function ys({receipt:t}){var n;const s=((n=t.signals[0])==null?void 0:n.summary)??null;return e.jsxs("div",{className:"grid gap-2 py-2 md:grid-cols-[120px_110px_1fr] md:items-start",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(k,{color:it(t.verdict),children:t.verdict})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-mono text-xs text-ouro-bone",children:lt(t.trigger)}),e.jsx("p",{className:"text-[10px] text-ouro-shadow",children:M(t.generatedAt)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"break-words text-xs text-ouro-mist",children:t.summary}),s&&e.jsx("p",{className:"mt-1 break-words text-xs text-ouro-shadow",children:s}),e.jsx("p",{className:"mt-1 truncate font-mono text-[10px] text-ouro-moss",children:t.receiptLocator})]})]})}function it(t){return t==="ready"?"lime":t==="watch"?"yellow":"red"}function ks(t){return t.status==="fail"||t.severity==="critical"?"red":t.status==="warn"||t.severity==="warn"?"yellow":"lime"}function be(t){return t.receiptLocator||t.id}function Be(t){return Array.from(new Set(t.filter(Boolean)))}function lt(t){return t.replace(/_/g," ")}function Cs(t){return"isPrimary"in t}function Ss({agentName:t,focus:s,onFocusConsumed:n,refreshGeneration:a}){const r=X(),[o,d]=l.useState(null),[b,x]=l.useState(null),[f,h]=l.useState(null);l.useEffect(()=>{const g=`/agents/${encodeURIComponent(t)}`;Promise.all([L(`${g}/attention`).then(d),L(`${g}/bridges`).then(x),L(`${g}/friends`).then(h)])},[t,a]);const w=(o==null?void 0:o.queueItems)??[],A=(b==null?void 0:b.items)??[],c=(f==null?void 0:f.friends)??[];return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsx(ve,{label:`Who is waiting (${(o==null?void 0:o.queueLength)??0})`}),w.length>0?e.jsx("div",{className:"mt-3 space-y-2",children:w.map((g,m)=>{const v=g.bridgeId,y=g.obligationId;return e.jsxs("div",{className:"rounded-lg bg-ouro-void/40 px-3 py-3 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>r({tab:"sessions"}),className:"font-medium text-ouro-bone hover:text-ouro-glow transition-colors",children:g.friendName}),e.jsxs("span",{className:"text-xs text-ouro-shadow",children:["via ",g.channel]}),e.jsxs(k,{color:"yellow",children:["waiting ",M(new Date(g.timestamp).toISOString())]})]}),e.jsx("p",{className:"mt-1 text-sm text-ouro-mist",children:_(g.delegatedContent,140)}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-2 text-xs",children:[v&&e.jsxs("button",{onClick:()=>r({tab:"connections",focus:v}),className:"text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:["bridge: ",v.slice(0,12),"…"]}),y&&e.jsxs("button",{onClick:()=>r({tab:"work",focus:y}),className:"text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:["obligation: ",y.slice(0,16),"…"]})]})]},m)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"Nobody waiting."})]}),e.jsxs("section",{children:[e.jsx(ve,{label:`Bridges (${(b==null?void 0:b.totalCount)??0})`}),A.length>0?e.jsx("div",{className:"mt-3 space-y-3",children:A.map(g=>{const m=g.attachedSessions,v=g.task,y=g.lifecycle==="active";return e.jsxs("div",{className:`rounded-lg px-3 py-3 ring-1 ${y?"bg-ouro-moss/10 ring-ouro-glow/12":"bg-ouro-void/40 ring-ouro-moss/15"}`,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(k,{color:y?"lime":"zinc",children:g.lifecycle}),e.jsx("p",{className:"font-medium text-ouro-bone",children:g.objective})]}),g.summary&&e.jsx("p",{className:"mt-1 text-sm text-ouro-mist",children:_(g.summary,160)}),m.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:m.map((j,I)=>e.jsxs("button",{onClick:()=>r({tab:"sessions",focus:`${j.friendId}/${j.channel}/${j.key}`}),className:"rounded-md bg-ouro-moss/10 px-2 py-0.5 font-mono text-[11px] text-ouro-glow ring-1 ring-ouro-moss/12 hover:ring-ouro-glow/25 transition-colors",children:[j.friendId,"/",j.channel,"/",j.key]},I))}),v&&e.jsxs("p",{className:"mt-1.5 text-xs",children:[e.jsxs("button",{onClick:()=>r({tab:"work"}),className:"text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:["task: ",v.taskName]}),e.jsxs("span",{className:"text-ouro-shadow",children:[" (",v.mode,")"]})]}),e.jsx("p",{className:"mt-1 text-xs text-ouro-shadow",children:M(g.updatedAt)})]},g.id)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No bridges."})]}),e.jsxs("section",{children:[e.jsx(ve,{label:`Friends (${(f==null?void 0:f.totalFriends)??0})`}),c.length>0?e.jsx("div",{className:"mt-3 space-y-1.5",children:c.map(g=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-ouro-void/40 px-3 py-2.5 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("button",{onClick:()=>r({tab:"sessions"}),className:"font-medium text-ouro-bone hover:text-ouro-glow transition-colors",children:g.friendName}),e.jsxs("p",{className:"text-xs text-ouro-shadow",children:[g.channels.join(", ")," · ",g.sessionCount," sessions",g.lastActivityAt&&e.jsxs(e.Fragment,{children:[" · ",M(g.lastActivityAt)]})]})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("p",{className:"tabular-nums text-sm font-medium text-ouro-bone",children:g.totalTokens.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-ouro-shadow",children:"tokens"})]})]},g.friendId))}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No friends."})]})]})}function ve({label:t}){return e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:t})}function $s(t){return st(t)}function ne(t){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date($s(t)))}function As({agentName:t,view:s,refreshGeneration:n}){const a=X(),[r,o]=l.useState(null),[d,b]=l.useState(null),[x,f]=l.useState(!1),[h,w]=l.useState(null),[A,c]=l.useState(!1),g=l.useRef(null),m=s.inner;l.useEffect(()=>{L(`/agents/${encodeURIComponent(t)}/habits`).then(o)},[t,n]),l.useEffect(()=>{let p=!1;return f(!1),b(null),L(`/agents/${encodeURIComponent(t)}/habit-runs`).then(u=>{p||b(u)}).catch(()=>{p||f(!0)}),()=>{p=!0}},[t,n]),l.useEffect(()=>{h&&g.current!==n&&(g.current=n,L(`/agents/${encodeURIComponent(t)}/inner-transcript`).then(w))},[t,n,h!==null]);function v(){if(h){c(!A);return}L(`/agents/${encodeURIComponent(t)}/inner-transcript`).then(p=>{g.current=n,w(p),c(!0)})}const y=(r==null?void 0:r.items)??[],j=(d==null?void 0:d.items)??[],I=y.filter(p=>p.isOverdue),i=y.filter(p=>p.status==="active"&&!p.isOverdue),S=y.filter(p=>p.status==="paused"),T=m.mode==="deep"?m.origin:null,z=m.mode==="deep"?m.obligationStatus:null,O=y.find(p=>p.name.toLowerCase()==="heartbeat");return e.jsxs("div",{className:"space-y-8",children:[O&&e.jsxs("section",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Heartbeat"}),e.jsx("div",{className:`mt-2 rounded-xl p-4 ring-1 ${O.isOverdue?"bg-ouro-fang/5 ring-ouro-fang/15":"bg-ouro-moss/10 ring-ouro-glow/10"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${O.isOverdue?"bg-ouro-fang animate-pulse":"bg-ouro-glow"}`}),e.jsx("span",{className:"font-medium text-ouro-bone",children:O.isOverdue?"Overdue":"Healthy"}),e.jsxs("span",{className:"text-xs text-ouro-shadow",children:["every ",O.cadence??"unknown"," · last ",O.lastRun?M(O.lastRun):"never"]})]})})]}),e.jsx("section",{children:e.jsxs("div",{className:"rounded-xl bg-ouro-moss/15 p-4 ring-1 ring-ouro-glow/10",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:"Private runtime work"}),e.jsx("p",{className:"mt-1 font-display text-xl italic font-semibold text-ouro-bone",children:m.status}),m.summary&&e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-ouro-mist",children:m.summary}),e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:m.hasPending?"Private runtime work queued.":"No private runtime work."}),(m.returnObligationQueue.queuedCount>0||m.returnObligationQueue.runningCount>0)&&e.jsxs("p",{className:"mt-1 text-sm text-ouro-mist",children:["Held work items:"," ",e.jsx("span",{className:"font-medium text-ouro-bone",children:m.returnObligationQueue.queuedCount+m.returnObligationQueue.runningCount})," ","(",m.returnObligationQueue.queuedCount," queued",m.returnObligationQueue.runningCount>0?`, ${m.returnObligationQueue.runningCount} running`:"",")",m.returnObligationQueue.oldestActiveAt!==null&&e.jsxs("span",{className:"text-ouro-shadow",children:[" · oldest ",M(new Date(m.returnObligationQueue.oldestActiveAt).toISOString())]})]}),T&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:"Triggered from"}),e.jsxs("button",{onClick:()=>{a({tab:"sessions",focus:`${T.friendId}/${T.channel}/${T.key}`})},className:"mt-1 text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:[T.friendId.slice(0,8),"…/",T.channel,"/",T.key]}),z&&e.jsxs("button",{onClick:()=>a({tab:"work"}),className:"ml-2 text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:["obligation: ",z]})]})]})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Habit sessions"}),e.jsx("p",{className:"mt-1 text-xs text-ouro-shadow",children:d?`${d.totalCount} recorded`:x?"Run history unavailable":"Loading runs"})]}),d&&d.totalCount>j.length&&e.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-ouro-shadow",children:["showing ",j.length,"/",d.totalCount]})]}),d?j.length>0?e.jsx("div",{className:"mt-3 space-y-2",children:j.map(p=>e.jsx(Is,{run:p},p.runId))}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No habit sessions recorded."}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:x?"Habit sessions unavailable.":"Loading habit sessions."})]}),e.jsxs("section",{children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:["Private runtime ",h?`(${h.messages.length} total)`:""]}),h?e.jsx(Ts,{messages:h.messages}):e.jsx("button",{onClick:v,className:"mt-2 w-full rounded-lg px-3 py-2.5 text-left font-mono text-xs text-ouro-glow ring-1 ring-ouro-moss/15 hover:ring-ouro-glow/20 transition-colors",children:"Load private runtime"})]}),e.jsxs("section",{children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:["Habits (",(r==null?void 0:r.totalCount)??0,")"]}),I.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-fang mb-1.5",children:["Overdue (",I.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:I.map(p=>e.jsx(we,{h:p},p.name))})]}),i.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-glow mb-1.5",children:["Running fine (",i.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:i.map(p=>e.jsx(we,{h:p},p.name))})]}),S.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow mb-1.5",children:["Paused (",S.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:S.map(p=>e.jsx(we,{h:p},p.name))})]}),y.length===0&&e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No habits configured."})]})]})}function Rs(t){return t==="error"||t==="blocked"?"bad":t==="surfaced"||t==="wrote_arc"||t==="updated_desk"||t==="wrote_record"?"good":t==="no_change"?"quiet":"warn"}function zs(t){const s=Rs(t);return s==="bad"?"bg-ouro-fang/10 text-ouro-fang ring-ouro-fang/20":s==="good"?"bg-ouro-scale/10 text-ouro-glow ring-ouro-scale/20":s==="warn"?"bg-ouro-gold/10 text-ouro-gold ring-ouro-gold/20":"bg-ouro-void/60 text-ouro-shadow ring-ouro-moss/15"}function Is({run:t}){const s=t.permissionEnvelope.returnRoutes,n=t.surfaceAttempts,a=t.errors??[],r=Array.from(new Set([...t.permissionEnvelope.deniedTools,...t.toolPolicy.deniedTools]));return e.jsxs("article",{className:"rounded-lg bg-ouro-void/45 px-3 py-3 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`rounded-md px-2 py-0.5 font-mono text-[10px] font-medium uppercase tracking-wider ring-1 ${zs(t.outcome)}`,children:t.outcome}),e.jsx("span",{className:"min-w-0 break-all font-medium text-ouro-bone",children:t.habitName}),e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wider text-ouro-shadow",children:t.trigger})]}),e.jsx("p",{className:"mt-1 font-mono text-[11px] text-ouro-shadow break-all",children:t.runId})]}),e.jsxs("div",{className:"shrink-0 text-left sm:text-right",children:[e.jsx("p",{className:"font-mono text-[10px] text-ouro-shadow",children:M(t.endedAt)}),t.nextRunAt&&e.jsxs("p",{className:"font-mono text-[10px] text-ouro-glow",children:["next ",M(t.nextRunAt)]})]})]}),e.jsxs("div",{className:"mt-3 grid gap-2 lg:grid-cols-3",children:[e.jsxs(je,{label:"routes",children:[s.length>0?e.jsx("div",{className:"space-y-1.5",children:s.map((o,d)=>e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx("span",{className:"max-w-full break-all rounded bg-ouro-moss/20 px-1.5 py-0.5 font-mono text-[10px] text-ouro-mist ring-1 ring-ouro-moss/20",children:o.kind}),e.jsx("span",{className:"max-w-full break-all rounded bg-ouro-void/60 px-1.5 py-0.5 font-mono text-[10px] text-ouro-shadow ring-1 ring-ouro-moss/15",children:o.status})]}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-ouro-shadow break-all",children:o.recipient}),(o.friendId||o.channel||o.key)&&[o.friendId,o.channel,o.key].filter(Boolean).join("/")!==o.recipient&&e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-ouro-shadow/70 break-all",children:[o.friendId,o.channel,o.key].filter(Boolean).join("/")}),o.reason&&e.jsx("p",{className:"mt-0.5 text-[11px] text-ouro-shadow break-words",children:o.reason})]},`${o.kind}-${o.recipient}-${d}`))}):e.jsx("span",{className:"text-ouro-shadow",children:"none"}),e.jsxs("p",{className:"mt-1 text-[11px] text-ouro-shadow",children:["outward ",t.permissionEnvelope.canMessageOutward?"allowed":"closed"]}),t.permissionEnvelope.warnings.length>0&&e.jsx("div",{className:"mt-1.5 space-y-1",children:t.permissionEnvelope.warnings.map((o,d)=>e.jsx("p",{className:"text-[11px] text-ouro-gold break-words",children:o},`${o}-${d}`))})]}),e.jsx(je,{label:"attempts",children:n.length>0?e.jsx("div",{className:"space-y-1",children:n.map((o,d)=>e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"rounded bg-ouro-moss/20 px-1.5 py-0.5 font-mono text-[10px] text-ouro-bone ring-1 ring-ouro-moss/20",children:o.result}),e.jsx("span",{className:"text-[11px] text-ouro-shadow",children:o.reason})]}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-ouro-shadow break-all",children:[o.recipient,"/",o.channel,o.error?` - ${o.error}`:""]})]},`${o.recipient}-${o.channel}-${d}`))}):e.jsx("span",{className:"text-ouro-shadow",children:"none"})}),e.jsxs(je,{label:"tools",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.toolPolicy.grantedTools.map(o=>e.jsx("span",{className:"max-w-full break-all rounded bg-ouro-scale/10 px-1.5 py-0.5 font-mono text-[10px] text-ouro-glow ring-1 ring-ouro-scale/15",children:o},`granted-${o}`)),r.map(o=>e.jsx("span",{className:"max-w-full break-all rounded bg-ouro-fang/8 px-1.5 py-0.5 font-mono text-[10px] text-ouro-fang ring-1 ring-ouro-fang/15",children:o},`denied-${o}`)),t.toolPolicy.grantedTools.length===0&&r.length===0&&e.jsx("span",{className:"text-ouro-shadow",children:"none"})]}),t.errorCount>0&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] text-ouro-fang",children:[t.errorCount," error",t.errorCount===1?"":"s"]}),a.length>0&&e.jsx("div",{className:"mt-1 space-y-1",children:a.map((o,d)=>e.jsx("p",{className:"max-w-full break-words font-mono text-[10px] text-ouro-fang",children:o},`${t.runId}-error-${d}`))})]})]}),(t.producedRefs.length>0||t.receiptLocator)&&e.jsxs("div",{className:"mt-3 border-t border-ouro-moss/15 pt-2",children:[t.producedRefs.length>0&&e.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:t.producedRefs.map((o,d)=>e.jsxs("span",{className:"max-w-full break-all rounded bg-ouro-void/60 px-1.5 py-0.5 font-mono text-[10px] text-ouro-shadow ring-1 ring-ouro-moss/10",children:[o.kind,": ",o.locator]},`${o.kind}-${o.locator}-${d}`))}),e.jsx("p",{className:"font-mono text-[10px] text-ouro-shadow break-all",children:t.receiptLocator})]})]})}function je({label:t,children:s}){return e.jsxs("div",{className:"min-w-0 border-l border-ouro-moss/15 pl-2.5",children:[e.jsx("p",{className:"mb-1 font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:t}),e.jsx("div",{className:"min-w-0 text-xs text-ouro-mist",children:s})]})}function Ts({messages:t}){var A;const s=t.filter(c=>c.role!=="system"&&c.role!=="tool"),[n,a]=l.useState(!1),r=n?s:s.slice(-30),o=s.length-r.length,d=((A=r[r.length-1])==null?void 0:A.id)??null,{ref:b,onScroll:x,preserveScroll:f}=tt(d),h=[];for(const c of s){if(c.role!=="assistant")continue;const g=(c.toolCalls??[]).map(Se);for(const m of g)m.kind==="surface"&&h.push({index:c.sequence,kind:"surfaced",label:_(m.deliveredText??"",40)}),m.kind==="rest"&&h.push({index:c.sequence,kind:"resting",label:"resting"}),m.kind==="delegation"&&h.push({index:c.sequence,kind:"delegated",label:"continued thinking"})}function w(c){var m;const g=(m=b.current)==null?void 0:m.querySelector(`[data-msg-index="${c}"]`);g&&g.scrollIntoView({behavior:"smooth",block:"center"})}return e.jsxs("div",{children:[h.length>0&&e.jsx("div",{className:"mt-2 mb-1 flex flex-wrap gap-1",children:h.map((c,g)=>e.jsxs("button",{onClick:()=>{f(),a(!0),setTimeout(()=>w(c.index),100)},className:`rounded-md px-2 py-0.5 text-[10px] font-mono ring-1 transition-colors ${c.kind==="surfaced"?"bg-ouro-scale/10 text-ouro-glow ring-ouro-scale/20 hover:ring-ouro-glow/30":c.kind==="resting"?"bg-ouro-void/40 text-ouro-shadow ring-ouro-moss/10":"bg-ouro-gold/5 text-ouro-gold ring-ouro-gold/10"}`,children:[c.kind==="surfaced"?"★":c.kind==="resting"?"—":"→"," #",c.index]},g))}),e.jsxs("div",{ref:b,"data-testid":"inner-transcript-scroll",onScroll:x,className:"max-h-[60vh] overflow-y-auto rounded-lg bg-ouro-void/60 p-3 ring-1 ring-ouro-moss/15 space-y-1",children:[o>0&&e.jsxs("button",{onClick:()=>{f(),a(!0)},className:"w-full rounded-lg px-3 py-2 text-center font-mono text-xs text-ouro-shadow hover:text-ouro-mist ring-1 ring-ouro-moss/10 hover:ring-ouro-moss/20 transition-colors mb-2",children:["Load ",o," earlier messages"]}),r.map(c=>{const g=ie(c);if(c.role==="user"){const m=g.includes("[pending from")||g.includes("[delegated"),v=g.includes("waking up")||g.includes("world-state checkpoint");return e.jsx("div",{"data-msg-index":c.sequence,className:"flex justify-start py-1",children:e.jsxs("div",{className:`max-w-[85%] rounded-2xl rounded-bl-sm px-3 py-2 ring-1 ${m?"bg-ouro-gold/8 ring-ouro-gold/15":v?"bg-ouro-moss/20 ring-ouro-moss/15":"bg-ouro-moss/25 ring-ouro-moss/15"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider",style:{color:m?"var(--color-ouro-gold)":"var(--color-ouro-shadow)"},children:m?"★ delegated":v?"heartbeat":"prompt"}),e.jsxs("span",{className:"font-mono text-[9px] text-ouro-shadow/40",children:["#",c.sequence]}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:ne(c)})]}),e.jsx("p",{className:"text-sm leading-relaxed text-ouro-bone whitespace-pre-wrap break-words",children:g})]})},c.id)}if(c.role==="assistant"){const m=(c.toolCalls??[]).map(Se),v=m.filter(I=>I.kind==="surface"),y=m.filter(I=>I.kind==="rest"),j=m.filter(I=>I.kind==="delegation");return e.jsxs("div",{"data-msg-index":c.sequence,children:[v.map(I=>e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:"max-w-[85%] rounded-2xl rounded-br-sm bg-ouro-scale/15 px-3 py-2 ring-1 ring-ouro-scale/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-glow",children:"★ surfaced outward"}),e.jsxs("span",{className:"font-mono text-[9px] text-ouro-shadow/40",children:["#",c.sequence]}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:ne(c)})]}),e.jsx("p",{className:"text-sm leading-relaxed text-ouro-bone whitespace-pre-wrap break-words",children:I.deliveredText}),I.metadata&&e.jsxs("p",{className:"mt-1 font-mono text-[9px] text-ouro-shadow",children:["→ ",I.metadata]})]})},I.id)),j.length>0&&e.jsxs("div",{className:"py-1 text-center font-mono text-[10px] text-ouro-gold/50",children:["— still thinking — #",c.sequence," · ",ne(c)]}),y.length>0&&e.jsxs("div",{className:"py-1 text-center font-mono text-[10px] text-ouro-shadow/40",children:["— resting — #",c.sequence," · ",ne(c)]}),v.length===0&&y.length===0&&j.length===0&&g&&e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:"max-w-[85%] rounded-2xl rounded-br-sm bg-ouro-glow/6 px-3 py-2 ring-1 ring-ouro-glow/8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-glow/50",children:"thinking"}),e.jsxs("span",{className:"font-mono text-[9px] text-ouro-shadow/40",children:["#",c.sequence]}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:ne(c)})]}),e.jsx("p",{className:"text-sm leading-relaxed text-ouro-mist whitespace-pre-wrap break-words",children:g})]})})]},c.id)}return null})]})]})}function we({h:t}){const s=t.isOverdue,n=t.isDegraded,a=t.status;return e.jsxs("div",{className:`rounded-lg px-3 py-2.5 ring-1 ${s?"bg-ouro-fang/5 ring-ouro-fang/15":n?"bg-ouro-gold/5 ring-ouro-gold/15":a==="paused"?"bg-ouro-void/30 ring-ouro-moss/10":"bg-ouro-void/40 ring-ouro-moss/15"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{color:s?"red":n?"yellow":a==="active"?"lime":"zinc",children:s?"overdue":n?"degraded":a}),e.jsx("span",{className:"font-medium text-ouro-bone",children:t.title})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-3 text-xs text-ouro-shadow",children:[t.cadence&&e.jsxs("span",{children:["every ",t.cadence]}),e.jsx("span",{children:t.lastRun?`last ${M(t.lastRun)}`:"never run"}),n&&t.degradedReason&&e.jsx("span",{className:"text-ouro-gold",children:t.degradedReason}),!s&&!n&&a==="active"&&t.lastRun&&e.jsx("span",{className:"text-ouro-glow",children:"on schedule"}),s&&t.overdueMs&&e.jsxs("span",{className:"text-ouro-fang",children:[Math.floor(t.overdueMs/6e4),"m overdue"]}),!t.lastRun&&a==="active"&&e.jsx("span",{className:"text-ouro-gold",children:"never fired — may be misconfigured"})]}),t.bodyExcerpt&&e.jsx("p",{className:"mt-1 text-xs text-ouro-shadow/70",children:t.bodyExcerpt})]})}function Es({agentName:t,refreshGeneration:s}){const[n,a]=l.useState(null),[r,o]=l.useState(null),[d,b]=l.useState("diary");if(l.useEffect(()=>{L(`/agents/${encodeURIComponent(t)}/notes`).then(a),L(`/agents/${encodeURIComponent(t)}/note-decisions`).then(o).catch(()=>{})},[t,s]),!n)return e.jsxs("div",{className:"flex items-center gap-2 py-6",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-ouro-glow"}),e.jsx("span",{className:"font-mono text-xs text-ouro-shadow",children:"Loading…"})]});const x=n.recentDiaryEntries,f=n.recentCanonicalNotes;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>b("diary"),className:`font-mono text-xs uppercase tracking-wider transition-colors ${d==="diary"?"text-ouro-glow":"text-ouro-shadow hover:text-ouro-mist"}`,children:["Diary (",n.diaryEntryCount,")"]}),e.jsx("span",{className:"text-ouro-shadow/30",children:"|"}),e.jsxs("button",{onClick:()=>b("notes"),className:`font-mono text-xs uppercase tracking-wider transition-colors ${d==="notes"?"text-ouro-glow":"text-ouro-shadow hover:text-ouro-mist"}`,children:["Notes (",n.canonicalNoteCount,")"]}),e.jsx("span",{className:"text-ouro-shadow/30",children:"|"}),e.jsxs("button",{onClick:()=>b("decisions"),className:`font-mono text-xs uppercase tracking-wider transition-colors ${d==="decisions"?"text-ouro-glow":"text-ouro-shadow hover:text-ouro-mist"}`,children:["Decisions (",(r==null?void 0:r.totalCount)??0,")"]})]}),d==="diary"&&e.jsx("div",{children:x.length>0?e.jsx("div",{className:"space-y-3",children:x.map(h=>e.jsxs("article",{className:"rounded-xl bg-ouro-void/40 px-4 py-3.5 ring-1 ring-ouro-moss/15",children:[e.jsx("p",{className:"text-sm leading-relaxed text-ouro-bone",children:h.text}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-ouro-shadow",children:[e.jsx(k,{children:h.source}),e.jsx("span",{children:M(h.createdAt)})]})]},h.id))}):e.jsx("p",{className:"text-sm text-ouro-shadow italic",children:"No diary entries yet. The agent hasn't written anything down."})}),d==="notes"&&e.jsx("div",{children:f.length>0?e.jsx("div",{className:"space-y-3",children:f.map(h=>e.jsxs("article",{className:"rounded-xl bg-ouro-void/40 px-4 py-3.5 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"font-medium text-ouro-bone",children:h.title}),e.jsx("span",{className:"text-xs text-ouro-shadow",children:M(h.writtenAt)})]}),e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-ouro-mist",children:h.preview}),h.tags.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:h.tags.map(w=>e.jsx(k,{children:w},w))})]},h.filename))}):e.jsx("p",{className:"text-sm text-ouro-shadow italic",children:"No canonical notes yet."})}),d==="decisions"&&e.jsx("div",{children:r&&r.items.length>0?e.jsx("div",{className:"space-y-2",children:r.items.map((h,w)=>e.jsxs("div",{className:"rounded-xl bg-ouro-void/40 px-4 py-3 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{color:h.decision==="saved"?"lime":"zinc",children:h.decision}),e.jsx(k,{children:h.kind.replace(/_/g," ")}),e.jsx("span",{className:"text-xs text-ouro-shadow",children:M(h.timestamp)})]}),h.reason&&e.jsx("p",{className:"mt-1 text-sm text-ouro-mist",children:h.reason}),h.excerpt&&e.jsx("p",{className:"mt-0.5 text-xs text-ouro-shadow italic truncate",children:h.excerpt})]},w))}):e.jsx("p",{className:"text-sm text-ouro-shadow italic",children:"No note decisions logged yet."})})]})}function Ls({agentName:t,view:s,refreshGeneration:n}){var g;const[a,r]=l.useState(null),[o,d]=l.useState(null),b=s.agent,x=b.degraded,f=b.freshness,h=((g=b.providers)==null?void 0:g.lanes)??[];l.useEffect(()=>{Promise.all([L("/machine/health").then(r).catch(()=>null),L("/machine/logs").then(d).catch(()=>null)])},[t,n]);const w=Fs(a)?a:null,A=(w==null?void 0:w.degradedComponents)??[],c=(o==null?void 0:o.entries)??[];return e.jsxs("div",{className:"space-y-8",children:[x.status==="degraded"&&x.issues.length>0&&e.jsxs("section",{children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-fang",children:["Agent issues (",x.issues.length,")"]}),e.jsx("div",{className:"mt-3 space-y-1.5",children:x.issues.map((m,v)=>e.jsxs("div",{className:"rounded-lg bg-ouro-fang/5 px-3 py-2.5 ring-1 ring-ouro-fang/15",children:[e.jsx("p",{className:"font-mono text-xs font-semibold text-ouro-fang",children:m.code}),e.jsx("p",{className:"mt-0.5 text-xs text-ouro-mist break-all",children:m.detail})]},v))})]}),e.jsxs("section",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Agent config"}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3",children:[e.jsx(J,{label:"Provider lanes",value:Os(h)}),e.jsx(J,{label:"Enabled",value:b.enabled?"yes":"no"}),e.jsx(J,{label:"Freshness",value:`${f.status}${f.ageMs!=null?` (${Math.floor(f.ageMs/6e4)}m)`:""}`})]})]}),e.jsxs("section",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Provider lanes"}),h.length>0?e.jsx("div",{className:"mt-3 grid gap-2 lg:grid-cols-2",children:h.map(m=>{const v=_s(m);return e.jsxs("div",{className:"rounded-lg bg-ouro-void/40 px-3 py-3 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"font-mono text-xs font-semibold uppercase tracking-wider text-ouro-bone",children:m.lane}),e.jsx(k,{color:Ds(m),children:m.status}),e.jsx(k,{color:qs(m.readiness.status),children:m.readiness.status})]}),e.jsx("p",{className:"mt-2 text-sm font-medium text-ouro-bone",children:Ms(m)}),e.jsxs("div",{className:"mt-2 space-y-1 text-xs text-ouro-mist",children:[e.jsxs("p",{children:["source: ",m.source]}),e.jsxs("p",{children:["readiness: ",Us(m.readiness)]}),m.readiness.attempts!==void 0&&e.jsxs("p",{children:["attempts: ",m.readiness.attempts]}),m.readiness.checkedAt&&e.jsxs("p",{children:["checked: ",M(m.readiness.checkedAt)]}),e.jsxs("p",{children:["credentials: ",Hs(m.credential)]}),m.credential.revision&&e.jsxs("p",{children:["revision: ",m.credential.revision]}),Pe(m)&&e.jsxs("p",{children:["reason: ",Pe(m)]}),v&&e.jsxs("p",{className:"break-all text-ouro-fang",children:["repair: ",v]}),m.warnings.map((y,j)=>e.jsxs("p",{className:"break-words text-ouro-gold",children:["warning: ",y]},j))]})]},m.lane)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No provider lane data loaded."})]}),e.jsxs("section",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Daemon health"}),w?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3",children:[e.jsx(J,{label:"Status",value:w.status}),e.jsx(J,{label:"Mode",value:w.mode}),e.jsx(J,{label:"Uptime",value:`${Math.floor(w.uptimeSeconds/60)}m`})]}),A.length>0&&e.jsxs("div",{className:"mt-3 space-y-1.5",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-ouro-fang",children:"Degraded components"}),A.map((m,v)=>e.jsxs("div",{className:"rounded-lg bg-ouro-fang/5 px-3 py-2 ring-1 ring-ouro-fang/15",children:[e.jsx("p",{className:"text-xs font-semibold text-ouro-fang",children:m.component}),e.jsx("p",{className:"text-xs text-ouro-mist",children:m.reason})]},v))]})]}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No health file found. This is normal when not running under the daemon."})]}),e.jsxs("section",{children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:["Recent logs (",(o==null?void 0:o.totalLines)??0," total)"]}),c.length>0?e.jsx("div",{className:"mt-3 max-h-96 overflow-y-auto rounded-lg bg-ouro-void/40 ring-1 ring-ouro-moss/15",children:[...c].reverse().slice(0,50).map((m,v)=>{const y=m.level;return e.jsxs("div",{className:"border-b border-ouro-moss/10 px-3 py-1.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx(k,{color:y==="error"?"red":y==="warn"?"yellow":"zinc",children:y}),e.jsx("span",{className:"text-ouro-shadow",children:M(m.ts)}),e.jsx("span",{className:"font-mono text-ouro-glow",children:m.event})]}),e.jsx("p",{className:"truncate text-xs text-ouro-mist",children:m.message})]},v)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No log entries."})]})]})}function J({label:t,value:s}){return e.jsxs("div",{className:"rounded-lg bg-ouro-void/40 px-3 py-2.5 ring-1 ring-ouro-moss/15",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-ouro-shadow",children:t}),e.jsx("p",{className:"mt-1 text-sm font-medium text-ouro-bone",children:s})]})}function Os(t){return t.length===0?"none":`${t.filter(n=>n.status==="configured").length}/${t.length} configured`}function Ms(t){return t.status==="unconfigured"?"unconfigured":`${t.provider} / ${t.model}`}function Us(t){return t.status==="failed"?t.error?`failed: ${t.error}`:"failed":t.status==="stale"?t.reason?`stale: ${t.reason}`:"stale":t.status==="unknown"?t.reason?`unknown: ${t.reason}`:"unknown":t.status}function Hs(t){return t.status==="present"?t.source??"vault":t.status==="invalid-pool"?"vault unavailable":"missing"}function _s(t){return t.status==="unconfigured"?t.repairCommand:t.credential.repairCommand}function Pe(t){return t.status==="unconfigured"?t.reason:t.readiness.reason}function Ds(t){return t.status==="configured"?"green":"yellow"}function qs(t){return t==="ready"?"green":t==="failed"?"red":t==="stale"?"amber":"zinc"}function Fs(t){return!!(t&&"degradedComponents"in t)}const Ne=[{id:"overview",label:"Overview"},{id:"mail",label:"Mailbox"},{id:"sessions",label:"Sessions"},{id:"work",label:"Work"},{id:"connections",label:"Connections"},{id:"inner",label:"Private Runtime"},{id:"notes",label:"Desk Record"},{id:"runtime",label:"Runtime"}];function Bs(t){return t==="degraded"||t==="blocked"?"red":t==="stale"?"yellow":t==="active"?"lime":"zinc"}function Ps({agentName:t,view:s,deskPrefs:n,refreshGeneration:a,initialRoute:r,onNavigate:o}){const[d,b]=l.useState((r==null?void 0:r.tab)??"overview"),[x,f]=l.useState(r==null?void 0:r.focus),h=l.useRef(t);l.useEffect(()=>{const v=h.current!==t;if(h.current=t,(r==null?void 0:r.agent)===t){b(r.tab),f(r.focus);return}v&&(b("overview"),f(void 0))},[t,r==null?void 0:r.agent,r==null?void 0:r.focus,r==null?void 0:r.tab]);const w=l.useCallback(v=>{const y={agent:t,tab:v.tab,focus:v.focus};b(v.tab),f(v.focus),window.history.pushState(null,"",Ce(y)),o==null||o(y)},[t,o]),A=l.useCallback(v=>{const y={agent:t,tab:v,focus:void 0};b(v),f(void 0),window.history.pushState(null,"",Ce(y)),o==null||o(y)},[t,o]),c=l.useCallback(()=>f(void 0),[]);if(It(w),!s||!t)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[e.jsx("p",{className:"font-display text-2xl italic text-ouro-bone",children:"Choose an agent"}),e.jsx("p",{className:"mt-2 text-sm text-ouro-mist",children:"Select an agent from the sidebar to inspect its state."})]});const m=s.agent.attention;return e.jsx(Ye.Provider,{value:w,children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 pb-4 border-b border-ouro-moss/30",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("h1",{className:"font-display text-2xl italic font-semibold text-ouro-bone sm:text-3xl",children:t})}),e.jsx(k,{color:Bs(m.level),children:m.label})]}),e.jsx("nav",{className:"mt-4 flex gap-0.5 overflow-x-auto border-b border-ouro-moss/20 -mx-1",children:(()=>{const v=n==null?void 0:n.tabOrder;if(!v)return Ne;const y=v.map(I=>Ne.find(i=>i.id===I)).filter(I=>I!==void 0),j=Ne.filter(I=>!v.includes(I.id));return[...y,...j]})().map(v=>e.jsx("button",{type:"button",onClick:()=>A(v.id),className:`shrink-0 px-3 py-2 text-xs font-mono uppercase tracking-wider transition-colors rounded-t-md ${d===v.id?"bg-ouro-moss/20 text-ouro-glow border-b-2 border-ouro-glow":"text-ouro-shadow hover:text-ouro-mist hover:bg-ouro-moss/10"}`,children:v.label},v.id))}),e.jsxs("div",{className:"mt-6",children:[d==="overview"&&e.jsx(Ht,{view:s,deskPrefs:n,refreshGeneration:a}),d==="mail"&&e.jsx(Kt,{agentName:t,focus:x,onFocusConsumed:c,refreshGeneration:a}),d==="sessions"&&e.jsx(hs,{agentName:t,focus:x,onFocusConsumed:c,deskPrefs:n,refreshGeneration:a}),d==="work"&&e.jsx(js,{agentName:t,view:s,focus:x,onFocusConsumed:c,refreshGeneration:a}),d==="connections"&&e.jsx(Ss,{agentName:t,focus:x,onFocusConsumed:c,refreshGeneration:a}),d==="inner"&&e.jsx(As,{agentName:t,view:s,refreshGeneration:a}),d==="notes"&&e.jsx(Es,{agentName:t,refreshGeneration:a}),d==="runtime"&&e.jsx(Ls,{agentName:t,view:s,refreshGeneration:a})]})]})})}const We={observation:"Observation",judgment:"Judgment",input_admitted:"Input admitted",input_unknown:"Input unknown",legacy_input_reported:"Legacy input report (unqualified)",notification_queued:"Notification queued",notification_delivered:"Notification transport acceptance",notification_unknown:"Notification unknown",recovery:"Acknowledged recovery"};function Re(t,s){const n=t===null?NaN:s-Date.parse(t);return Number.isFinite(n)&&n>=0?n:null}function Ve(t,s){const n=Re(t,s);return n===null?"unknown":`${Math.floor(n/1e3)}s`}function he(t,s){const n=Re(t,s);return n!==null&&n<=3e4}const B="rounded-xl bg-ouro-void/50 p-4 ring-1 ring-ouro-moss/25";function ye({command:t,label:s}){const[n,a]=l.useState(null);if(!t)return null;const r=async()=>{try{await navigator.clipboard.writeText(t),a("copied")}catch{a("failed")}};return e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("code",{className:"block select-text break-all rounded-md bg-ouro-void p-2 text-xs",children:t}),e.jsxs("button",{type:"button",onClick:()=>{r()},className:"text-xs text-ouro-glow underline",children:["Copy ",s," command"]}),n==="copied"&&e.jsx("span",{role:"status",className:"ml-2 text-xs text-ouro-mist",children:"Copied for local execution; nothing was run."}),n==="failed"&&e.jsx("p",{role:"alert",className:"text-xs text-ouro-gold",children:"Copy failed. Select the command text and copy it manually."})]})}function Ws({agents:t,agentName:s,focus:n,refreshGeneration:a,onSelectOwner:r}){const[o,d]=l.useState(null),[b,x]=l.useState(null),[f,h]=l.useState(Date.now),w=l.useRef(null),A=l.useRef(a);l.useEffect(()=>{if(!s){w.current=null;return}const i=s;let S=!0,T=!1,z=!1,O=null;const p=async()=>{if(S){if(T){z=!0;return}T=!0,O=new AbortController;try{const E=await L(`/agents/${encodeURIComponent(i)}/supervision`,{signal:O.signal});if(!S)return;if(E.agentName!==i)throw new Error("the observation belongs to another agent");if(E.schemaVersion!==1)throw new Error("unsupported observation schema");d(E),x(null),h(Date.now())}catch(E){S&&!O.signal.aborted&&x({agent:i,message:E instanceof Error?E.message:String(E)})}finally{T=!1,S&&z&&(z=!1,p())}}},u=()=>{p()};w.current=u,u();const N=window.setInterval(()=>{document.visibilityState!=="hidden"&&u()},5e3),R=window.setInterval(()=>h(Date.now()),1e3),$=()=>{h(Date.now()),document.visibilityState!=="hidden"&&u()};return document.addEventListener("visibilitychange",$),()=>{S=!1,O==null||O.abort(),window.clearInterval(N),window.clearInterval(R),document.removeEventListener("visibilitychange",$),w.current===u&&(w.current=null)}},[s]),l.useEffect(()=>{var i;A.current!==a&&(A.current=a,(i=w.current)==null||i.call(w))},[a]);const c=(o==null?void 0:o.agentName)===s?o:null,g=(b==null?void 0:b.agent)===s?b.message:null,m=(c==null?void 0:c.freshness.status)==="fresh"&&he(c.freshness.observedAt,f),v=!c||c.freshness.status==="unknown"||Re(c.freshness.observedAt,f)===null?"unknown":m?"fresh":"stale",y=(c==null?void 0:c.sessions.items.map(i=>({...i,activity:m&&i.freshness.status==="fresh"&&he(i.observedAt,f)?i.activity:"unknown",authority:m&&he(i.observedAt,f)?i.authority:"unknown",capability:m&&he(i.observedAt,f)?i.capability:"unknown"})))??[],j=c!=null&&c.counts?{working:0,idle:0,shell:0,unknown:0}:null;if(j)for(const i of y)j[i.activity]+=1;const I=(c==null?void 0:c.custody.claims.items.filter(i=>(i.state==="unknown"||i.state==="claimed")&&!i.retired))??[];return e.jsxs("div",{className:"space-y-6 text-ouro-bone",children:[e.jsxs("header",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl font-semibold",children:"Supervision"}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm text-ouro-mist",children:"What Shepherd can observe, why it acted or withheld input, and what still needs the owner. Quiet terminals and judgments are not proof of merge, publication or deployment."})]}),e.jsxs("label",{className:"flex min-w-0 flex-col gap-1 text-sm text-ouro-mist",children:["Owning Ouro agent",e.jsxs("select",{"aria-label":"Owning Ouro agent",value:s??"",onChange:i=>r(i.target.value||null),className:"max-w-full rounded-lg border border-ouro-moss/40 bg-ouro-deep px-3 py-2 text-ouro-bone",children:[e.jsx("option",{value:"",children:"Choose an owner"}),s&&!t.includes(s)&&e.jsxs("option",{value:s,children:[s," (not in machine inventory)"]}),t.map(i=>e.jsx("option",{value:i,children:i},i))]})]})]}),e.jsxs("aside",{className:`${B} text-sm text-ouro-gold`,"aria-label":"Alpha automation boundary",children:[e.jsx("p",{className:"font-semibold",children:"Alpha automation boundary"}),e.jsx("p",{className:"mt-1",children:ls})]}),s?e.jsxs(e.Fragment,{children:[g&&e.jsxs("div",{role:"alert",className:`${B} text-ouro-gold`,children:["Could not load supervision for ",s,": ",g,".",c&&e.jsxs(e.Fragment,{children:[" Showing the last successful observation for ",s,"; its age continues to increase."]}),e.jsx("button",{type:"button",className:"ml-2 underline",onClick:()=>{var i;return(i=w.current)==null?void 0:i.call(w)},children:"Retry observation"})]}),!c&&!g&&e.jsxs("p",{role:"status",children:["Loading supervision for ",s,"..."]}),c&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:B,"aria-label":"Observation health",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(k,{color:v==="fresh"?"lime":"yellow",children:e.jsxs("span",{"data-testid":"supervision-freshness",children:[v," observation"]})}),e.jsx(k,{color:c.health==="ok"?"zinc":"yellow",children:c.health==="ok"?"Sources readable":"Sources degraded"}),e.jsxs("p",{className:"text-sm",children:["Observation age: ",Ve(c.freshness.observedAt,f)]}),e.jsx("button",{type:"button",onClick:()=>{var i;return(i=w.current)==null?void 0:i.call(w)},className:"text-sm text-ouro-glow underline",children:"Refresh observation"})]}),c.freshness.observedAt&&e.jsxs("p",{className:"mt-2 break-words font-mono text-xs text-ouro-mist",children:["Observed at ",e.jsx("time",{dateTime:c.freshness.observedAt,children:c.freshness.observedAt}),". Reading this page does not refresh the observation."]}),e.jsx("dl",{className:"mt-3 flex flex-wrap gap-x-4 gap-y-1 text-xs text-ouro-mist",children:Object.entries(c.sourceHealth).map(([i,S])=>e.jsxs("div",{className:"flex gap-1",children:[e.jsxs("dt",{children:[i,":"]}),e.jsx("dd",{children:S})]},i))}),c.sourceErrors.length>0&&e.jsx("ul",{className:"mt-3 space-y-1 text-sm text-ouro-gold",children:c.sourceErrors.map((i,S)=>e.jsxs("li",{className:"break-words",children:[i.source,": ",i.detail]},`${i.source}:${i.code}:${S}`))})]}),e.jsx("section",{"aria-label":"Terminal counts",className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:["working","idle","shell","unknown"].map(i=>e.jsxs("div",{className:B,children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-ouro-mist",children:i}),e.jsx("p",{"data-testid":`supervision-count-${i}`,className:"mt-1 text-2xl tabular-nums",children:(j==null?void 0:j[i])??"Unknown"})]},i))}),e.jsxs("p",{className:"text-sm text-ouro-mist",children:["Showing ",y.length," of ",c.sessions.totalCount??"unknown"," terminals.",c.sessions.truncated&&" Inventory is truncated."," Counts above describe only the displayed rows."]}),e.jsxs("section",{"aria-label":"Supervised terminals",className:"grid min-w-0 gap-4 xl:grid-cols-2",children:[y.map(i=>{const S=`${i.host}:${i.session}`,T=c.timeline.items.filter(z=>z.host===i.host&&z.session===i.session);return e.jsxs("article",{className:`${B} min-w-0 space-y-3`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx("h2",{className:"min-w-0 break-words text-lg font-semibold",children:i.label}),e.jsx(k,{color:i.activity==="working"?"lime":i.activity==="unknown"?"yellow":"zinc",children:i.activity})]}),e.jsxs("dl",{className:"space-y-1 break-words text-sm text-ouro-mist",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"inline",children:"Terminal: "}),e.jsxs("dd",{className:"inline font-mono",children:[i.host," / ",i.session]})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"inline",children:"Harness: "}),e.jsx("dd",{className:"inline",children:i.harness??"Unknown / no identified coding harness"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"inline",children:"Project: "}),e.jsx("dd",{className:"inline font-mono",children:i.project??"Unknown"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"inline",children:"Process instance: "}),e.jsx("dd",{className:"inline font-mono",children:i.instance??"Unknown"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"inline",children:"Last observed: "}),e.jsxs("dd",{className:"inline",children:[Ve(i.observedAt,f)," ago"]})]})]}),e.jsxs("p",{className:"text-sm",children:["Stored mandate / pause state: ",i.authority,". Guarded input: ",i.capability,"."]}),e.jsxs("p",{className:"break-words text-sm text-ouro-gold",children:["Stored policy assessment, not an enforced dispatch decision: ",i.withheldReason??"Unknown."]}),e.jsxs("p",{className:"text-sm",children:["Last recorded judgment: ",e.jsx("span",{children:i.lastDecisionLabel??"None recorded"})]}),e.jsxs("p",{className:"break-words text-sm text-ouro-mist",children:["Last recorded action: ",i.lastAction==="respond"?"Reported terminal response":i.lastAction==="let_through"?"Let through without a response":"None recorded",".",i.lastReason&&e.jsxs(e.Fragment,{children:[" ",i.lastReason]}),i.lastActionAt&&e.jsxs(e.Fragment,{children:[" ",e.jsx("time",{dateTime:i.lastActionAt,children:i.lastActionAt})]})]}),e.jsx("a",{className:"inline-block text-xs text-ouro-glow underline",href:`#/supervision/${encodeURIComponent(s)}/${encodeURIComponent(S)}`,children:"Link to this terminal"}),e.jsxs("details",{open:n===S||void 0,className:"border-t border-ouro-moss/25 pt-3",children:[e.jsxs("summary",{className:"cursor-pointer text-sm text-ouro-glow",children:["Timeline for ",i.label]}),T.length===0&&e.jsx("p",{className:"mt-2 text-sm text-ouro-mist",children:"No retained events for this terminal."}),e.jsx("ol",{className:"mt-3 space-y-3",children:T.map(z=>e.jsxs("li",{className:"break-words text-sm",children:[e.jsxs("p",{children:[We[z.kind],": ",z.summary]}),e.jsxs("p",{className:"mt-1 font-mono text-xs text-ouro-mist",children:[e.jsx("time",{dateTime:z.at,children:z.at})," | ",z.instance?`instance ${z.instance}`:"instance not recorded"]})]},z.id))})]})]},S)}),y.length===0&&e.jsx("p",{className:B,children:c.counts===null?"Terminal inventory is unavailable, not empty.":"No terminals were present in this observation."})]}),e.jsxs("section",{className:B,"aria-label":"Custody and held inputs",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Replay barriers and unknown inputs"}),e.jsx("p",{className:"mt-2 text-sm text-ouro-gold",children:"Unknown effects remain held: do not retry blindly. Owner administration is local-only; this browser cannot resolve or retry claims."}),e.jsx("div",{className:"mt-3",children:e.jsx(ye,{command:_e(s),label:"status"},s)}),e.jsxs("p",{className:"mt-2 text-xs text-ouro-mist",children:["Run commands locally as the existing owner. Local administration is same-UID authority, not proof of human presence."," ","Read current status and inspect the exact claim before changing anything. A stale revision will be rejected."]}),e.jsxs("p",{className:"mt-2 text-xs text-ouro-mist",children:["Custody revision: ",c.custody.revision??"unknown","."," ","Storage: ",c.custody.bytes===null?"unknown":`${c.custody.bytes.toLocaleString()} bytes`," (",c.custody.capacity,")."," ","Showing ",c.custody.claims.items.length," of ",c.custody.claims.totalCount??"unknown"," retained barriers.",c.custody.claims.truncated&&" Custody inventory is truncated."]}),I.map(i=>e.jsxs("div",{className:"mt-3 space-y-1 break-words border-t border-ouro-moss/25 pt-3 text-sm",children:[e.jsxs("p",{children:["Original state: ",i.state," | ",i.host," / ",i.session]}),e.jsx("p",{className:"break-all font-mono text-xs",children:i.id}),e.jsxs("p",{className:"text-ouro-mist",children:[i.reason??"No outcome evidence is recorded."," Acknowledgments in the timeline do not rewrite the original state."]}),e.jsx(ye,{command:_e(s,i.id),label:"inspection"}),e.jsxs("details",{className:"pt-2",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-ouro-glow",children:"Local recovery after terminal retirement"}),e.jsxs("p",{className:"my-2 text-xs text-ouro-mist",children:["The entire terminal must be absent from a strict host inventory."," ","A different foreground process is not proof of retirement. This command never confirms delivery or retries input."," ","Confirmed-delivery recovery remains unsupported until native receipt lookup is qualified."]}),e.jsx(ye,{command:is(s,i.id,c.custody.revision),label:"retirement"},`${i.id}:${c.custody.revision}`),c.custody.revision===null&&e.jsx("p",{className:"text-xs text-ouro-gold",children:"No retirement command is available until a custody revision is known."})]})]},i.id)),c.custody.claims.totalCount===null&&e.jsx("p",{className:"mt-3 text-sm",children:"Custody availability is unknown; zero held inputs cannot be established."})]}),e.jsxs("details",{className:B,children:[e.jsx("summary",{className:"cursor-pointer text-sm text-ouro-glow",children:"All retained events, including closed terminals"}),e.jsx("ol",{className:"mt-3 space-y-3",children:c.timeline.items.map(i=>e.jsxs("li",{className:"break-words text-sm",children:[e.jsxs("p",{children:[i.host," / ",i.session,": ",We[i.kind],": ",i.summary]}),e.jsxs("p",{className:"mt-1 font-mono text-xs text-ouro-mist",children:[e.jsx("time",{dateTime:i.at,children:i.at})," | ",i.instance??"instance not recorded"]})]},i.id))})]}),e.jsxs("p",{className:"text-xs text-ouro-mist",children:["Retained timeline: ",c.timeline.items.length," of ",c.timeline.totalCount??"unknown"," events.",c.timeline.truncated&&" History is truncated; absence from this view is not proof that an event never occurred."]})]})]}):e.jsx("p",{className:B,children:"Choose an owning Ouro agent to inspect its terminal supervision. No fleet counts are available until an owner is selected."})]})}function ke(){return Xe(window.location.hash)}function Vs(t){return t==="degraded"||t==="blocked"?"red":t==="stale"?"yellow":t==="active"?"lime":"zinc"}function Qs(){var Ie;const[t,s]=l.useState(()=>Te(window.location.hash)),n=l.useRef(t!==null),[a,r]=l.useState(null),[o,d]=l.useState(((Ie=ke())==null?void 0:Ie.agent)??""),[b,x]=l.useState(null),[f,h]=l.useState(null),[w,A]=l.useState(null),[c,g]=l.useState(null),[m,v]=l.useState(null),[y,j]=l.useState(null),[I,i]=l.useState("connecting"),[S,T]=l.useState(0),z=l.useRef(0),O=l.useRef(ke()),[p,u]=l.useState(ke),N=l.useRef(o),R=l.useRef(!0),$=l.useRef(0),E=l.useRef(0),q=l.useRef(null),Q=l.useRef(null),K=l.useCallback(C=>{var U;N.current!==C&&(N.current=C,E.current+=1,z.current+=1,(U=Q.current)==null||U.abort(),d(C),x(null),h(null),g(null),j(null))},[]),le=l.useCallback(async()=>{var D,P;const C=++$.current;(D=q.current)==null||D.abort();const U=new AbortController;q.current=U;try{const F=await L("/machine",{signal:U.signal});if(!R.current||C!==$.current)return;if(r(F),A(null),v(new Date().toISOString()),!n.current&&!N.current&&F.agents.length>0){const W=((P=O.current)==null?void 0:P.agent)??F.agents[0].agentName;K(W)}}catch(F){if(!R.current||U.signal.aborted||C!==$.current)return;A(F instanceof Error?F.message:String(F))}},[K]),G=l.useCallback(async C=>{var F;if(!C)return;const U=++E.current;(F=Q.current)==null||F.abort();const D=new AbortController;Q.current=D;const P=()=>R.current&&U===E.current&&N.current===C;try{const[W,dt]=await Promise.all([L(`/agents/${encodeURIComponent(C)}`,{signal:D.signal}),L(`/agents/${encodeURIComponent(C)}/desk-prefs`,{signal:D.signal})]);if(!P())return;if(W.agent.agentName!==C)throw new Error("the response belongs to another agent");x(W),h(dt),g(null),j(new Date().toISOString())}catch(W){if(!P()||D.signal.aborted)return;g(W instanceof Error?W.message:String(W))}},[]);l.useEffect(()=>(R.current=!0,()=>{var C,U;R.current=!1,$.current+=1,E.current+=1,z.current+=1,(C=q.current)==null||C.abort(),(U=Q.current)==null||U.abort()}),[]),l.useEffect(()=>{le()},[le]),l.useEffect(()=>{o&&G(o)},[o,G]);const ce=l.useCallback(async()=>{const C=++z.current,U=n.current?"":N.current;await Promise.all([le(),U?G(U):Promise.resolve()]),R.current&&z.current===C&&T(D=>D+1)},[le,G]);l.useEffect(()=>gt(()=>{ce()},i),[ce]),l.useEffect(()=>{const C=()=>{const U=Te(window.location.hash);if(U){n.current=!0,s(U);return}const D=Xe(window.location.hash);D&&(n.current=!1,u(D),s(null),K(D.agent))};return window.addEventListener("hashchange",C),()=>window.removeEventListener("hashchange",C)},[K]);const ct=l.useCallback(C=>{const U={agent:C,tab:"overview",focus:void 0};u(U),n.current=!1,s(null),K(C),window.history.pushState(null,"",Ce(U))},[K]),ze=l.useCallback(C=>{n.current=!0,s({agent:C}),window.history.pushState(null,"",bt(C))},[]);if(!a)return e.jsx("div",{className:"flex h-screen items-center justify-center bg-ouro-void",children:e.jsx("div",{className:"text-center",children:w?e.jsxs("div",{role:"alert",children:[e.jsxs("p",{className:"text-ouro-bone",children:["Could not connect to Mailbox: ",w]}),e.jsx("button",{type:"button",onClick:()=>{ce()},className:"mt-3 text-ouro-glow underline",children:"Retry connection"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-auto mb-4 h-4 w-4 animate-pulse rounded-full bg-ouro-glow shadow-[0_0_20px_theme(--color-ouro-glow)]"}),e.jsx("p",{role:"status",className:"font-mono text-sm text-ouro-mist",children:"Connecting to Mailbox…"})]})})});const de=a.overview.totals,Z=(b==null?void 0:b.agent.agentName)===o?b:null;return e.jsxs(Ct,{navbar:e.jsxs(vt,{children:[e.jsx(wt,{}),e.jsx(jt,{children:e.jsx($e,{children:e.jsx(k,{color:a.overview.daemon.mode==="dev"?"yellow":"lime",children:a.overview.daemon.mode})})})]}),sidebar:e.jsxs(St,{className:"bg-ouro-deep",children:[e.jsx($t,{className:"border-ouro-moss/30",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-3 w-3 shrink-0 rounded-full bg-ouro-glow shadow-[0_0_16px_theme(--color-ouro-glow)]"}),e.jsx("div",{className:"min-w-0",children:e.jsx("p",{className:"truncate font-display text-lg italic font-semibold text-ouro-bone",children:"Ouro Mailbox"})})]})}),e.jsxs(At,{className:"[&>[data-slot=section]+[data-slot=section]]:mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Le,{className:"text-ouro-mist/60",children:"Machine"}),e.jsx(Oe,{current:t!==null,onClick:()=>ze(null),children:e.jsx(Me,{className:"text-ouro-bone",children:"Supervision"})}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5 px-2",children:[{v:de.liveTasks??0,l:"Tasks",alert:(de.blockedTasks??0)>0},{v:de.openObligations??0,l:"Oblig."},{v:de.activeCodingAgents??0,l:"Coding"}].map(C=>e.jsxs("div",{className:"rounded-md bg-ouro-void/60 px-2 py-1.5 text-center ring-1 ring-ouro-moss/20",children:[e.jsx("div",{className:`text-base font-semibold tabular-nums ${C.alert?"text-ouro-fang":"text-ouro-bone"}`,children:C.v}),e.jsx("div",{className:"text-[9px] uppercase tracking-widest text-ouro-shadow",children:C.l})]},C.l))})]}),e.jsxs(Ee,{children:[e.jsx(Le,{className:"text-ouro-mist/60",children:"Agents"}),a.agents.map(C=>e.jsx(Oe,{current:t===null&&C.agentName===o,onClick:()=>ct(C.agentName),children:e.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(Me,{className:"text-ouro-bone",children:C.agentName}),e.jsxs("p",{className:"truncate text-xs text-ouro-shadow",children:[C.tasks.liveCount,"t · ",C.obligations.openCount,"o · ",C.coding.activeCount,"c"]})]}),e.jsx(k,{color:Vs(C.attention.level),children:C.attention.label})]})},C.agentName))]})]}),e.jsx(Rt,{className:"border-ouro-moss/30",children:e.jsxs("div",{className:"px-2 text-xs text-ouro-shadow",children:[e.jsx("p",{className:"font-mono",children:a.overview.runtime.version}),e.jsxs("p",{className:"mt-0.5",children:[a.overview.daemon.mode," · ",a.overview.freshness.status]})]})}),t===null&&o&&Z&&e.jsx("div",{className:"px-4 py-2 border-t border-ouro-moss/20",children:e.jsx("p",{className:"text-xs italic text-ouro-shadow/70",children:(()=>{const C=f==null?void 0:f.statusLine;if(C)return C;const U=Z.inner;if(U.status==="running"||U.hasPending)return"thinking through something privately";const P=Z.work.obligations.openCount;return P>2?"a few loose ends":P>0?"carrying something":"steady"})()})})]}),children:[e.jsxs("div",{role:"status",className:"mb-4 text-xs text-ouro-mist",children:[I==="connected"?"Live connection":I==="reconnecting"?"Disconnected - reconnecting. Displayed snapshots may be stale.":"Connecting to live updates. Displayed snapshots may be stale.",m&&e.jsxs(e.Fragment,{children:[" Last machine snapshot received ",e.jsx("time",{dateTime:m,children:new Date(m).toLocaleTimeString()}),"."]})]}),w&&e.jsxs("div",{role:"alert",className:"mb-4 text-sm text-ouro-gold",children:["Could not refresh the machine snapshot: ",w,". Showing the last successful machine snapshot.",e.jsx("button",{type:"button",onClick:()=>{ce()},className:"ml-2 underline",children:"Retry"})]}),t===null&&c&&e.jsxs("div",{role:"alert",className:"mb-4 text-sm text-ouro-gold",children:["Could not load ",o,": ",c,".",Z&&e.jsxs(e.Fragment,{children:[" Showing the last successful snapshot for ",o,y&&e.jsxs(e.Fragment,{children:[" received ",e.jsx("time",{dateTime:y,children:new Date(y).toLocaleTimeString()})]}),"."]}),e.jsx("button",{type:"button",onClick:()=>{G(o)},className:"ml-2 underline",children:"Retry agent"})]}),t?e.jsx(Ws,{agents:a.agents.map(C=>C.agentName),agentName:t.agent,focus:t.focus,refreshGeneration:S,onSelectOwner:ze}):Z||!o?e.jsx(Ps,{agentName:o,view:Z,deskPrefs:f,refreshGeneration:S,initialRoute:(p==null?void 0:p.agent)===o?p:void 0,onNavigate:u},o):e.jsx("p",{role:"status",className:"py-12 text-ouro-mist",children:c?`No snapshot available for ${o}.`:`Loading ${o}...`})]})}pt.createRoot(document.getElementById("app")).render(e.jsx(l.StrictMode,{children:e.jsx(Qs,{})}));
@@ -6,7 +6,7 @@
6
6
  <meta name="color-scheme" content="dark" />
7
7
  <title>Ouro Mailbox</title>
8
8
  <meta name="description" content="The daemon-hosted shared orientation surface for agents alive on this machine." />
9
- <script type="module" crossorigin src="/assets/index-xU5krmwW.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-Dbska1tZ.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="/assets/vendor-CcN1XpQ9.js">
11
11
  <link rel="stylesheet" crossorigin href="/assets/index-DsiKaPyH.css">
12
12
  </head>