@schlenkr/ragents 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/apps/server/src/provider.ts +8 -2
  2. package/apps/server/src/title-compactor.ts +1 -1
  3. package/apps/web/dist/assets/{highlighted-body-KPVGNVTW-CpPi6QLr.js → highlighted-body-KPVGNVTW-BslIwn_y.js} +1 -1
  4. package/apps/web/dist/assets/main-BUN8m8SW.js +11 -0
  5. package/apps/web/dist/assets/{mermaid-HWGCJPDP-q-mf1kLN.js → mermaid-HWGCJPDP-B1erZlFM.js} +4 -4
  6. package/apps/web/dist/assets/{runPanel-nk_aMxSn.js → runPanel-s8gGpr9M.js} +1 -1
  7. package/apps/web/dist/help/mini-app.css +9 -0
  8. package/apps/web/dist/host-web.json +7 -7
  9. package/apps/web/dist/index.html +2 -2
  10. package/apps/web/dist/run-panel.html +2 -2
  11. package/apps/web/src/App.tsx +12 -1
  12. package/apps/web/src/PluginRegistry.tsx +2 -2
  13. package/apps/web/src/SessionList.tsx +7 -6
  14. package/apps/web/src/SettingsModal.tsx +3 -3
  15. package/apps/web/src/actor-programs/client-ui/FilePicker.tsx +1 -1
  16. package/apps/web/src/api.ts +2 -0
  17. package/apps/web/src/run-overview.ts +1 -1
  18. package/apps/web/src/ui/relative-time.ts +1 -1
  19. package/bundles/ragents.documents/ragents-bundle.json +2 -2
  20. package/bundles/ragents.documents/web/classes.json +1 -1
  21. package/bundles/ragents.documents/web/index.js +1 -1
  22. package/bundles/ragents.documents/web/index.js.map +2 -2
  23. package/bundles/ragents.orchestration/ragents-bundle.json +2 -2
  24. package/bundles/ragents.orchestration/web/index.js +3 -3
  25. package/bundles/ragents.orchestration/web/index.js.map +2 -2
  26. package/bundles/ragents.overseer/ragents-bundle.json +4 -3
  27. package/bundles/ragents.overseer/web/classes.json +1 -1
  28. package/bundles/ragents.overseer/web/index.js +1 -1
  29. package/bundles/ragents.overseer/web/index.js.map +4 -4
  30. package/bundles/ragents.processes/ragents-bundle.json +2 -2
  31. package/bundles/ragents.processes/web/classes.json +1 -1
  32. package/bundles/ragents.processes/web/index.js +1 -1
  33. package/bundles/ragents.processes/web/index.js.map +2 -2
  34. package/bundles/ragents.workspace/ragents-bundle.json +2 -2
  35. package/bundles/ragents.workspace/web/classes.json +1 -1
  36. package/bundles/ragents.workspace/web/index.js +1 -1
  37. package/bundles/ragents.workspace/web/index.js.map +2 -2
  38. package/package.json +2 -2
  39. package/plugins/ragents.documents/web/DocumentViewer.tsx +2 -2
  40. package/plugins/ragents.orchestration/web/ExecutionsPanel.tsx +1 -1
  41. package/plugins/ragents.orchestration/web/FlowInspector.tsx +1 -1
  42. package/plugins/ragents.orchestration/web/JournalStatus.tsx +1 -1
  43. package/plugins/ragents.orchestration/web/format.ts +1 -1
  44. package/plugins/ragents.overseer/web/index.tsx +51 -3
  45. package/plugins/ragents.processes/web/processes.ts +1 -1
  46. package/plugins/ragents.workspace/web/FileBrowser.tsx +1 -1
  47. package/apps/web/dist/assets/main-DJmCHGzM.js +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schlenkr/ragents",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "RAgents host: server, engine, plugins and tools without a source checkout",
5
5
  "keywords": [
6
6
  "agents",
@@ -70,6 +70,6 @@
70
70
  "yaml": "2.9.0"
71
71
  },
72
72
  "ragents": {
73
- "hostVersion": "2fe07b19a1aa4533d20428b040e88960fedc44cb"
73
+ "hostVersion": "7b70e01ffa7c5e09ad393aa630cedb17fb4c2472"
74
74
  }
75
75
  }
@@ -92,7 +92,7 @@ const formatTime = (iso: string) => {
92
92
  const date = new Date(iso);
93
93
  return Number.isNaN(date.getTime())
94
94
  ? iso
95
- : date.toLocaleString("en-US", { day: "2-digit", month: "2-digit", hour: "2-digit", minute: "2-digit" });
95
+ : date.toLocaleString(undefined, { day: "2-digit", month: "2-digit", hour: "2-digit", minute: "2-digit" });
96
96
  };
97
97
 
98
98
  export const documentMessagesFrom = (
@@ -182,7 +182,7 @@ export function DocumentToolCall({ active, document, onOpen, status }: DocumentT
182
182
  <span className="text-[0.62rem] font-semibold tracking-[0.05em] text-primary uppercase">Document</span>
183
183
  <strong className="truncate text-[0.84rem] leading-[1.35]" title={document.title}>{document.title}</strong>
184
184
  <span className="text-[0.7rem] leading-[1.35] text-muted-foreground">
185
- {formatLabels[document.format]}, {lineCount.toLocaleString("en-US")} {lineCount === 1 ? "line" : "lines"}
185
+ {formatLabels[document.format]}, {lineCount.toLocaleString()} {lineCount === 1 ? "line" : "lines"}
186
186
  </span>
187
187
  </span>
188
188
  <span className="flex items-center gap-1 text-[0.7rem] font-semibold text-primary group-data-[status=error]/call:text-destructive">
@@ -91,7 +91,7 @@ function ExecutionEntry({ execution, now }: { execution: TypeScriptExecution; no
91
91
  <span className="truncate font-[650]" title={`${execution.actorName} (${execution.actorId})`}>@{execution.actorHandle}</span>
92
92
  <Badge className={`h-auto rounded-[5px] px-[5px] py-0.5 text-[0.64rem] ${statusBadgeClass[execution.status] ?? "bg-secondary text-muted-foreground"}`}>{executionStatusLabel(execution.status)}</Badge>
93
93
  <span className="col-span-full truncate font-mono text-[0.68rem]" title={preview}>{preview}</span>
94
- <span className="col-span-full flex flex-wrap justify-between gap-x-3 gap-y-1.5 text-[0.65rem] tabular-nums text-muted-foreground"><time dateTime={execution.startedAt} title={new Date(execution.startedAt).toLocaleString("en-US")}>{new Date(execution.startedAt).toLocaleString("en-US", { day: "2-digit", month: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" })}</time><span>{executionDuration(execution, now)}</span></span>
94
+ <span className="col-span-full flex flex-wrap justify-between gap-x-3 gap-y-1.5 text-[0.65rem] tabular-nums text-muted-foreground"><time dateTime={execution.startedAt} title={new Date(execution.startedAt).toLocaleString()}>{new Date(execution.startedAt).toLocaleString(undefined, { day: "2-digit", month: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" })}</time><span>{executionDuration(execution, now)}</span></span>
95
95
  </summary>
96
96
  {expanded && <div className={contentClass}>
97
97
  {execution.path && <p className="mt-2.5 grid gap-1 text-[0.68rem] text-muted-foreground"><span>Path</span><code className="[overflow-wrap:anywhere]">{execution.path}</code></p>}
@@ -128,7 +128,7 @@ const runCostUsd = (view: RunView): number | undefined => {
128
128
  };
129
129
 
130
130
  const formatCostUsd = (value: number) =>
131
- `${value.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: value > 0 && value < 0.005 ? 4 : 2 })} USD`;
131
+ `${value.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: value > 0 && value < 0.005 ? 4 : 2 })} USD`;
132
132
 
133
133
  interface RunIndex {
134
134
  view: RunView;
@@ -80,7 +80,7 @@ function JournalEntry({ actor, event }: { actor: string | undefined; event: Jour
80
80
  <span className="text-muted-foreground tabular-nums">{event.sequence}</span>
81
81
  <span className="font-mono [overflow-wrap:anywhere]">{event.type}</span>
82
82
  <span className="truncate max-[550px]:col-start-2 max-[550px]:row-start-2" title={event.actorId}>{actor ? `@${actor}` : event.actorId}</span>
83
- <time className="text-muted-foreground tabular-nums max-[550px]:col-start-3 max-[550px]:row-start-1" dateTime={event.occurredAt}>{new Date(event.occurredAt).toLocaleTimeString("en-US")}</time>
83
+ <time className="text-muted-foreground tabular-nums max-[550px]:col-start-3 max-[550px]:row-start-1" dateTime={event.occurredAt}>{new Date(event.occurredAt).toLocaleTimeString()}</time>
84
84
  </summary>
85
85
  {expanded && <SourceCode className="m-0 mb-2 text-[0.68rem]" content={JSON.stringify(event, null, 2)} language="json" path="event.json" />}
86
86
  </details>;
@@ -1,4 +1,4 @@
1
1
  export const formatTime = (iso: string) => {
2
2
  const date = new Date(iso);
3
- return Number.isNaN(date.getTime()) ? iso : date.toLocaleString("en-US");
3
+ return Number.isNaN(date.getTime()) ? iso : date.toLocaleString();
4
4
  };
@@ -3,7 +3,7 @@ import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogH
3
3
  import { RunModalContext } from "@ragents/web/ui/dialog";
4
4
  import { XIcon } from "lucide-react";
5
5
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
6
- import { ChatMessages, ChatInputToolbar, type ChatInputHandle, type ChatEvent } from "quassel";
6
+ import { ChatMessages, ChatInputToolbar, ChatPanel, type ChatInputHandle, type ChatEvent } from "quassel";
7
7
  import { useChat } from "@ragents/web/chat/useChat";
8
8
  import { useAttachmentCapabilities } from "@ragents/web/chat/useAttachmentCapabilities";
9
9
  import { ChatStepsProvider, type OverviewPanelContext, type WebPlugin } from "@ragents/web/PluginRegistry";
@@ -30,7 +30,7 @@ const interruptCoordinator = async (runId: string) => {
30
30
  const errorClass = "mx-4 my-2 flex-none text-[0.8rem] text-destructive";
31
31
 
32
32
  /** Every user has their own coordinator; only the server knows its id. */
33
- function OverseerToolbar(context: OverviewPanelContext) {
33
+ function useCoordinator() {
34
34
  const user = useAccess().user?.id;
35
35
  const [coordinator, setCoordinator] = useState<{ runId?: string; error?: string }>({});
36
36
  useEffect(() => {
@@ -42,6 +42,11 @@ function OverseerToolbar(context: OverviewPanelContext) {
42
42
  );
43
43
  return () => { current = false; };
44
44
  }, [user]);
45
+ return coordinator;
46
+ }
47
+
48
+ function OverseerToolbar(context: OverviewPanelContext) {
49
+ const coordinator = useCoordinator();
45
50
  if (!coordinator.runId) {
46
51
  return <div className={toolbarClass} data-slot="overseer-toolbar" role="status">
47
52
  {coordinator.error && <span className="text-[0.7rem] font-bold text-destructive" title={coordinator.error} aria-label={coordinator.error}>!</span>}
@@ -226,8 +231,51 @@ function OverseerConversation({ open, onOpen, onClose, onBusy, userLocation, run
226
231
  </div>;
227
232
  }
228
233
 
234
+ /** The coordinator's chat fills the main area while no run is open. */
235
+ function OverseerIdleView({ userLocation }: OverviewPanelContext) {
236
+ const coordinator = useCoordinator();
237
+ if (!coordinator.runId) {
238
+ return <p className={coordinator.error ? "m-auto p-6 text-center text-destructive" : "m-auto p-6 text-center text-muted-foreground"} role="status">
239
+ {coordinator.error ?? "Connecting to the global coordinator ..."}
240
+ </p>;
241
+ }
242
+ return <ChatStepsProvider policy={overseerChatDisplayPolicy} storageKeyPrefix={overseerChatStorageKeyPrefix}>
243
+ <OverseerIdleChat key={coordinator.runId} runId={coordinator.runId} userLocation={userLocation} />
244
+ </ChatStepsProvider>;
245
+ }
246
+
247
+ function OverseerIdleChat({ runId, userLocation }: { runId: string; userLocation: OverviewPanelContext["userLocation"] }) {
248
+ const writable = useAccess().can("ragents.overseer.write");
249
+ const chat = useChat(runId);
250
+ const chatView = useChatViewSettings(runId, "primary", "coordinator");
251
+ const modelState = useModelSettings();
252
+ const attachments = useAttachmentCapabilities(runId, "primary", JSON.stringify(modelState.settings && [modelState.settings.provider, modelState.settings.model]));
253
+ const messages = useMemo(() => withToolSummaries(chat.messages), [chat.messages]);
254
+ const [error, setError] = useState<string>();
255
+ const problem = error ?? (chat.connected ? undefined : "No connection. Your draft is kept; sending is disabled.");
256
+ return <ChatPanel className="flex h-full min-h-0 w-full min-w-0 flex-1 flex-col overflow-hidden" maxWidth="880px"
257
+ composer={<div className="[--qsl-input-card-radius:var(--radius-lg)]">
258
+ {problem && <p className="text-[0.8rem] text-destructive" role="alert">{problem}</p>}
259
+ <ChatInputToolbar {...attachments} disabled={!writable} sendDisabled={!chat.connected || modelState.status === "saving"} maxRows={6} rows={1}
260
+ onErrorChange={setError} onSend={(text, attachments) => chat.send(text, attachments, userLocation)}
261
+ onStop={writable && chat.running ? () => { setError(undefined); void interruptCoordinator(runId).catch((cause: unknown) => setError(cause instanceof Error ? cause.message : String(cause))); } : undefined}
262
+ running={chat.running}
263
+ texts={{ placeholder: writable ? "Ask the global coordinator" : "Read access to the global coordinator", steeringPlaceholder: "Ask the global coordinator" }}
264
+ toolbarLeft={<ChatViewSwitches settings={chatView} />}
265
+ />
266
+ </div>}>
267
+ <ChatMessages detailMode={chatView.detailMode}
268
+ emptyState={<div className="m-auto max-w-[480px] p-8 text-center text-[0.9rem] leading-[1.6] text-muted-foreground max-md:p-5"><strong className="text-foreground">Global coordinator</strong><p>No run is open. Ask about your runs or give a task; open or start a run through the overview at the top left.</p></div>}
269
+ messages={messages} running={chat.running} showTimestamps={chatView.showTimestamps} stepsExpandable={chatView.stepsExpandable}
270
+ />
271
+ </ChatPanel>;
272
+ }
273
+
229
274
  export const webPlugin: WebPlugin = {
230
275
  id: OVERSEER_PLUGIN_ID,
231
276
  settings: [{ category: "models", order: 10, readRight: "ragents.overseer.read", id: `${OVERSEER_PLUGIN_ID}.model`, label: "Global coordinator", Settings: ModelSettings }],
232
- overviewPanels: [{ id: `${OVERSEER_PLUGIN_ID}.chat`, placement: "toolbar", order: 100, readRight: "ragents.overseer.read", Panel: OverseerToolbar }],
277
+ overviewPanels: [
278
+ { id: `${OVERSEER_PLUGIN_ID}.chat`, placement: "toolbar", order: 100, readRight: "ragents.overseer.read", Panel: OverseerToolbar },
279
+ { id: `${OVERSEER_PLUGIN_ID}.idle`, placement: "idle", order: 100, readRight: "ragents.overseer.read", Panel: OverseerIdleView },
280
+ ],
233
281
  };
@@ -54,7 +54,7 @@ const originText = (origin: RunProcess["origin"]): string =>
54
54
 
55
55
  const timeText = (iso: string): string => {
56
56
  const parsed = new Date(iso);
57
- return Number.isNaN(parsed.getTime()) ? iso : parsed.toLocaleTimeString("en-US");
57
+ return Number.isNaN(parsed.getTime()) ? iso : parsed.toLocaleTimeString();
58
58
  };
59
59
 
60
60
  export const titleOf = (process: RunProcess): string => {
@@ -41,7 +41,7 @@ const sizeLabel = (bytes: number): string => {
41
41
 
42
42
  const timeLabel = (value: string): string => {
43
43
  const at = new Date(value);
44
- return Number.isNaN(at.getTime()) ? value : at.toLocaleString("en-US");
44
+ return Number.isNaN(at.getTime()) ? value : at.toLocaleString();
45
45
  };
46
46
 
47
47
  interface BrowserMemory {
@@ -1,11 +0,0 @@
1
- import{a as le,r as t,j as e,D as ce,b as de,d as G,B as b,X as Me,M as Pe,C as ue,e as Le,f as Ie,g as _e,h as He,u as Be,i as Ue,k as Fe,l as qe,m as Te,A as Ke,n as $e,o as We,U as Qe,P as Ve,W as Ge,R as Xe,p as re,q as V,s as Ye,t as Je,v as Ze,w as et,x as tt,y as st,z as nt,Q as at,F as rt,G as ot}from"./mermaid-HWGCJPDP-q-mf1kLN.js";/**
2
- * @license lucide-react v1.46.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const fe={name:"circle-question-mark",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["help-circle","circle-help"]};fe.node;const it=le(fe);/**
7
- * @license lucide-react v1.46.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const pe={name:"sparkles",size:24,node:[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],aliases:["stars"]};pe.node;const lt=le(pe);function ct(n,a,r,u){if(!a||n.source!==a||n.origin!==r)return;const o=n.data;if(!(!o||typeof o!="object"||Array.isArray(o))&&"type"in o){if(o.type==="ragents:help-ready")return{type:"ready"};if(o.type==="ragents:start-sample"&&"entry"in o&&typeof o.entry=="string"&&u.includes(o.entry))return{type:"start",entry:o.entry}}}function dt({onClose:n,sampleEntries:a,onStartSample:r}){const u=t.useRef(null),o=t.useRef(null),p=t.useRef(void 0),m=t.useRef(!1);t.useEffect(()=>()=>{var i;return(i=p.current)==null?void 0:i.call(p)},[]),t.useEffect(()=>{var y;const i=(y=o.current)==null?void 0:y.contentWindow;if(!i)return;const l=()=>i.postMessage({type:"ragents:help-context",canStartSamples:a.length>0,entries:a},window.location.origin),h=C=>{const c=ct(C,i,window.location.origin,a);(c==null?void 0:c.type)==="ready"&&l(),(c==null?void 0:c.type)==="start"&&!m.current&&(m.current=!0,r(c.entry))};return window.addEventListener("message",h),l(),()=>window.removeEventListener("message",h)},[r,a]);const x=()=>{var C;(C=p.current)==null||C.call(p);const i=o.current,l=i==null?void 0:i.contentDocument,h=l==null?void 0:l.defaultView;if(!i||!l||!h)return;l.documentElement.dataset.helpEmbedded="true";for(const c of l.querySelectorAll("a[href]"))new URL(c.href).origin!==window.location.origin&&(c.target="_blank",c.rel="noopener noreferrer");const y=c=>{var v;if(!c.defaultPrevented){if(c.key==="Escape")c.preventDefault(),n();else if(c.key==="Tab"){const g=[...l.querySelectorAll("a[href], button, input, select, textarea, summary, [tabindex]")].filter(j=>j.tabIndex>=0&&!j.matches(":disabled")&&j.getClientRects().length>0),L=c.shiftKey?g[0]:g.at(-1);if(!g.length||l.activeElement===L||l.activeElement===l.body){if(!c.shiftKey&&l.activeElement===l.body&&g.length)return;c.preventDefault(),(v=u.current)==null||v.focus()}}}};h.addEventListener("keydown",y),p.current=()=>h.removeEventListener("keydown",y)};return e.jsx(ce,{open:!0,onOpenChange:i=>{i||n()},children:e.jsxs(de,{className:"gap-0 p-0",initialFocus:u,scope:"page",showCloseButton:!1,size:"full",children:[e.jsx(G,{className:"sr-only",children:"Help"}),e.jsx(b,{"aria-label":"Close help",className:"absolute top-3 right-4.5 z-1 rounded-full",onClick:n,ref:u,size:"icon",variant:"outline",children:e.jsx(Me,{})}),e.jsx("iframe",{className:"min-h-0 w-full min-w-0 flex-[1_1_0] bg-background",onLoad:x,ref:o,src:"/help/index.html",tabIndex:0,title:"RAgents: homepage and documentation"})]})})}const ut="button:not([disabled]), a[href], input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])",xe="pointer-events-auto shadow-pop";function ft({onBusy:n,onClose:a,onOpen:r,open:u,panels:o,registry:p,runs:m}){const x=t.useRef(null);return t.useEffect(()=>{if(!u)return;const i=requestAnimationFrame(()=>{var h;const l=x.current;!l||l.contains(document.activeElement)||(h=l.querySelector(ut))==null||h.focus({preventScroll:!0})});return()=>cancelAnimationFrame(i)},[u]),e.jsxs(Pe,{className:"pointer-events-none flex h-[min(900px,100%)] w-[min(1440px,100%)] flex-col rounded-none bg-transparent p-0 ring-0",keepMounted:!0,onClose:a,open:u,scope:"workspace",size:"full",children:[e.jsx(G,{className:"sr-only",children:"Overview"}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 gap-4 max-[900px]:flex-col",id:"app-overview",ref:x,children:[o.map(({id:i,Panel:l})=>e.jsx(pt,{id:i,onBusy:n,onClose:a,onOpen:r,open:u,Panel:l,registry:p},i)),m&&e.jsx(xt,{...m})]})]})}function pt({id:n,onBusy:a,onClose:r,onOpen:u,open:o,Panel:p,registry:m}){const x=t.useCallback(i=>a(n,i),[n,a]);return t.useEffect(()=>()=>a(n,!1),[n,a]),e.jsx(ue,{className:`${xe} min-h-0 min-w-0 flex-1 gap-0 p-0`,children:e.jsx(p,{onBusy:x,onClose:r,onOpen:u,open:o,registry:m})})}function xt({activeId:n,canCreate:a,canDelete:r,onCreate:u,onDelete:o,onOpen:p,registry:m,sessions:x,seenRevisions:i,unreachable:l}){const[h,y]=t.useState(),[C,c]=t.useState(!1),[v,g]=t.useState(()=>new Set),[L,j]=t.useState(!1),[R,H]=t.useState(!1),B=()=>{c(!1),g(new Set)},w=f=>{g(D=>{const I=new Set(D);return I.delete(f)||I.add(f),I})},E=async f=>{H(!0),y(void 0);try{await o(f)}catch(D){y(D instanceof Error?D.message:String(D))}finally{H(!1)}},S=async()=>{await E(x.filter(f=>v.has(f.id)).map(f=>f.id)),j(!1),B()};return e.jsx("section",{"aria-labelledby":"overview-runs-title",className:"flex min-h-0 min-w-0 flex-1 flex-col max-[900px]:flex-[1_1_50%]",children:e.jsxs(ue,{className:`${xe} min-h-0 flex-1 gap-workspace-inset overflow-y-auto overscroll-contain pt-workspace-inset pr-6 pb-6 pl-6 max-[900px]:px-3 max-[900px]:pt-3.5 max-[900px]:pb-4`,children:[e.jsxs("header",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-2.5",children:[e.jsxs("h2",{className:"text-[0.95rem] font-semibold",id:"overview-runs-title",children:["Runs ",e.jsx("span",{className:"ml-1 text-[0.8rem] font-medium tabular-nums text-muted-foreground",children:x.length})]}),l&&e.jsx("span",{className:"text-[0.72rem] font-medium text-destructive",role:"alert",children:"Server unreachable"}),r&&x.length>0&&e.jsx("div",{className:"ml-auto flex flex-wrap items-center gap-1",children:C?e.jsxs(e.Fragment,{children:[e.jsx(b,{onClick:()=>g(new Set(x.map(f=>f.id))),size:"sm",variant:"ghost",children:"All"}),e.jsx(b,{onClick:()=>g(new Set),size:"sm",variant:"ghost",children:"None"}),e.jsxs(b,{className:"ml-auto",disabled:v.size===0||R,onClick:()=>j(!0),size:"sm",variant:"destructive",children:["Delete (",v.size,")"]}),e.jsx(b,{onClick:B,size:"sm",variant:"ghost",children:"Done"})]}):e.jsx(b,{onClick:()=>c(!0),size:"sm",variant:"ghost",children:"Select"})})]}),h&&e.jsx("p",{className:"text-[0.72rem] font-medium text-destructive",role:"alert",children:h}),e.jsx("p",{className:"mb-5.5 text-[0.75rem] text-muted-foreground",children:"By last activity in the run. New activity has come in since you last viewed it."}),e.jsx(Le,{seenRevisions:i,activeId:n,onCreate:a?u:void 0,onDelete:r?f=>void E([f]):void 0,onSelect:p,onToggleSelected:w,registry:m,selectMode:C,selectedIds:v,sessions:x}),L&&e.jsx(ce,{open:!0,onOpenChange:f=>{!f&&!R&&j(!1)},children:e.jsxs(de,{scope:"page",showCloseButton:!1,size:"small",children:[e.jsxs(Ie,{children:[e.jsx(G,{children:"Delete runs"}),e.jsx(_e,{children:v.size===1?"One run will be permanently deleted.":`${v.size} runs will be permanently deleted.`})]}),e.jsxs(He,{children:[e.jsx(b,{disabled:R,onClick:()=>j(!1),variant:"outline",children:"Cancel"}),e.jsx(b,{disabled:R,onClick:()=>void S(),children:R?"Deleting ...":`Delete (${v.size})`})]})]})})]})})}const oe="flex min-h-0 min-w-0 flex-1 flex-col",mt="inline-flex w-header min-h-header items-center justify-center border-r border-border text-primary transition-colors duration-100 not-disabled:cursor-pointer hover:not-disabled:bg-accent focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-3 aria-expanded:bg-primary aria-expanded:text-primary-foreground aria-pressed:bg-primary aria-pressed:text-primary-foreground disabled:opacity-45";function ht(){var ae;const n=Be(),a=Ue((ae=n.user)==null?void 0:ae.id),r=n.can("runs.read"),u=r&&n.can("runs.write"),o=n.can("runs.inspect"),p=r&&n.can("runs.delete"),m=Fe(),x=t.useRef(null),i=t.useRef(null),[l,h]=t.useState(null),[y,C]=t.useState(null),[c,v]=t.useState(null),[g,L]=t.useState(null),[j,R]=t.useState(null),[H,B]=t.useState([]),[w,E]=t.useState(),[S,f]=t.useState(),[D,I]=t.useState(),[F,X]=t.useState(!1),[q,T]=t.useState(!1),[O,Y]=t.useState(!1),[J,z]=t.useState(),[he,ve]=t.useState(!1),[be,ge]=t.useState(()=>new Set),[we,Z]=t.useState(!1),_=t.useRef(void 0),K=t.useRef(!1),M=t.useCallback(()=>{if(!r)return Promise.resolve();if(_.current)return K.current=!0,_.current;const s=async()=>{do{K.current=!1;try{B(await Je()),Z(!1)}catch{Z(!0)}}while(K.current)};return _.current=s().finally(()=>{_.current=void 0}),_.current},[r]);t.useEffect(()=>{if(!r||w)return;M();const s=qe.subscribe(Te.channels.runs,{},()=>void M()),d=setInterval(()=>void M(),5e3);return()=>{s(),clearInterval(d)}},[w,r,M]);const A=t.useCallback((s=!1)=>{var d;Y(!1),s&&((d=x.current)==null||d.focus({preventScroll:!0}))},[]),$=t.useCallback(()=>{z(void 0),ve(!0),Y(!0)},[]),W=t.useCallback(()=>{O?A(!0):$()},[A,$,O]);t.useEffect(()=>{const s=d=>{if(d.defaultPrevented||d.repeat||d.altKey||d.shiftKey||d.key.toLowerCase()!=="i"||d.metaKey===d.ctrlKey)return;const N=x.current;!N||N.closest("[inert]")||(d.preventDefault(),W())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[W]);const ee=t.useCallback((s,d)=>ge(N=>{if(N.has(s)===d)return N;const P=new Set(N);return d?P.add(s):P.delete(s),P}),[]),te=H,ye=te.find(s=>s.id===S),je=t.useCallback(()=>{z(void 0),X(!0)},[]),Se=t.useCallback(()=>T(!1),[]),ke=t.useCallback(()=>{X(!1),requestAnimationFrame(()=>{var s;return(s=i.current)==null?void 0:s.focus()})},[]),Ce=e.jsx(b,{"aria-label":"Open settings",onClick:je,ref:i,size:"icon-lg",title:"Settings",variant:"ghost",children:e.jsx(Ze,{})}),Ne=s=>{f(s),A(!0)},Re=()=>{z(void 0),A(!0),E({id:crypto.randomUUID(),title:"New run",updatedAt:Date.now()})},Ee=async s=>{const d=await Promise.allSettled(s.map(U=>et(U))),N=s.filter((U,Ae)=>d[Ae].status==="fulfilled");S!==void 0&&N.includes(S)&&f(void 0),await M();const P=d.find(U=>U.status==="rejected");if(P)throw P.reason};if(m.status==="loading")return e.jsx("div",{className:"m-auto p-6 text-muted-foreground",children:"Loading profile."});if(m.status==="failed")return e.jsx("div",{className:"flex h-full",children:e.jsx("main",{className:"relative z-1 flex min-h-0 min-w-0 flex-1 bg-[image:var(--surface-backdrop)]",children:e.jsxs("div",{className:oe,children:[e.jsx("header",{className:"flex min-h-[42px] flex-none items-center gap-3 border-b border-border-soft pr-0.5 pb-2 pl-2.5",children:e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3 text-[0.82rem] font-semibold text-foreground",children:"Profile unavailable"})}),e.jsxs(Ke,{className:"m-auto max-w-[560px] gap-3 p-6",variant:"destructive",children:[e.jsx("p",{children:m.error}),e.jsx(b,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload"})]})]})})});const k=m.registry,se=k.overviewPanels.filter(s=>s.readRight===void 0||n.can(s.readRight)),Q=se.filter(s=>s.placement!=="toolbar"),De=se.filter(s=>s.placement==="toolbar"),Oe=r||Q.length>0,ne=Q.some(s=>be.has(s.id)),ze=$e(r?S:void 0,O,D);return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("header",{className:"relative z-[80] flex h-header flex-none items-stretch border-b border-border bg-shell shadow-bar",children:[Oe&&e.jsx("div",{className:"relative flex flex-none self-stretch",children:e.jsx("button",{"aria-controls":"app-overview","aria-expanded":O,"aria-haspopup":"dialog","aria-keyshortcuts":"Meta+I Control+I","aria-label":O?"Close overview":"Open overview",className:mt,onClick:W,ref:x,title:`Overview (Cmd+I / Ctrl+I)${ne?": processing":""}`,type:"button",children:ne?e.jsx(We,{"aria-hidden":!0,className:"size-[18px]"}):e.jsx(lt,{size:22})})}),De.map(({id:s,Panel:d})=>e.jsx(vt,{id:s,onBusy:ee,onClose:()=>z(void 0),onOpen:()=>{!F&&!q&&!w&&(A(),z(s))},open:J===s,Panel:d,registry:k,userLocation:ze},s)),e.jsx("div",{"aria-label":"Run title bar",className:"flex min-w-0 flex-1 items-stretch overflow-x-auto no-scrollbar focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-3 max-md:in-[header:has([data-slot=overseer-toolbar][data-open=true])]:flex-[0_1_0]",ref:h,role:"region",tabIndex:0}),e.jsx(Qe,{}),e.jsxs("div",{className:"flex min-w-0 flex-[0_1_auto] items-stretch bg-shell has-data-[workspace-state=expanded]:w-[var(--workspace-panel-width,560px)] has-data-[workspace-state=expanded]:border-l has-data-[workspace-state=expanded]:border-border",children:[e.jsx("div",{className:"flex min-w-0 flex-1 empty:hidden",ref:C}),e.jsxs("div",{className:"flex flex-none items-center gap-1.5 px-2 max-md:gap-0.5 max-md:px-1",children:[n.can("settings.read")&&Ce,o&&e.jsx(b,{"aria-haspopup":"dialog","aria-label":"Open help",onClick:()=>{z(void 0),T(!0)},size:"icon-lg",title:"Help",variant:"ghost",children:e.jsx(it,{})})]})]})]}),e.jsx(Ve,{failures:m.failures}),e.jsx(Ge.Provider,{value:g,children:e.jsx("div",{className:"relative flex min-h-0 flex-1 flex-col",ref:L,children:e.jsxs(Xe.Provider,{value:j,children:[e.jsxs("div",{className:"relative flex h-auto min-h-0 flex-1",ref:R,children:[e.jsx("main",{className:"relative z-1 flex min-h-0 min-w-0 flex-1 bg-[image:var(--surface-backdrop)] @container/chat-content",children:r&&S?e.jsx(re,{headerContainer:l,workspaceHeaderContainer:y,statusContainer:c,onLocationChange:I,onViewed:a.markViewed,viewing:!O&&!F&&!q&&!w&&!J,registry:k,session:ye??{id:S,title:"New run",updatedAt:Date.now()}},S):e.jsx("div",{className:oe,children:e.jsx("div",{className:"m-auto text-center text-muted-foreground",children:r?u?"Open the overview at the top left to choose a run or start a new one.":"Open the overview at the top left to choose a run. You have read access.":"No runs are shared with this user account."})})}),he&&e.jsx(ft,{onOpen:$,onBusy:ee,onClose:()=>A(!0),open:O,panels:Q,registry:k,runs:r?{activeId:S,canCreate:u&&(n.can("runs.create")||k.scriptEntries.some(s=>V(n,s.id))),canDelete:p,onCreate:Re,onDelete:Ee,onOpen:Ne,registry:k,sessions:te,seenRevisions:a.revisions,unreachable:we}:void 0}),w&&e.jsx(re,{onStarted:()=>{f(w.id),E(void 0),M()},registry:k,session:w,startDialog:{onClose:()=>E(void 0),initialEntryId:w.startEntryId}},w.id),F&&e.jsx(Ye,{onClose:ke,registry:k}),o&&q&&e.jsx(dt,{onClose:Se,sampleEntries:k.scriptEntries.filter(s=>V(n,s.id)).map(s=>s.id),onStartSample:s=>{!V(n,s)||!k.scriptEntries.some(d=>d.id===s)||(T(!1),z(void 0),A(),E({id:crypto.randomUUID(),title:"New run",updatedAt:Date.now(),startEntryId:s}))}})]}),e.jsx("footer",{"aria-label":"Run status bar",className:"relative flex h-statusbar w-full flex-none items-stretch pl-3 before:pointer-events-none before:absolute before:inset-0 before:z-[2] before:border-t before:border-border before:bg-shell before:shadow-status before:backdrop-blur-[16px] before:content-['']",ref:v})]})})})]})}function vt({id:n,onBusy:a,Panel:r,...u}){const o=t.useCallback(p=>a(n,p),[n,a]);return t.useEffect(()=>()=>a(n,!1),[n,a]),e.jsx(r,{...u,onBusy:o})}tt();const me=document.getElementById("root");if(!me)throw new Error("Root element is missing");const ie=st.createRoot(me);try{const n=nt(window);ie.render(e.jsx(t.StrictMode,{children:e.jsx(at,{children:e.jsx(rt,{children:e.jsx(ht,{})})})}))}catch(n){ie.render(e.jsxs(ot,{children:[e.jsx("h1",{className:"my-3 text-[1.5rem]",children:"The view could not be loaded"}),e.jsx("p",{className:"mb-6 leading-normal",role:"alert",children:n instanceof Error?n.message:String(n)}),e.jsx(b,{onClick:()=>window.location.reload(),variant:"outline",children:"Reload"})]}))}