@bigduu/lotus-next 2026.11.2 → 2026.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asset-manifest.json +229 -202
- package/dist/assets/{AgentService-BcSV4V6G.js → AgentService-T_rVeCqc.js} +1 -1
- package/dist/assets/{BrowserPane-Qpdtlb6C.js → BrowserPane-BCZscRcO.js} +1 -1
- package/dist/assets/{CommandPalette-FYYof7PJ.js → CommandPalette-CgiVqLDj.js} +1 -1
- package/dist/assets/ComposerEditor-VqGIrsdq.js +102 -0
- package/dist/assets/{ConversationClearDialogContent-DapZ3K4B.js → ConversationClearDialogContent-Dhq7t2MJ.js} +1 -1
- package/dist/assets/{ErrorBoundary-Cd8Mqhm-.js → ErrorBoundary-Dvuhdy_Q.js} +1 -1
- package/dist/assets/ErrorBoundary-kV_VJwPy.js +1 -0
- package/dist/assets/{ExternalLinkDialog-DxecTv9b.js → ExternalLinkDialog--gaLElt0.js} +1 -1
- package/dist/assets/{JianduProjectMemories-BSU_YgtD.js → JianduProjectMemories-DGz_FvO5.js} +1 -1
- package/dist/assets/Markdown-D90UutFO.js +2 -0
- package/dist/assets/MermaidChart-D1bUSRYY.js +1 -0
- package/dist/assets/{NewChatWorktreeControl-BVvX1tE3.js → NewChatWorktreeControl-BokjqEn9.js} +1 -1
- package/dist/assets/{ProjectWorkBoard-BDerd2KC.js → ProjectWorkBoard-_Gx9gO7O.js} +1 -1
- package/dist/assets/{RightWorkbench-ClTIc5yT.js → RightWorkbench-Bx2XueC9.js} +1 -1
- package/dist/assets/{RightWorkbenchSurface-5chVm3Q5.js → RightWorkbenchSurface-C6yJ1qQs.js} +1 -1
- package/dist/assets/Root-BVX9BeqN.js +11 -0
- package/dist/assets/{RunDiagnosticsDialogContent-C83miiCb.js → RunDiagnosticsDialogContent-fFSfsQk9.js} +1 -1
- package/dist/assets/Settings-BP9B8xH8.js +9 -0
- package/dist/assets/{SidebarProjectDrag-B8jeZZwD.js → SidebarProjectDrag-Tr-RiAfv.js} +1 -1
- package/dist/assets/{StreamdownMarkdown-BYrL8Htd.js → StreamdownMarkdown-B9_N1kbO.js} +2 -2
- package/dist/assets/StreamdownMermaid-D1bUSRYY.js +1 -0
- package/dist/assets/{StreamdownMermaid-BqMCspWP.js → StreamdownMermaid-DihA1DWx.js} +1 -1
- package/dist/assets/{SupervisorManagedSessions-DDL1goCC.js → SupervisorManagedSessions-CDSclXHy.js} +1 -1
- package/dist/assets/{SupervisorProjectScopeDialog-BRpx_B7f.js → SupervisorProjectScopeDialog-CqLk6xn2.js} +1 -1
- package/dist/assets/{TicketWorkPanel-CoPV3q8A.js → TicketWorkPanel-_eNUp0U9.js} +1 -1
- package/dist/assets/{WorkflowRunsContent-lUfm3WNf.js → WorkflowRunsContent-BW5KNi4_.js} +1 -1
- package/dist/assets/api-CPcpMjoM.js +1 -0
- package/dist/assets/appStore-DivM-eKj.js +14 -0
- package/dist/assets/{client-IKYlOoXY.js → client-Cxjm7aQO.js} +1 -1
- package/dist/assets/{command-CKwm5a6S.js → command-Cxbz9MXP.js} +3 -3
- package/dist/assets/{composerStyles-t36ulToF.js → composerStyles-BGNR54wZ.js} +1 -1
- package/dist/assets/dist-DRdYZy9Q.js +1 -0
- package/dist/assets/{dropdown-menu-CL18d3V3.js → dropdown-menu-L3Js6izm.js} +1 -1
- package/dist/assets/{en-US-CsZdRXMR.js → en-US-D9PrFi7z.js} +1 -1
- package/dist/assets/floating-ui.dom-BRnbq1vk.js +1 -0
- package/dist/assets/{index-BziNk-bd.js → index-CHQa-Zcr.js} +3 -3
- package/dist/assets/{jianduMemoryApi-o1cxvito.js → jianduMemoryApi-Bg3hZQEs.js} +1 -1
- package/dist/assets/{managedSessions-Df_XdXaQ.js → managedSessions-CyG8WTnE.js} +2 -2
- package/dist/assets/{managedSessions-CNlNA0Gf.js → managedSessions-DoDwGW7n.js} +1 -1
- package/dist/assets/{popover-NRuw3aPJ.js → popover-Cu0Q3dYz.js} +1 -1
- package/dist/assets/{project-EohCp9v3.js → project-Bes6r3Er.js} +1 -1
- package/dist/assets/{renderPdf-Cug6wuGM.js → renderPdf-md4Uxowu.js} +1 -1
- package/dist/assets/{responsive-dialog-ChvCU7Pw.js → responsive-dialog-5w1qV2Jr.js} +1 -1
- package/dist/assets/{select-D2Yn2_yL.js → select-CBtmzEvB.js} +1 -1
- package/dist/assets/{sessionLabels-CKjmBG2k.js → sessionLabels-CEwTJAqp.js} +1 -1
- package/dist/assets/shim-B7rqb4U2.js +1 -0
- package/dist/assets/{state-BgzWNmJm.js → state-BjHHK7Ni.js} +1 -1
- package/dist/assets/{ticketWorkLabels-tosshWRq.js → ticketWorkLabels-BNVpjOJX.js} +1 -1
- package/dist/assets/{ui-DQy0lUHc.js → ui-OvgR8HKW.js} +3 -3
- package/dist/assets/{useBrowserSession-DTq2injR.js → useBrowserSession-CA0yWm0c.js} +1 -1
- package/dist/assets/{useWorkflowCatalog-B3e4h1Zh.js → useWorkflowCatalog-BlIMJrl3.js} +1 -1
- package/dist/assets/{zh-CN-M8nOhM1r.js → zh-CN-CGY2FZ8_.js} +1 -1
- package/dist/bundle-ownership.json +114 -95
- package/dist/index.html +1 -1
- package/dist/lotus-next-manifest.json +144 -129
- package/package.json +1 -1
- package/dist/assets/ErrorBoundary-DrkdmL6R.js +0 -1
- package/dist/assets/Markdown-sn8uDNJU.js +0 -2
- package/dist/assets/MermaidChart-CK128dqg.js +0 -1
- package/dist/assets/Root-Cbi1Q37c.js +0 -112
- package/dist/assets/Settings-6l99-5Ca.js +0 -9
- package/dist/assets/StreamdownMermaid-CK128dqg.js +0 -1
- package/dist/assets/api-dae15_RX.js +0 -1
- package/dist/assets/appStore-DJRgb7nl.js +0 -14
- package/dist/assets/dist-gWmr0ziz.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{a as r}from"./ui-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{a as r}from"./ui-OvgR8HKW.js";import{B as i,_ as a,a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./workbenchSensors-t4FKs4U1.js";import{i as p,m}from"./appStore-DivM-eKj.js";import{o as h}from"./projectSidebarPreferences-CMJ99W-X.js";var g=e(t(),1);function _(e){if(!e||typeof e!=`object`)return null;let t=e;return(t.kind===`session`||t.kind===`section`)&&typeof t.projectId==`string`&&typeof t.id==`string`?{kind:t.kind,projectId:t.projectId,id:t.id}:null}function v(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.projectId!=`string`||t.sectionId!==null&&typeof t.sectionId!=`string`?null:typeof t.sessionId==`string`&&t.sessionId?{projectId:t.projectId,sectionId:t.sectionId,sessionId:t.sessionId}:{projectId:t.projectId,sectionId:t.sectionId}}function y(e,t,n){let r=t.projects[e.projectId];return!r||r.status!==`active`||r.sidebar===void 0||t.busy.has(r.id)||m(r)!==r.revision||n!==void 0&&r.revision!==n?!1:e.kind===`session`?t.chats.some(t=>t.id===e.id&&!t.parentSessionId&&t.config?.projectId?.trim()===r.id):e.id!==`legacy`&&h(t.preferences,r.id,r.section).some(t=>t.id===e.id)}function b(e,t,n){if(e.projectId!==t.projectId||!y(e,n,e.revision))return!1;let r=n.projects[e.projectId];return t.sectionId===null||h(n.preferences,r.id,r.section).some(e=>e.id===t.sectionId)}var x=n(),S={Handle:({source:e,label:t,disabled:n})=>{let{ref:r,isDragging:o}=l({id:JSON.stringify([e.kind,e.projectId,e.id]),data:e,disabled:n,plugins:[a.configure({feedback:`clone`,dropAnimation:null})]});return(0,x.jsx)(`button`,{ref:r,type:`button`,disabled:n,"aria-label":t,title:t,"data-sidebar-drag-handle":`${e.kind}:${e.id}`,"data-sidebar-dragging":o||void 0,className:`shrink-0 rounded p-1 text-muted-foreground outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring`,style:{touchAction:`none`,cursor:`grab`,opacity:o?.6:void 0},onClick:e=>{e.preventDefault(),e.stopPropagation()},onDragStart:e=>{e.preventDefault(),e.stopPropagation()},children:(0,x.jsx)(i,{"aria-hidden":`true`,className:`size-3`})})},Target:({target:e,disabled:t,children:n,style:r,...i})=>{let{source:a}=o(),{ref:s,isDropTarget:c}=d({id:JSON.stringify([`target`,e.projectId,e.sectionId,Object.hasOwn(i,`data-project-drop`)]),data:e,disabled:t}),l=c&&_(a?.data)?.projectId===e.projectId;return(0,x.jsx)(`div`,{...i,ref:s,"data-sidebar-drop-target":!0,"data-drop-active":l||void 0,style:{...r,...l?{boxShadow:`inset 0 0 0 2px var(--ring)`,backgroundColor:`color-mix(in oklab, var(--primary) 5%, transparent)`}:{}},children:n})}};function C(e){let t=e?.x,n=e?.y;if(typeof t!=`number`||typeof n!=`number`||!Number.isFinite(t)||!Number.isFinite(n)||typeof document.elementsFromPoint!=`function`)return null;for(let e of document.elementsFromPoint(t,n)){let t=e.closest?.(`[data-sidebar-session]`),r=t?.dataset.sidebarSession;if(!t||!r)continue;let i=t.getBoundingClientRect();return{sessionId:r,after:n>i.top+i.height/2}}return null}function w({scopeKey:e,state:t,onCancel:n,getPickup:r}){let i=s(),a=(0,g.useRef)({scopeKey:e,state:t,onCancel:n});a.current={scopeKey:e,state:t,onCancel:n};let o=(0,g.useRef)(()=>{});return(0,g.useLayoutEffect)(()=>{if(!i)return;let e=()=>!i.dragOperation.controller?.signal.aborted&&(i.dragOperation.status.initializing||i.dragOperation.status.dragging),t=c(i,e);o.current=()=>{a.current.onCancel(),t.cancel()};let n=e=>{e.target instanceof Element&&e.target.closest(`[role="dialog"], [role="menu"]`)&&o.current()},r=()=>o.current(),s=()=>{document.visibilityState!==`visible`&&o.current()};document.addEventListener(`focusin`,n,!0),document.addEventListener(`contextmenu`,r,!0),document.addEventListener(`pointerdown`,r,!0),document.addEventListener(`visibilitychange`,s),window.addEventListener(`blur`,r),window.addEventListener(`resize`,r,!0);let l=e=>{(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`)&&o.current()};document.addEventListener(`keydown`,l,!0);let u=new MutationObserver(()=>{let t=i.dragOperation.source?.element;e()&&(!t?.isConnected||t.closest(`[inert], [hidden], [aria-hidden="true"]`)||document.querySelector(`[role="dialog"]:not([data-state="closed"]):not([hidden]), [role="menu"]:not([data-state="closed"]):not([hidden])`))&&o.current()});return u.observe(document.body,{childList:!0,attributes:!0,attributeFilter:[`inert`,`hidden`,`aria-hidden`],subtree:!0}),()=>{o.current(),t.dispose(),document.removeEventListener(`focusin`,n,!0),document.removeEventListener(`contextmenu`,r,!0),document.removeEventListener(`pointerdown`,r,!0),document.removeEventListener(`visibilitychange`,s),document.removeEventListener(`keydown`,l,!0),window.removeEventListener(`blur`,r),window.removeEventListener(`resize`,r,!0),u.disconnect()}},[i]),(0,g.useLayoutEffect)(()=>{o.current()},[e]),(0,g.useLayoutEffect)(()=>{let e=_(i?.dragOperation.source?.data),n=r();e&&n&&!y(e,{...t,projects:p.getState().projects},n.revision)&&o.current()},[i,t,r]),null}function T(e){let t=r(),n=(0,g.useRef)(null),i=(0,g.useRef)(0),a=(0,g.useRef)(e);a.current=e;let[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(null);(0,g.useLayoutEffect)(()=>{if(!c)return;let{source:t,sidebar:n,sourceElement:r,scope:a,version:o}=c;if(o!==i.current||e.scopeKey!==a||document.activeElement!==document.body&&document.activeElement!==r){l(null);return}if(e.busy.has(t.projectId))return;if(!y(t,{...e,projects:p.getState().projects})){l(null);return}let s=[...n?.querySelectorAll(`[data-sidebar-drag-handle="session:${CSS.escape(t.id)}"]`)??[]].find(e=>e.isConnected&&e.getClientRects().length>0&&!e.closest(`[inert], [hidden], [aria-hidden="true"]`));s&&(s.focus(),l(null))},[c,e]);let d=()=>({...e,projects:p.getState().projects}),m=()=>{n.current=null,i.current+=1,s(!1),l(null)},h=e=>{let t=v(e.target?.data);s(!!n.current&&!!t&&n.current.projectId!==t.projectId)};return(0,x.jsxs)(u,{sensors:f,onBeforeDragStart:e=>{let t=_(e.operation.source?.data);if(m(),!t||!y(t,d())){e.preventDefault();return}n.current={...t,revision:d().projects[t.projectId].revision}},onDragOver:e=>h(e.operation),onDragEnd:t=>{let r=n.current,o=v(t.operation.target?.data);if(m(),!(t.canceled||!r||!o||!b(r,o,d())))if(r.kind===`session`){let n=C(t.operation.position.current),s=n&&n.sessionId!==r.id?{...o,sessionId:n.sessionId}:o,c=n?.after??!1,u=t.operation.source?.element,d=u?.closest(`aside`),f=e.scopeKey,p=i.current;e.onMoveSession(r,s,c).then(e=>{e&&p===i.current&&a.current.scopeKey===f&&l({source:r,sidebar:d,sourceElement:u,scope:f,version:p})})}else{let n=t.operation.target?.element,i=(n?.querySelector(`[data-sidebar-section-header]`)??n)?.getBoundingClientRect(),a=!!i&&t.operation.position.current.y>i.top+i.height/2;e.onMoveSection(r,o,a)}},children:[(0,x.jsx)(w,{scopeKey:e.scopeKey,state:e,onCancel:m,getPickup:()=>n.current}),o?(0,x.jsx)(`p`,{role:`status`,className:`px-3 py-2 text-xs text-muted-foreground`,children:t(`sidebar_cross_project_drop_unavailable`)}):null,e.children(S)]})}export{T as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-46ItjLqy.js","./vendor-streamdown-code-pjpYu3vJ.js","./preload-helper-DYl5dUZ5.js","./vendor-markdown-CfSBref-.js","./rolldown-runtime-QTnfLwEv.js","./vendor-react-CCIEwYL0.js","./lib-CFLxRXs3.js","./StreamdownMermaid-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{t as r}from"./preload-helper-DYl5dUZ5.js";import{d as i}from"./vendor-markdown-CfSBref-.js";import{i as a,o,r as s,s as c,t as l}from"./vendor-streamdown-LREut7gy.js";import{i as u,r as d}from"./ui-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-46ItjLqy.js","./vendor-streamdown-code-pjpYu3vJ.js","./preload-helper-DYl5dUZ5.js","./vendor-markdown-CfSBref-.js","./rolldown-runtime-QTnfLwEv.js","./vendor-react-CCIEwYL0.js","./lib-CFLxRXs3.js","./StreamdownMermaid-D1bUSRYY.js","./StreamdownMermaid-DihA1DWx.js","./vendor-mermaid-D-p0xABq.js","./ui-OvgR8HKW.js","./shim-B7rqb4U2.js","./button-Cfb4l-V4.js","./bundle-mjs-B_AA55HL.js","./dist-F2p7j0vG.js","./utils-DqNhCx4L.js","./themeStore-iULXkh0N.js","./react-BqtYw2Yd.js","./textarea-BKzYyWL5.js","./strictConfig-C66PYHjm.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{t as r}from"./preload-helper-DYl5dUZ5.js";import{d as i}from"./vendor-markdown-CfSBref-.js";import{i as a,o,r as s,s as c,t as l}from"./vendor-streamdown-LREut7gy.js";import{i as u,r as d}from"./ui-OvgR8HKW.js";import{t as f}from"./utils-DqNhCx4L.js";import{n as p,r as m}from"./FileOperationsService-XcscMou0.js";import{t as h}from"./ExternalLinkDialog--gaLElt0.js";import{t as g}from"./markdownTheme-DZ_SWMdl.js";var _=e(t(),1),v=[`github-light`,`github-dark-default`],y;function b(){return y??=r(()=>import(`./dist-46ItjLqy.js`).then(e=>e.code),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url),y}var x={name:`shiki`,type:`code-highlighter`,getSupportedLanguages:()=>[],getThemes:()=>v,supportsLanguage:()=>!0,highlight(e,t){return b().then(n=>{let r=n.highlight(e,t);r&&t?.(r)}),null}},S=/^[A-Za-z][A-Za-z\d+.-]*:/,C=new Set([`http:`,`https:`,`mailto:`]),w=new Set([`http:`,`https:`]),T=/\.(?:png|jpe?g|gif|webp)$/i,E=`/__bodhi_local_image__/`;function D(e){return T.test(e)&&(e.startsWith(`/`)&&!e.startsWith(`//`)||/^[A-Za-z]:\//.test(e))}function O(e){let t;if(/^[A-Za-z]:[\\/]/.test(e))t=e.replace(/\\/g,`/`);else try{let n=new URL(e);if(n.protocol!==`file:`||n.host||n.search||n.hash)return null;t=decodeURIComponent(n.pathname),/^\/[A-Za-z]:\//.test(t)&&(t=t.slice(1))}catch{return null}return D(t)?`${E}${encodeURIComponent(t)}`:null}function k(){return e=>{let t=e=>{e.type===`image`&&typeof e.url==`string`&&(e.url=O(e.url)??e.url),e.children?.forEach(t)};t(e)}}function A(e){let t;try{t=decodeURIComponent(e.startsWith(E)?e.slice(23):e)}catch{return null}return!D(t)||!e.startsWith(E)&&/^\/(?:assets|images|icons|api)\//.test(t)?null:t}function j(e){return Array.from(e).some(e=>{let t=e.codePointAt(0);return t!==void 0&&(t<=31||t===127)})}var M=(e,t)=>{let n=e.trim();if(!n||n!==e||j(n)||t!==`href`&&t!==`src`)return null;if(!S.test(n))return n.includes(`\\`)||n.startsWith(`//`)?null:n;try{let e=new URL(n).protocol.toLowerCase();return(t===`src`?w:C).has(e)?n:null}catch{return null}},N=n();function P({src:e,alt:t=``,onPreviewImage:n}){u();let r=e?A(e):null,[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null);if((0,_.useEffect)(()=>{if(!r||!m())return;let e=!1;return p(r).then(t=>{e||a({path:r,dataUrl:t})}).catch(()=>{e||s(r)}),()=>{e=!0}},[r]),!e)return null;if(r&&(!m()||o===r))return(0,N.jsxs)(`span`,{role:`status`,className:`text-xs text-muted-foreground`,children:[d(`local_images_cannot_be_previewed_here_9378ebfb`),t||r]});if(r&&i?.path!==r)return(0,N.jsx)(`span`,{role:`status`,className:`text-xs text-muted-foreground`,children:d(`loading_image_e661c55e`)});let c=r?i.dataUrl:e,l=(0,N.jsx)(`img`,{src:c,alt:t,"data-streamdown":`image`,className:`max-h-48 max-w-full rounded-xl object-contain`});return n?(0,N.jsx)(`button`,{type:`button`,onClick:()=>n(c),"aria-label":d(`preview_image_1689cf75`,{v0:t?`:${t}`:``}),className:`cursor-zoom-in`,children:l}):l}var F=new Set([`a`,`code`,`pre`,`svg`,`math`,`annotation`,`table`,`button`,`input`,`textarea`,`select`,`kbd`,`samp`,`sup`]);function I(e,t){let n=t?``:null,r=``,i=typeof Intl.Segmenter==`function`?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null,a=()=>e=>{let t=[],a=``,o=(e,n=!1)=>{let r=e.properties,i=n||F.has(e.tagName??``)||r?.ariaHidden===!0||r?.ariaHidden===`true`||r?.[`aria-hidden`]===!0||r?.[`aria-hidden`]===`true`;e.children?.forEach((n,r)=>{n.type===`text`?(t.push({node:n,parent:e,index:r,start:a.length,safe:!i}),a+=n.value??``):o(n,i)})};if(o(e),r=a,!i)return;let s=n?.length??0,c=n!==null&&a.startsWith(n),l=t.findLast(e=>e.node.value?.trim()),u=256,d=t.map(e=>{if(!e.safe||!e.node.value?.trim())return null;let t=[],n=``,r=0,a=0;for(let o of i.segment(e.node.value))a===32&&u>0&&(t.push({value:n,start:r,reveal:c&&e.start+r>=s}),--u,r+=n.length,n=``,a=0),n+=o.segment,a+=1;return n&&(t.push({value:n,start:r,reveal:u>0&&c&&e.start+r>=s}),u=Math.max(0,u-1)),t.map((n,r)=>({type:`element`,tagName:`span`,properties:{"data-assistant-reveal-chunk":`true`,"data-assistant-reveal":n.reveal?`true`:void 0,"data-assistant-reveal-tail":e===l&&r===t.length-1?`true`:void 0},children:[{type:`text`,value:n.value}]}))});for(let e=t.length-1;e>=0;--e){let n=d[e],r=t[e];n&&r.parent.children.splice(r.index,1,...n)}};return Object.defineProperty(a,"name",{value:`assistantReveal${e}`}),{plugin:a,commit:()=>{n=r}}}var L=(0,_.createContext)({current:!1});function R({isStreaming:e,children:t}){let n=(0,_.useRef)(!1);return(0,_.useLayoutEffect)(()=>{n.current=e},[e]),(0,N.jsx)(L.Provider,{value:n,children:t})}var z=(0,_.memo)(function({rehypePlugins:e,...t}){let n=(0,_.useContext)(L),r=(0,_.useId)(),i=(0,_.useMemo)(()=>I(r,n.current),[r,n]),a=(0,_.useMemo)(()=>[...e??[],i.plugin],[e,i]);return(0,_.useLayoutEffect)(()=>{i.commit()}),(0,N.jsx)(`div`,{"data-assistant-reveal-block":`true`,style:{display:`contents`},children:(0,N.jsx)(c,{...t,rehypePlugins:a})})});function B({value:e,reveal:t,tail:n}){let r=(0,_.useRef)(null),i=(0,_.useRef)(null),a=(0,_.useRef)(t).current;return(0,_.useLayoutEffect)(()=>{let t=r.current;if(!i.current)i.current=t.ownerDocument.createTextNode(e),t.insertBefore(i.current,t.firstChild);else if(e===i.current.data)return;else e.startsWith(i.current.data)?i.current.appendData(e.slice(i.current.length)):i.current.data=e},[e]),(0,N.jsx)(`span`,{ref:r,"data-assistant-reveal-chunk":`true`,"data-assistant-reveal":a?`true`:void 0,children:n?(0,N.jsx)(`span`,{"aria-hidden":`true`,"data-assistant-streaming-caret":`true`}):null})}function V({children:e,node:t,...n}){return n[`data-assistant-reveal-chunk`]===`true`?(0,N.jsx)(B,{value:String(e??``),reveal:n[`data-assistant-reveal`]===`true`,tail:n[`data-assistant-reveal-tail`]===`true`}):(0,N.jsx)(`span`,{...n,children:e})}var H={block:{gap:`0.25rem`,marginBlock:`0.5rem`,padding:`0.375rem`},body:{fontSize:`0.875rem`,fontWeight:`400`,lineHeight:`1.55`,padding:`0.625rem 0.75rem`},header:{fontSize:`0.75rem`,height:`1.25rem`,lineHeight:`1rem`},source:{background:`transparent`,fontSize:`inherit`,fontWeight:`inherit`,lineHeight:`inherit`,margin:`0`,padding:`0`}};function U(e){for(let t of e.querySelectorAll(`[data-streamdown="code-block"]`))Object.assign(t.style,H.block);for(let t of e.querySelectorAll(`[data-streamdown="code-block-header"]`))Object.assign(t.style,H.header);for(let t of e.querySelectorAll(`[data-streamdown="code-block-body"]`)){Object.assign(t.style,H.body);for(let e of t.querySelectorAll(`pre, code`))Object.assign(e.style,H.source)}}function W(e){u(),(0,_.useLayoutEffect)(()=>{let t=e.current?.querySelector(`.assistant-streamdown`);if(!t)return;for(let[e,n]of Object.entries(g))t.style.setProperty(e,String(n));U(t);let n=new MutationObserver(()=>U(t));return n.observe(t,{childList:!0,subtree:!0}),()=>n.disconnect()},[e])}var G=(0,_.lazy)(()=>r(()=>import(`./StreamdownMermaid-D1bUSRYY.js`),__vite__mapDeps([7,8,4,5,9,2,10,11,12,13,14,15,16,17,18,19]),import.meta.url));function K({code:e,isIncomplete:t,language:n}){return u(),t?(0,N.jsxs)(`div`,{"aria-label":d(`mermaid_diagram_is_still_streaming_317ebd6c`),className:`my-4 min-w-0 rounded-xl border bg-sidebar p-2`,"data-mermaid-state":`incomplete`,role:`status`,children:[(0,N.jsx)(`div`,{className:`px-1 pb-2 font-mono text-xs text-muted-foreground`,children:n}),(0,N.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap rounded-md bg-background p-3 font-mono text-xs [overflow-wrap:anywhere]`,children:e})]}):(0,N.jsx)(_.Suspense,{fallback:(0,N.jsx)(`div`,{"aria-label":d(`loading_mermaid_diagram_b8e5834f`),className:`my-4 min-h-24 animate-pulse rounded-xl border bg-sidebar`,"data-mermaid-state":`loading`,role:`status`}),children:(0,N.jsx)(G,{code:e})})}var q={cjk:l,code:x,renderers:[{component:K,language:`mermaid`}]},J=[i,a.harden],Y=[...Object.values(s),k],X={enabled:!0,renderModal:e=>(0,N.jsx)(h,{...e})},Z={katex:!1,linkMode:`text-only`};function Q({children:e,className:t,isStreaming:n,onPreviewImage:r}){u();let i=(0,_.useRef)(null),a=(0,_.useMemo)(()=>({span:V,img:({node:e,...t})=>(0,N.jsx)(P,{...t,onPreviewImage:r})}),[r]);return W(i),(0,N.jsx)(`div`,{ref:i,style:{display:`contents`},children:(0,N.jsx)(R,{isStreaming:n,children:(0,N.jsx)(o,{animated:!1,BlockComponent:z,className:f(`assistant-streamdown prose max-w-none min-w-0 space-y-0 font-normal text-foreground`,`[overflow-wrap:anywhere] prose-p:my-2 prose-headings:mt-4 prose-headings:mb-2`,`prose-a:text-primary prose-li:my-0.5`,n&&`assistant-streamdown-streaming`,t),codeBlockMaxHeight:1/0,controls:!1,components:a,dir:`auto`,isAnimating:n,lineNumbers:!1,linkSafety:X,mode:n?`streaming`:`static`,parseIncompleteMarkdown:n,plugins:q,rehypePlugins:J,remarkPlugins:Y,remend:Z,shikiTheme:v,tableMaxHeight:1/0,urlTransform:M,children:e})})})}export{Q as StreamdownMarkdown};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./StreamdownMermaid-DihA1DWx.js";export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{t as r}from"./vendor-mermaid-D-p0xABq.js";import{i,r as a}from"./ui-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{t as r}from"./vendor-mermaid-D-p0xABq.js";import{i,r as a}from"./ui-OvgR8HKW.js";import{t as o}from"./button-Cfb4l-V4.js";import{t as s}from"./themeStore-iULXkh0N.js";import{t as c}from"./textarea-BKzYyWL5.js";import{n as l,t as u}from"./strictConfig-C66PYHjm.js";var d=e(t(),1),f=n(),p=r({config:u}),m=0;function h({code:e}){return(0,f.jsx)(g,{original:e},e)}function g({original:e}){i();let t=s(e=>e.themeMode),n=(0,d.useId)(),r=(0,d.useRef)(null),[u,h]=(0,d.useState)(e),[g,_]=(0,d.useState)(e),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(0),[S,C]=(0,d.useState)({kind:`loading`}),w=()=>{y(!1),r.current?.focus()};(0,d.useEffect)(()=>{let e=!1;C({kind:`loading`});let n=p.getMermaid(l(`app`,t)),r=`streamdown-mermaid-${m++}`;return n.render(r,u).then(({svg:n})=>{e||C({kind:`ready`,source:u,theme:t,svg:n})}).catch(n=>{e||C({kind:`error`,message:n instanceof Error?n.message:String(n),source:u,theme:t})}),()=>{e=!0}},[u,t,b]);let T=S.kind!==`loading`&&S.source===u&&S.theme===t,E=T?S.kind:`loading`;return(0,f.jsxs)(`figure`,{className:`my-4 min-w-0 rounded-xl border bg-card`,"data-mermaid-state":E,children:[(0,f.jsxs)(`figcaption`,{className:`flex flex-wrap items-center gap-2 px-3 py-2 text-sm`,children:[(0,f.jsx)(`span`,{className:`font-medium`,children:a(`mermaid_diagram_2a0d4106`)}),(0,f.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-1`,children:[(0,f.jsx)(o,{ref:r,type:`button`,size:`sm`,variant:`ghost`,"aria-expanded":v,onClick:()=>{_(u),y(!v)},children:a(`mermaid_edit_source`)}),(0,f.jsx)(o,{type:`button`,size:`sm`,variant:`ghost`,disabled:E===`loading`,onClick:()=>x(e=>e+1),children:a(`mermaid_render_again`)}),u!==e&&(0,f.jsx)(o,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{h(e),_(e),w(),x(e=>e+1)},children:a(`mermaid_restore_original`)})]})]}),v&&(0,f.jsxs)(`form`,{className:`space-y-2 border-t p-3`,onSubmit:e=>{e.preventDefault(),g.trim()&&(h(g),w(),x(e=>e+1))},children:[(0,f.jsx)(`label`,{htmlFor:n,className:`block text-sm font-medium`,children:a(`mermaid_source`)}),(0,f.jsx)(c,{id:n,"aria-describedby":`${n}-hint`,value:g,rows:8,className:`min-h-40 max-h-80 border bg-background font-mono text-sm`,autoFocus:!0,dir:`ltr`,spellCheck:!1,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&(e.preventDefault(),e.stopPropagation(),w())}}),(0,f.jsx)(`p`,{id:`${n}-hint`,className:`text-xs text-muted-foreground`,children:a(`mermaid_local_preview_hint`)}),(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(o,{type:`submit`,size:`sm`,disabled:!g.trim(),children:a(`mermaid_render_preview`)}),(0,f.jsx)(o,{type:`button`,size:`sm`,variant:`ghost`,onClick:w,children:a(`mermaid_cancel_edit`)})]})]}),E===`loading`?(0,f.jsx)(`div`,{"aria-label":a(`rendering_mermaid_diagram_beb228f6`),className:`min-h-24 animate-pulse rounded-xl bg-sidebar`,role:`status`}):T&&S.kind===`error`?(0,f.jsxs)(`div`,{className:`space-y-2 border-t p-3`,children:[(0,f.jsx)(`p`,{role:`alert`,className:`text-sm font-medium text-destructive`,children:a(`could_not_render_mermaid_diagram_c26105d4`)}),(0,f.jsxs)(`details`,{className:`text-xs`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:a(`mermaid_error_details`)}),(0,f.jsx)(`pre`,{className:`mt-2 max-h-40 overflow-auto whitespace-pre-wrap font-mono [overflow-wrap:anywhere]`,children:S.message})]}),!v&&(0,f.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap font-mono text-xs [overflow-wrap:anywhere]`,"data-mermaid-source":!0,children:u})]}):T&&S.kind===`ready`?(0,f.jsx)(`div`,{"aria-label":a(`mermaid_diagram_2a0d4106`),role:`img`,className:`flex min-w-0 justify-center overflow-x-auto rounded-xl bg-background p-2 [&_svg]:h-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:S.svg}}):null]})}export{h as t};
|
package/dist/assets/{SupervisorManagedSessions-DDL1goCC.js → SupervisorManagedSessions-CDSclXHy.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{a as r}from"./ui-DQy0lUHc.js";import{t as i}from"./refresh-cw-DHR8UyeF.js";import{c as a,r as o}from"./api-dae15_RX.js";import{t as s}from"./button-Cfb4l-V4.js";import{a as c,i as l,n as u,o as d,r as f,t as p}from"./dialog-CfOua_Le.js";import{a as m,o as h}from"./client-IKYlOoXY.js";import{t as g}from"./SupervisorProjectScopeDialog-BRpx_B7f.js";import{a as _,n as v,o as y,t as b}from"./managedSessions-Df_XdXaQ.js";var x=e(t(),1),S=()=>({observation:null,candidates:[],nextOffset:null,nextAfter:null,loading:!1,catalogError:!1,loadingMore:!1,problem:null,review:null,notice:null,submitting:!1,writeBlocked:!0});function C(e,t=_){let[n,r]=(0,x.useState)(S),i=(0,x.useRef)(n);i.current=n;let s=(0,x.useRef)(e);s.current=e;let c=(0,x.useRef)(0),l=(0,x.useRef)(0),u=(0,x.useRef)(null),d=(0,x.useRef)(null),f=(0,x.useRef)(null),p=(0,x.useCallback)((e,n,i)=>{!t.describe||!e.length||t.describe(e,n.signal).then(e=>{!i()||n.signal.aborted||r(t=>t.observation?.management_access&&t.observation.owner_authorization.available?{...t,candidates:[...new Map([...t.candidates,...e].map(e=>[e.session_id,e])).values()]}:t)}).catch(()=>{})},[t]),g=(0,x.useCallback)(async()=>{let e=c.current,n=++l.current;u.current?.abort(),f.current=null;let i=new AbortController;u.current=i,r(e=>({...e,loading:!0,loadingMore:!1,review:null,problem:null,writeBlocked:!0}));let a=()=>s.current&&c.current===e&&l.current===n,o;try{o=await t.read(i.signal)}catch(e){return a()?(l.current+=1,r(t=>({...t,loading:!1,observation:null,nextAfter:null,problem:y(e),writeBlocked:!0})),null):null}if(!a())return null;let d={sessions:[],nextOffset:null},m=!1;if(!o.management_access)try{d=await t.candidates()}catch{m=!0}return a()?(r(e=>({...e,loading:!1,observation:o,candidates:d.sessions,nextOffset:d.nextOffset,nextAfter:o.next_after??null,catalogError:m,problem:null,review:null,writeBlocked:!1})),o.management_access&&o.owner_authorization.available&&p(o.sessions,i,a),o):null},[t,p]);(0,x.useEffect)(()=>(c.current+=1,d.current=null,f.current=null,r(S()),e&&g(),()=>{c.current+=1,l.current+=1,u.current?.abort()}),[e,g]);let C=(0,x.useCallback)(()=>s.current&&!d.current?g():Promise.resolve(null),[g]),w=(0,x.useCallback)((e=!0)=>{let t=c.current,n=l.current,r=i.current.observation,a=i.current.problem,o=f.current;return()=>s.current&&c.current===t&&l.current===n&&(e?r!==null&&f.current===null&&i.current.observation===r&&!i.current.loading&&!i.current.problem&&r.owner_authorization.available:i.current.problem===a&&f.current===o)},[]),T=(0,x.useCallback)(async()=>{let e=i.current;if(!s.current||f.current||d.current||e.loading||e.nextOffset===null&&e.nextAfter===null)return;let n={},a=c.current,g=l.current,_=e.nextOffset;f.current=n,r(e=>({...e,loadingMore:!0}));let v=()=>s.current&&c.current===a&&l.current===g&&f.current===n;try{if(e.observation?.management_access){if(e.nextAfter===null)return;let n=await t.read(u.current?.signal,{after:e.nextAfter,limit:20});if(!v())return;if(!n.management_access||!h(n.scope.supervisor,e.observation.scope.supervisor)||n.scope.state_revision!==e.observation.scope.state_revision||!m(n.scope.allowed_projects,e.observation.scope.allowed_projects))throw new o(`directory_scope_changed`,409,``,JSON.stringify({code:`scope_revision_conflict`}));r(e=>({...e,observation:{...n,sessions:[...new Map([...e.observation?.sessions??[],...n.sessions].map(e=>[e.session_id,e])).values()]},nextAfter:n.next_after??null,problem:null}));let i=u.current;i&&n.owner_authorization.available&&p(n.sessions,i,()=>s.current&&c.current===a&&l.current===g&&u.current===i);return}let n=await t.candidates(_??void 0);if(!v())return;r(e=>({...e,candidates:[...new Map([...e.candidates,...n.sessions].map(e=>[e.session_id,e])).values()],nextOffset:n.nextOffset,catalogError:!1}))}catch(t){v()&&r(n=>{if(!e.observation?.management_access)return{...n,catalogError:!0};let r=y(t);return{...n,problem:r,...[`authentication`,`forbidden`,`conflict`].includes(r.kind)?{observation:null,candidates:[],nextAfter:null,nextOffset:null,writeBlocked:!0}:{}}})}finally{if(f.current===n){let e=v();f.current=null,e&&r(e=>({...e,loadingMore:!1}))}}},[t,p]),E=(0,x.useMemo)(()=>{if(n.observation?.management_access){let e=new Map(n.candidates.map(e=>[JSON.stringify(e.observedTarget),e])),t=n.observation.owner_authorization.available;return n.observation.sessions.map(n=>({session_id:n.session_id,link:n,summary:t&&n.current_user_target?e.get(JSON.stringify(n.current_user_target)):void 0,status:`current_user`,canEnable:!1}))}let e=new Set(n.observation?.scope.allowed_projects),t=new Map(n.candidates.map(e=>[e.session_id,e])),r=new Map(n.observation?.sessions.map(e=>[e.session_id,e]));return[...new Set([...r.keys(),...n.candidates.filter(t=>t.project_id!==null&&e.has(t.project_id)).map(e=>e.session_id)])].sort().map(n=>{let i=r.get(n),a=t.get(n);return{session_id:n,link:i,summary:a,status:i?.authorization_error?`unavailable`:i?.authorized?`authorized`:i?.enabled?`reconfirm`:i?`detached`:`available`,canEnable:!i?.authorization_error&&!!a?.project_id&&e.has(a.project_id)}})},[n.observation,n.candidates]),D=(0,x.useCallback)((e,t)=>{let n=i.current,a=E.find(t=>t.session_id===e);if(!s.current||!n.observation||n.loading||n.submitting||n.writeBlocked||!b(n.observation)||!a||t&&(!a.canEnable||n.catalogError||a.link?.authorized)||!t&&!a.link?.enabled)return;let o=Object.freeze({supervisor:Object.freeze({...n.observation.scope.supervisor}),expected_state_revision:n.observation.scope.state_revision,target_session_id:e,enabled:t});r(e=>({...e,review:o,notice:null}))},[E]),O=(0,x.useCallback)(async()=>{let e=i.current,n=e.review;if(!s.current||d.current||!n||!e.observation||e.loading||e.writeBlocked||!b(e.observation)||!h(n.supervisor,e.observation.scope.supervisor)||n.expected_state_revision!==e.observation.scope.state_revision)return;let o={},l=c.current;d.current=o;let u=()=>s.current&&c.current===l&&d.current===o;r(e=>({...e,submitting:!0,notice:null}));try{let e=null,i=`unknown`;try{e=v(await t.update(n),n)}catch(e){a(e)&&(i=e.status===409?`conflict`:[400,401,403,404].includes(e.status)?`rejected`:`unknown`)}if(!u())return;let o=await g();if(!u())return;let s=o?.sessions.find(e=>e.session_id===n.target_session_id);e&&o&&!o.management_access&&h(e.supervisor,o.scope.supervisor)&&e.state_revision===o.scope.state_revision&&e.link_revision===(s?.link_revision??null)&&(n.enabled?s?.enabled&&s.authorized:!s?.enabled)&&(i=`saved`),r(e=>({...e,review:null,notice:i,writeBlocked:o===null}))}finally{u()&&(d.current=null,r(e=>({...e,submitting:!1})))}},[t,g]);return{...n,rows:E,refresh:C,loadMore:T,navigationGuard:w,reviewTarget:D,confirm:O,currentUser:n.observation?.management_access?.kind===`current_user`,cancelReview:()=>r(e=>({...e,review:null})),canManage:!n.loading&&!n.submitting&&!n.writeBlocked&&b(n.observation)}}var w=n();function T(e,t){let n=(0,x.useRef)(null),r=(0,x.useRef)(null),i=(0,x.useRef)(null);return(0,x.useLayoutEffect)(()=>{let t=i.current;!t||e||(i.current=null,!t.isConnected&&document.activeElement===document.body&&r.current?.focus())},[e,t]),{more:n,fallback:r,remember:()=>{i.current=document.activeElement===n.current?n.current:null}}}var E={current_user:`supervisor_sessions_current_user_status`,authorized:`supervisor_sessions_authorized`,reconfirm:`supervisor_sessions_reconfirm`,detached:`supervisor_sessions_detached`,available:`supervisor_sessions_available`,unavailable:`supervisor_sessions_unverified`},D={unsupported:`supervisor_sessions_unsupported`,missing:`supervisor_sessions_missing`,authentication:`supervisor_scope_access_required`,forbidden:`supervisor_scope_forbidden`,conflict:`supervisor_sessions_conflict`,unavailable:`supervisor_sessions_unavailable`,invalid:`supervisor_sessions_invalid`,error:`supervisor_sessions_unavailable`},O={saved:`supervisor_sessions_saved`,unknown:`supervisor_sessions_unknown`,conflict:`supervisor_sessions_conflict`,rejected:`supervisor_sessions_rejected`};function k({controller:e}){let t=r();return(0,w.jsxs)(w.Fragment,{children:[e.loading||!e.observation&&!e.problem?(0,w.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:t(`supervisor_sessions_loading`)}):null,e.problem?(0,w.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:t(D[e.problem.kind])}):null,e.notice?(0,w.jsx)(`p`,{role:e.notice===`saved`?`status`:`alert`,className:`text-xs text-muted-foreground`,children:t(O[e.notice])}):null,e.catalogError?(0,w.jsx)(`p`,{role:`alert`,className:`text-xs text-muted-foreground`,children:t(`supervisor_sessions_catalog_failed`)}):null,e.observation&&!e.observation.owner_authorization.available?(0,w.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:t(`supervisor_scope_access_required`)}):null,e.currentUser&&e.observation?.capabilities.current_user_bound_history_v1!==!0?(0,w.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:t(`supervisor_sessions_bound_history_unsupported`)}):null]})}function A({row:e}){let t=r(),n=e.summary?.is_running?t(`supervisor_sessions_running`):e.summary?.last_run_status;return(0,w.jsxs)(`div`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:[(0,w.jsx)(`p`,{className:`text-sm font-medium`,children:e.summary?.title||e.session_id}),(0,w.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(E[e.status]),e.link?.kind?` · ${e.link.kind===`root`?`Root`:`Child`}`:``,n?` · ${t(`supervisor_sessions_progress`,{progress:n})}`:``]}),e.summary?.model?(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`supervisor_sessions_model`,{model:e.summary.model})}):null]})}function j({open:e,onOpenChange:t,returnFocus:n,dependencies:i,onOpenSession:a,opening:o=!1,openFailed:m=!1}){let h=r(),_=C(e,i),v=T(_.loadingMore,_.nextAfter??_.nextOffset),[y,b]=(0,x.useState)(!1),S=(0,x.useRef)(null),E=(0,x.useRef)(!1),D=_.rows.find(e=>e.session_id===_.review?.target_session_id);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p,{open:e,onOpenChange:e=>{!_.submitting&&!y&&!E.current&&t(e)},children:(0,w.jsxs)(u,{className:`max-h-[90dvh] overflow-y-auto`,showCloseButton:!_.submitting,onEscapeKeyDown:e=>{(_.submitting||y||E.current)&&e.preventDefault()},onInteractOutside:e=>{(_.submitting||y||E.current)&&e.preventDefault()},onCloseAutoFocus:n?e=>{e.preventDefault(),n()}:void 0,children:[(0,w.jsxs)(c,{children:[(0,w.jsx)(d,{children:h(`supervisor_sessions_title`)}),(0,w.jsx)(f,{children:h(_.currentUser?`supervisor_sessions_current_user_description`:`supervisor_sessions_description`)})]}),(0,w.jsxs)(`div`,{className:`space-y-3`,"data-testid":`supervisor-managed-sessions`,children:[(0,w.jsx)(k,{controller:_}),m?(0,w.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:h(`supervisor_sessions_open_failed`)}):null,(0,w.jsx)(s,{ref:S,variant:`outline`,size:`sm`,disabled:_.submitting,onClick:()=>{_.cancelReview(),b(!0)},children:h(_.currentUser?`supervisor_scope_current_user_title`:`supervisor_scope_title`)}),_.currentUser?(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`supervisor_sessions_legacy_links`,{count:Object.keys(_.observation?.legacy_links??{}).length})}):_.observation?.scope.allowed_projects.length===0?(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`supervisor_sessions_no_scope`)}):null,_.review?(0,w.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-3`,"data-testid":`managed-session-review`,children:[(0,w.jsx)(`p`,{className:`text-sm`,children:h(_.review.enabled?`supervisor_sessions_review_attach`:`supervisor_sessions_review_detach`,{title:D?.summary?.title||_.review.target_session_id})}),(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`supervisor_sessions_context_preserved`)}),(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[(0,w.jsx)(s,{variant:`outline`,disabled:_.submitting,onClick:_.cancelReview,children:h(`cancel_2cd0f3be`)}),(0,w.jsx)(s,{disabled:!_.canManage,onClick:()=>void _.confirm(),children:h(_.submitting?`supervisor_sessions_saving`:`supervisor_sessions_confirm`)})]})]}):(0,w.jsxs)(w.Fragment,{children:[_.observation&&!_.loading&&!_.rows.length?(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h(_.currentUser?`supervisor_sessions_current_user_empty`:`supervisor_sessions_empty`)}):null,(0,w.jsx)(`ul`,{className:`space-y-2`,children:_.rows.map(e=>(0,w.jsxs)(`li`,{"data-managed-session":e.session_id,className:`flex items-center gap-3 rounded-lg border p-3`,children:[(0,w.jsx)(A,{row:e}),_.currentUser?a?(0,w.jsx)(s,{size:`sm`,variant:`ghost`,disabled:o||_.loading||_.loadingMore||!!_.problem||!_.observation?.owner_authorization.available||_.observation.capabilities.current_user_bound_history_v1!==!0,onClick:()=>{_.observation&&a(e,_.observation,_.navigationGuard())},children:h(`supervisor_sessions_open`)}):null:(0,w.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1`,children:[e.link?.authorized?null:(0,w.jsx)(s,{size:`sm`,variant:`outline`,disabled:!_.canManage||!e.canEnable||_.catalogError,onClick:()=>_.reviewTarget(e.session_id,!0),children:h(e.status===`reconfirm`?`supervisor_sessions_reconfirm_action`:`supervisor_sessions_attach`)}),e.link?.enabled?(0,w.jsx)(s,{size:`sm`,variant:`ghost`,disabled:!_.canManage,onClick:()=>_.reviewTarget(e.session_id,!1),children:h(`supervisor_sessions_detach`)}):null]})]},e.session_id))}),_.nextOffset!==null||_.nextAfter!==null?(0,w.jsx)(s,{ref:v.more,size:`sm`,variant:`outline`,disabled:_.loadingMore||_.loading||_.submitting,onClick:()=>{v.remember(),_.loadMore()},children:h(`supervisor_sessions_more`)}):null]})]}),(0,w.jsxs)(l,{children:[(0,w.jsx)(s,{ref:v.fallback,variant:`outline`,disabled:_.loading||_.submitting,onClick:()=>void _.refresh(),children:h(`supervisor_scope_refresh`)}),(0,w.jsx)(s,{variant:`outline`,disabled:_.submitting,onClick:()=>t(!1),children:h(`supervisor_scope_close`)})]})]})}),y?(0,w.jsx)(g,{open:!0,onOpenChange:e=>{e||(E.current=!0,window.setTimeout(()=>{E.current=!1},0)),b(e),e||_.refresh()},returnFocus:()=>S.current?.focus()}):null]})}function M({active:e,onSelectSession:t,dependencies:n}){let a=r(),o=C(e,n),c=T(o.loadingMore,o.nextAfter??o.nextOffset),[l,u]=(0,x.useState)(!1),[d,f]=(0,x.useState)(null),[p,m]=(0,x.useState)(!1),h=(0,x.useRef)(!1),g=o.rows.filter(e=>!!e.link),_=async(e,n,r)=>{if(h.current)return;let i=e.link?.current_user_target,a=o.navigationGuard(!r),s=()=>a()&&(!r||r());if(!s()||n.management_access&&(!n.owner_authorization.available||!i||n.capabilities.current_user_bound_history_v1!==!0)){m(!0);return}h.current=!0,f(e.session_id),m(!1);try{(i&&n.management_access?await t(e.session_id,{target:i,supervisor:n.scope.supervisor},s):await t(e.session_id))===!1&&m(!0)}catch{m(!0)}finally{h.current=!1,f(null)}};return(0,w.jsxs)(`section`,{className:`rounded-lg border p-3`,"data-testid":`supervisor-managed-panel`,"aria-busy":o.loading,children:[(0,w.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-medium`,children:a(`supervisor_sessions_title`)}),(0,w.jsx)(s,{size:`sm`,variant:`ghost`,disabled:o.loading,"aria-label":a(`supervisor_sessions_refresh`),onClick:()=>void o.refresh(),children:(0,w.jsx)(i,{})})]}),(0,w.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:a(o.currentUser?`supervisor_sessions_current_user_description`:`supervisor_sessions_panel_description`)}),(0,w.jsx)(k,{controller:o}),p?(0,w.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:a(`supervisor_sessions_open_failed`)}):null,o.observation&&!o.loading&&!g.length?(0,w.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:a(o.currentUser?`supervisor_sessions_current_user_empty`:o.observation.scope.allowed_projects.length?`supervisor_sessions_none_attached`:`supervisor_sessions_no_scope`)}):null,(0,w.jsx)(`ul`,{className:`max-h-64 space-y-3 overflow-y-auto`,children:g.map(e=>(0,w.jsxs)(`li`,{className:`flex items-center gap-2`,"data-managed-session":e.session_id,children:[(0,w.jsx)(A,{row:e}),(0,w.jsx)(s,{size:`sm`,variant:`ghost`,disabled:d!==null||o.loading||o.loadingMore||!!o.problem||!o.observation?.owner_authorization.available||!!o.currentUser&&o.observation.capabilities.current_user_bound_history_v1!==!0,onClick:()=>{o.observation&&_(e,o.observation)},children:a(`supervisor_sessions_open`)})]},e.session_id))}),o.currentUser&&o.nextAfter!==null?(0,w.jsx)(s,{ref:c.more,size:`sm`,variant:`outline`,disabled:o.loadingMore||o.loading,onClick:()=>{c.remember(),o.loadMore()},children:a(`supervisor_sessions_more`)}):null,(0,w.jsx)(s,{ref:c.fallback,variant:`outline`,size:`sm`,className:`mt-3`,onClick:()=>u(!0),children:a(o.currentUser?`supervisor_sessions_browse`:`supervisor_sessions_manage`)}),l?(0,w.jsx)(j,{open:!0,dependencies:n,onOpenSession:_,opening:d!==null,openFailed:p,onOpenChange:e=>{u(e),e||o.refresh()},returnFocus:()=>c.fallback.current?.focus()}):null]})}export{j as SupervisorManagedSessionsDialog,M as SupervisorManagedSessionsPanel};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{a as r}from"./ui-OvgR8HKW.js";import{t as i}from"./refresh-cw-DHR8UyeF.js";import{c as a,r as o}from"./api-CPcpMjoM.js";import{t as s}from"./button-Cfb4l-V4.js";import{a as c,i as l,n as u,o as d,r as f,t as p}from"./dialog-CfOua_Le.js";import{a as m,o as h}from"./client-Cxjm7aQO.js";import{t as g}from"./SupervisorProjectScopeDialog-CqLk6xn2.js";import{a as _,n as v,o as y,t as b}from"./managedSessions-CyG8WTnE.js";var x=e(t(),1),S=()=>({observation:null,candidates:[],nextOffset:null,nextAfter:null,loading:!1,catalogError:!1,loadingMore:!1,problem:null,review:null,notice:null,submitting:!1,writeBlocked:!0});function C(e,t=_){let[n,r]=(0,x.useState)(S),i=(0,x.useRef)(n);i.current=n;let s=(0,x.useRef)(e);s.current=e;let c=(0,x.useRef)(0),l=(0,x.useRef)(0),u=(0,x.useRef)(null),d=(0,x.useRef)(null),f=(0,x.useRef)(null),p=(0,x.useCallback)((e,n,i)=>{!t.describe||!e.length||t.describe(e,n.signal).then(e=>{!i()||n.signal.aborted||r(t=>t.observation?.management_access&&t.observation.owner_authorization.available?{...t,candidates:[...new Map([...t.candidates,...e].map(e=>[e.session_id,e])).values()]}:t)}).catch(()=>{})},[t]),g=(0,x.useCallback)(async()=>{let e=c.current,n=++l.current;u.current?.abort(),f.current=null;let i=new AbortController;u.current=i,r(e=>({...e,loading:!0,loadingMore:!1,review:null,problem:null,writeBlocked:!0}));let a=()=>s.current&&c.current===e&&l.current===n,o;try{o=await t.read(i.signal)}catch(e){return a()?(l.current+=1,r(t=>({...t,loading:!1,observation:null,nextAfter:null,problem:y(e),writeBlocked:!0})),null):null}if(!a())return null;let d={sessions:[],nextOffset:null},m=!1;if(!o.management_access)try{d=await t.candidates()}catch{m=!0}return a()?(r(e=>({...e,loading:!1,observation:o,candidates:d.sessions,nextOffset:d.nextOffset,nextAfter:o.next_after??null,catalogError:m,problem:null,review:null,writeBlocked:!1})),o.management_access&&o.owner_authorization.available&&p(o.sessions,i,a),o):null},[t,p]);(0,x.useEffect)(()=>(c.current+=1,d.current=null,f.current=null,r(S()),e&&g(),()=>{c.current+=1,l.current+=1,u.current?.abort()}),[e,g]);let C=(0,x.useCallback)(()=>s.current&&!d.current?g():Promise.resolve(null),[g]),w=(0,x.useCallback)((e=!0)=>{let t=c.current,n=l.current,r=i.current.observation,a=i.current.problem,o=f.current;return()=>s.current&&c.current===t&&l.current===n&&(e?r!==null&&f.current===null&&i.current.observation===r&&!i.current.loading&&!i.current.problem&&r.owner_authorization.available:i.current.problem===a&&f.current===o)},[]),T=(0,x.useCallback)(async()=>{let e=i.current;if(!s.current||f.current||d.current||e.loading||e.nextOffset===null&&e.nextAfter===null)return;let n={},a=c.current,g=l.current,_=e.nextOffset;f.current=n,r(e=>({...e,loadingMore:!0}));let v=()=>s.current&&c.current===a&&l.current===g&&f.current===n;try{if(e.observation?.management_access){if(e.nextAfter===null)return;let n=await t.read(u.current?.signal,{after:e.nextAfter,limit:20});if(!v())return;if(!n.management_access||!h(n.scope.supervisor,e.observation.scope.supervisor)||n.scope.state_revision!==e.observation.scope.state_revision||!m(n.scope.allowed_projects,e.observation.scope.allowed_projects))throw new o(`directory_scope_changed`,409,``,JSON.stringify({code:`scope_revision_conflict`}));r(e=>({...e,observation:{...n,sessions:[...new Map([...e.observation?.sessions??[],...n.sessions].map(e=>[e.session_id,e])).values()]},nextAfter:n.next_after??null,problem:null}));let i=u.current;i&&n.owner_authorization.available&&p(n.sessions,i,()=>s.current&&c.current===a&&l.current===g&&u.current===i);return}let n=await t.candidates(_??void 0);if(!v())return;r(e=>({...e,candidates:[...new Map([...e.candidates,...n.sessions].map(e=>[e.session_id,e])).values()],nextOffset:n.nextOffset,catalogError:!1}))}catch(t){v()&&r(n=>{if(!e.observation?.management_access)return{...n,catalogError:!0};let r=y(t);return{...n,problem:r,...[`authentication`,`forbidden`,`conflict`].includes(r.kind)?{observation:null,candidates:[],nextAfter:null,nextOffset:null,writeBlocked:!0}:{}}})}finally{if(f.current===n){let e=v();f.current=null,e&&r(e=>({...e,loadingMore:!1}))}}},[t,p]),E=(0,x.useMemo)(()=>{if(n.observation?.management_access){let e=new Map(n.candidates.map(e=>[JSON.stringify(e.observedTarget),e])),t=n.observation.owner_authorization.available;return n.observation.sessions.map(n=>({session_id:n.session_id,link:n,summary:t&&n.current_user_target?e.get(JSON.stringify(n.current_user_target)):void 0,status:`current_user`,canEnable:!1}))}let e=new Set(n.observation?.scope.allowed_projects),t=new Map(n.candidates.map(e=>[e.session_id,e])),r=new Map(n.observation?.sessions.map(e=>[e.session_id,e]));return[...new Set([...r.keys(),...n.candidates.filter(t=>t.project_id!==null&&e.has(t.project_id)).map(e=>e.session_id)])].sort().map(n=>{let i=r.get(n),a=t.get(n);return{session_id:n,link:i,summary:a,status:i?.authorization_error?`unavailable`:i?.authorized?`authorized`:i?.enabled?`reconfirm`:i?`detached`:`available`,canEnable:!i?.authorization_error&&!!a?.project_id&&e.has(a.project_id)}})},[n.observation,n.candidates]),D=(0,x.useCallback)((e,t)=>{let n=i.current,a=E.find(t=>t.session_id===e);if(!s.current||!n.observation||n.loading||n.submitting||n.writeBlocked||!b(n.observation)||!a||t&&(!a.canEnable||n.catalogError||a.link?.authorized)||!t&&!a.link?.enabled)return;let o=Object.freeze({supervisor:Object.freeze({...n.observation.scope.supervisor}),expected_state_revision:n.observation.scope.state_revision,target_session_id:e,enabled:t});r(e=>({...e,review:o,notice:null}))},[E]),O=(0,x.useCallback)(async()=>{let e=i.current,n=e.review;if(!s.current||d.current||!n||!e.observation||e.loading||e.writeBlocked||!b(e.observation)||!h(n.supervisor,e.observation.scope.supervisor)||n.expected_state_revision!==e.observation.scope.state_revision)return;let o={},l=c.current;d.current=o;let u=()=>s.current&&c.current===l&&d.current===o;r(e=>({...e,submitting:!0,notice:null}));try{let e=null,i=`unknown`;try{e=v(await t.update(n),n)}catch(e){a(e)&&(i=e.status===409?`conflict`:[400,401,403,404].includes(e.status)?`rejected`:`unknown`)}if(!u())return;let o=await g();if(!u())return;let s=o?.sessions.find(e=>e.session_id===n.target_session_id);e&&o&&!o.management_access&&h(e.supervisor,o.scope.supervisor)&&e.state_revision===o.scope.state_revision&&e.link_revision===(s?.link_revision??null)&&(n.enabled?s?.enabled&&s.authorized:!s?.enabled)&&(i=`saved`),r(e=>({...e,review:null,notice:i,writeBlocked:o===null}))}finally{u()&&(d.current=null,r(e=>({...e,submitting:!1})))}},[t,g]);return{...n,rows:E,refresh:C,loadMore:T,navigationGuard:w,reviewTarget:D,confirm:O,currentUser:n.observation?.management_access?.kind===`current_user`,cancelReview:()=>r(e=>({...e,review:null})),canManage:!n.loading&&!n.submitting&&!n.writeBlocked&&b(n.observation)}}var w=n();function T(e,t){let n=(0,x.useRef)(null),r=(0,x.useRef)(null),i=(0,x.useRef)(null);return(0,x.useLayoutEffect)(()=>{let t=i.current;!t||e||(i.current=null,!t.isConnected&&document.activeElement===document.body&&r.current?.focus())},[e,t]),{more:n,fallback:r,remember:()=>{i.current=document.activeElement===n.current?n.current:null}}}var E={current_user:`supervisor_sessions_current_user_status`,authorized:`supervisor_sessions_authorized`,reconfirm:`supervisor_sessions_reconfirm`,detached:`supervisor_sessions_detached`,available:`supervisor_sessions_available`,unavailable:`supervisor_sessions_unverified`},D={unsupported:`supervisor_sessions_unsupported`,missing:`supervisor_sessions_missing`,authentication:`supervisor_scope_access_required`,forbidden:`supervisor_scope_forbidden`,conflict:`supervisor_sessions_conflict`,unavailable:`supervisor_sessions_unavailable`,invalid:`supervisor_sessions_invalid`,error:`supervisor_sessions_unavailable`},O={saved:`supervisor_sessions_saved`,unknown:`supervisor_sessions_unknown`,conflict:`supervisor_sessions_conflict`,rejected:`supervisor_sessions_rejected`};function k({controller:e}){let t=r();return(0,w.jsxs)(w.Fragment,{children:[e.loading||!e.observation&&!e.problem?(0,w.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:t(`supervisor_sessions_loading`)}):null,e.problem?(0,w.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:t(D[e.problem.kind])}):null,e.notice?(0,w.jsx)(`p`,{role:e.notice===`saved`?`status`:`alert`,className:`text-xs text-muted-foreground`,children:t(O[e.notice])}):null,e.catalogError?(0,w.jsx)(`p`,{role:`alert`,className:`text-xs text-muted-foreground`,children:t(`supervisor_sessions_catalog_failed`)}):null,e.observation&&!e.observation.owner_authorization.available?(0,w.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:t(`supervisor_scope_access_required`)}):null,e.currentUser&&e.observation?.capabilities.current_user_bound_history_v1!==!0?(0,w.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:t(`supervisor_sessions_bound_history_unsupported`)}):null]})}function A({row:e}){let t=r(),n=e.summary?.is_running?t(`supervisor_sessions_running`):e.summary?.last_run_status;return(0,w.jsxs)(`div`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:[(0,w.jsx)(`p`,{className:`text-sm font-medium`,children:e.summary?.title||e.session_id}),(0,w.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(E[e.status]),e.link?.kind?` · ${e.link.kind===`root`?`Root`:`Child`}`:``,n?` · ${t(`supervisor_sessions_progress`,{progress:n})}`:``]}),e.summary?.model?(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`supervisor_sessions_model`,{model:e.summary.model})}):null]})}function j({open:e,onOpenChange:t,returnFocus:n,dependencies:i,onOpenSession:a,opening:o=!1,openFailed:m=!1}){let h=r(),_=C(e,i),v=T(_.loadingMore,_.nextAfter??_.nextOffset),[y,b]=(0,x.useState)(!1),S=(0,x.useRef)(null),E=(0,x.useRef)(!1),D=_.rows.find(e=>e.session_id===_.review?.target_session_id);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p,{open:e,onOpenChange:e=>{!_.submitting&&!y&&!E.current&&t(e)},children:(0,w.jsxs)(u,{className:`max-h-[90dvh] overflow-y-auto`,showCloseButton:!_.submitting,onEscapeKeyDown:e=>{(_.submitting||y||E.current)&&e.preventDefault()},onInteractOutside:e=>{(_.submitting||y||E.current)&&e.preventDefault()},onCloseAutoFocus:n?e=>{e.preventDefault(),n()}:void 0,children:[(0,w.jsxs)(c,{children:[(0,w.jsx)(d,{children:h(`supervisor_sessions_title`)}),(0,w.jsx)(f,{children:h(_.currentUser?`supervisor_sessions_current_user_description`:`supervisor_sessions_description`)})]}),(0,w.jsxs)(`div`,{className:`space-y-3`,"data-testid":`supervisor-managed-sessions`,children:[(0,w.jsx)(k,{controller:_}),m?(0,w.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:h(`supervisor_sessions_open_failed`)}):null,(0,w.jsx)(s,{ref:S,variant:`outline`,size:`sm`,disabled:_.submitting,onClick:()=>{_.cancelReview(),b(!0)},children:h(_.currentUser?`supervisor_scope_current_user_title`:`supervisor_scope_title`)}),_.currentUser?(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`supervisor_sessions_legacy_links`,{count:Object.keys(_.observation?.legacy_links??{}).length})}):_.observation?.scope.allowed_projects.length===0?(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`supervisor_sessions_no_scope`)}):null,_.review?(0,w.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-3`,"data-testid":`managed-session-review`,children:[(0,w.jsx)(`p`,{className:`text-sm`,children:h(_.review.enabled?`supervisor_sessions_review_attach`:`supervisor_sessions_review_detach`,{title:D?.summary?.title||_.review.target_session_id})}),(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:h(`supervisor_sessions_context_preserved`)}),(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[(0,w.jsx)(s,{variant:`outline`,disabled:_.submitting,onClick:_.cancelReview,children:h(`cancel_2cd0f3be`)}),(0,w.jsx)(s,{disabled:!_.canManage,onClick:()=>void _.confirm(),children:h(_.submitting?`supervisor_sessions_saving`:`supervisor_sessions_confirm`)})]})]}):(0,w.jsxs)(w.Fragment,{children:[_.observation&&!_.loading&&!_.rows.length?(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h(_.currentUser?`supervisor_sessions_current_user_empty`:`supervisor_sessions_empty`)}):null,(0,w.jsx)(`ul`,{className:`space-y-2`,children:_.rows.map(e=>(0,w.jsxs)(`li`,{"data-managed-session":e.session_id,className:`flex items-center gap-3 rounded-lg border p-3`,children:[(0,w.jsx)(A,{row:e}),_.currentUser?a?(0,w.jsx)(s,{size:`sm`,variant:`ghost`,disabled:o||_.loading||_.loadingMore||!!_.problem||!_.observation?.owner_authorization.available||_.observation.capabilities.current_user_bound_history_v1!==!0,onClick:()=>{_.observation&&a(e,_.observation,_.navigationGuard())},children:h(`supervisor_sessions_open`)}):null:(0,w.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1`,children:[e.link?.authorized?null:(0,w.jsx)(s,{size:`sm`,variant:`outline`,disabled:!_.canManage||!e.canEnable||_.catalogError,onClick:()=>_.reviewTarget(e.session_id,!0),children:h(e.status===`reconfirm`?`supervisor_sessions_reconfirm_action`:`supervisor_sessions_attach`)}),e.link?.enabled?(0,w.jsx)(s,{size:`sm`,variant:`ghost`,disabled:!_.canManage,onClick:()=>_.reviewTarget(e.session_id,!1),children:h(`supervisor_sessions_detach`)}):null]})]},e.session_id))}),_.nextOffset!==null||_.nextAfter!==null?(0,w.jsx)(s,{ref:v.more,size:`sm`,variant:`outline`,disabled:_.loadingMore||_.loading||_.submitting,onClick:()=>{v.remember(),_.loadMore()},children:h(`supervisor_sessions_more`)}):null]})]}),(0,w.jsxs)(l,{children:[(0,w.jsx)(s,{ref:v.fallback,variant:`outline`,disabled:_.loading||_.submitting,onClick:()=>void _.refresh(),children:h(`supervisor_scope_refresh`)}),(0,w.jsx)(s,{variant:`outline`,disabled:_.submitting,onClick:()=>t(!1),children:h(`supervisor_scope_close`)})]})]})}),y?(0,w.jsx)(g,{open:!0,onOpenChange:e=>{e||(E.current=!0,window.setTimeout(()=>{E.current=!1},0)),b(e),e||_.refresh()},returnFocus:()=>S.current?.focus()}):null]})}function M({active:e,onSelectSession:t,dependencies:n}){let a=r(),o=C(e,n),c=T(o.loadingMore,o.nextAfter??o.nextOffset),[l,u]=(0,x.useState)(!1),[d,f]=(0,x.useState)(null),[p,m]=(0,x.useState)(!1),h=(0,x.useRef)(!1),g=o.rows.filter(e=>!!e.link),_=async(e,n,r)=>{if(h.current)return;let i=e.link?.current_user_target,a=o.navigationGuard(!r),s=()=>a()&&(!r||r());if(!s()||n.management_access&&(!n.owner_authorization.available||!i||n.capabilities.current_user_bound_history_v1!==!0)){m(!0);return}h.current=!0,f(e.session_id),m(!1);try{(i&&n.management_access?await t(e.session_id,{target:i,supervisor:n.scope.supervisor},s):await t(e.session_id))===!1&&m(!0)}catch{m(!0)}finally{h.current=!1,f(null)}};return(0,w.jsxs)(`section`,{className:`rounded-lg border p-3`,"data-testid":`supervisor-managed-panel`,"aria-busy":o.loading,children:[(0,w.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-medium`,children:a(`supervisor_sessions_title`)}),(0,w.jsx)(s,{size:`sm`,variant:`ghost`,disabled:o.loading,"aria-label":a(`supervisor_sessions_refresh`),onClick:()=>void o.refresh(),children:(0,w.jsx)(i,{})})]}),(0,w.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:a(o.currentUser?`supervisor_sessions_current_user_description`:`supervisor_sessions_panel_description`)}),(0,w.jsx)(k,{controller:o}),p?(0,w.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:a(`supervisor_sessions_open_failed`)}):null,o.observation&&!o.loading&&!g.length?(0,w.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:a(o.currentUser?`supervisor_sessions_current_user_empty`:o.observation.scope.allowed_projects.length?`supervisor_sessions_none_attached`:`supervisor_sessions_no_scope`)}):null,(0,w.jsx)(`ul`,{className:`max-h-64 space-y-3 overflow-y-auto`,children:g.map(e=>(0,w.jsxs)(`li`,{className:`flex items-center gap-2`,"data-managed-session":e.session_id,children:[(0,w.jsx)(A,{row:e}),(0,w.jsx)(s,{size:`sm`,variant:`ghost`,disabled:d!==null||o.loading||o.loadingMore||!!o.problem||!o.observation?.owner_authorization.available||!!o.currentUser&&o.observation.capabilities.current_user_bound_history_v1!==!0,onClick:()=>{o.observation&&_(e,o.observation)},children:a(`supervisor_sessions_open`)})]},e.session_id))}),o.currentUser&&o.nextAfter!==null?(0,w.jsx)(s,{ref:c.more,size:`sm`,variant:`outline`,disabled:o.loadingMore||o.loading,onClick:()=>{c.remember(),o.loadMore()},children:a(`supervisor_sessions_more`)}):null,(0,w.jsx)(s,{ref:c.fallback,variant:`outline`,size:`sm`,className:`mt-3`,onClick:()=>u(!0),children:a(o.currentUser?`supervisor_sessions_browse`:`supervisor_sessions_manage`)}),l?(0,w.jsx)(j,{open:!0,dependencies:n,onOpenSession:_,opening:d!==null,openFailed:p,onOpenChange:e=>{u(e),e||o.refresh()},returnFocus:()=>c.fallback.current?.focus()}):null]})}export{j as SupervisorManagedSessionsDialog,M as SupervisorManagedSessionsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i}from"./ui-DQy0lUHc.js";import{c as a}from"./api-dae15_RX.js";import{t as o}from"./button-Cfb4l-V4.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./dialog-CfOua_Le.js";import{a as p,c as m,n as h,o as g,s as _,t as v}from"./client-IKYlOoXY.js";var y=e(t(),1),b=m;function x(e){if(!a(e))return{kind:`unknown`};let{status:t}=e,{code:n}=_(e);return t===401?{kind:`authentication`,code:n}:t===403?{kind:`rejected`,code:n}:t===409&&(n===`scope_revision_conflict`||n===`project_archived`)?{kind:`conflict`,code:n}:t===503&&n&&[`host_owner_authorization_unavailable`,`scope_authority_invalid`,`scope_unavailable`,`project_store_unavailable`].includes(n)?{kind:`unavailable`,code:n}:t===404&&(n===`supervisor_missing`||n===`project_unavailable`)||t===400&&n===`project_scope_invalid`?{kind:`rejected`,code:n}:{kind:`unknown`}}var S=()=>({observation:null,projects:[],draft:null,reading:!0,catalogError:!1,writeBlocked:!1,problem:null,review:null,notice:null,submitting:!1});function C(e,t=b){let[n,r]=(0,y.useState)(S),i=(0,y.useRef)(n);i.current=n;let a=(0,y.useRef)(e);a.current=e;let o=(0,y.useRef)(0),s=(0,y.useRef)(0),c=(0,y.useRef)(null),l=(0,y.useRef)(null),u=(0,y.useCallback)(async e=>{let n=++s.current,i=o.current;c.current?.abort();let l=new AbortController;c.current=l,r(e=>({...e,reading:!0,writeBlocked:!0,review:null,problem:null}));let u=()=>a.current&&o.current===i&&s.current===n,[d,f]=await Promise.allSettled([t.read(l.signal),t.projects()]);return u()?d.status===`rejected`?(r(e=>({...e,observation:null,reading:!1,writeBlocked:!0,review:null,problem:_(d.reason)})),null):(r(t=>({...t,observation:d.value,projects:f.status===`fulfilled`?f.value:[],draft:e&&t.draft!==null?t.draft:[...d.value.scope.allowed_projects],reading:!1,catalogError:f.status===`rejected`,writeBlocked:!1,problem:null,review:null,notice:t.notice?.kind===`unknown`?t.notice:null})),d.value):null},[t]);(0,y.useEffect)(()=>(o.current+=1,l.current=null,e&&(r(S()),u(!1)),()=>{o.current+=1,s.current+=1,c.current?.abort()}),[e,u]);let d=(0,y.useCallback)((e,t)=>{r(n=>{if(!n.observation||n.observation.management_access||n.reading||n.submitting||n.catalogError||!n.draft)return n;let r=n.projects.find(t=>t.id===e);if(t&&(r?.status!==`active`||!n.draft.includes(e)&&n.draft.length>=64)||!t&&!n.draft.includes(e))return n;let i=t?[...new Set([...n.draft,e])].sort():n.draft.filter(t=>t!==e);return{...n,draft:i,review:null,notice:null}})},[]),f=(0,y.useCallback)(()=>{r(e=>{if(!e.observation||e.observation.management_access||e.reading||e.submitting||e.catalogError||e.draft===null)return e;let t=Object.freeze({supervisor:Object.freeze({...e.observation.scope.supervisor}),expected_state_revision:e.observation.scope.state_revision,mutation:Object.freeze({kind:`configure_project_scope`,allowed_projects:Object.freeze([...e.draft])})});return{...e,review:t,notice:null}})},[]),m=(0,y.useCallback)(()=>a.current&&!l.current?u(!0):Promise.resolve(null),[u]),C=(0,y.useCallback)(async()=>{let e=i.current,n=e.review;if(!a.current||l.current||!n||!e.observation||e.reading||e.catalogError||e.writeBlocked||!v(e.observation)||e.draft?.some(t=>e.projects.find(e=>e.id===t)?.status!==`active`)||!g(n.supervisor,e.observation.scope.supervisor)||n.expected_state_revision!==e.observation.scope.state_revision||!p(n.mutation.allowed_projects,e.draft??[]))return;let s={};l.current=s;let c=o.current,d=()=>a.current&&c===o.current&&l.current===s;r(e=>({...e,submitting:!0,notice:null}));try{let e={kind:`unknown`},i=null;try{i=h(await t.update(n),n)}catch(t){e=x(t)}if(!d())return;let a=await u(!0);if(!d())return;i&&a&&!a.management_access&&g(i.supervisor,a.scope.supervisor)&&i.state_revision===a.scope.state_revision&&p(n.mutation.allowed_projects,a.scope.allowed_projects)&&(e={kind:`saved`}),r(t=>({...t,review:null,notice:e,writeBlocked:[`authentication`,`rejected`,`unavailable`].includes(e.kind)}))}finally{d()&&(l.current=null,r(e=>({...e,submitting:!1})))}},[t,u]),w=!!n.draft?.some(e=>n.projects.find(t=>t.id===e)?.status!==`active`),T=!n.writeBlocked&&v(n.observation);return{...n,writeAvailable:T,invalidSelection:w,edit:d,reviewDraft:f,confirm:C,refresh:m,backToEdit:()=>r(e=>({...e,review:null,notice:null})),canEdit:!!n.observation&&!n.observation.management_access&&!n.reading&&!n.submitting&&!n.catalogError,canConfirm:!w&&!!n.review&&!n.reading&&!n.submitting&&!n.catalogError&&T}}var w=n(),T={authentication:`supervisor_scope_access_required`,saved:`supervisor_scope_saved`,conflict:`supervisor_scope_conflict`,rejected:`supervisor_scope_forbidden`,unavailable:`supervisor_scope_unavailable`,unknown:`supervisor_scope_unknown`},E={unsupported:`supervisor_scope_unsupported`,missing:`supervisor_scope_missing`,authentication:`supervisor_scope_access_required`,forbidden:`supervisor_scope_forbidden`,conflict:`supervisor_scope_conflict`,unavailable:`supervisor_scope_storage`,invalid:`supervisor_scope_invalid`,error:`supervisor_scope_error`},D={scope_revision_conflict:`supervisor_scope_conflict`,project_scope_invalid:`supervisor_scope_invalid`,host_owner_authorization_unavailable:`supervisor_scope_unavailable`,host_owner_authorization_required:`supervisor_scope_rejected`,scope_authority_invalid:`supervisor_scope_authority_invalid`,supervisor_identity_mismatch:`supervisor_scope_identity`,supervisor_missing:`supervisor_scope_missing`,project_unavailable:`supervisor_scope_project_unavailable`,project_archived:`supervisor_scope_project_unavailable`,project_store_unavailable:`supervisor_scope_storage`,scope_unavailable:`supervisor_scope_storage`};function O({open:e,onOpenChange:t,dependencies:n,returnFocus:a}){r();let p=C(e,n),m=(0,y.useId)(),h=p.observation?.scope,g=p.observation?.management_access?.kind===`current_user`,_=p.observation?.owner_authorization,v=new Map(p.projects.map(e=>[e.id,e])),b=[...new Set([...v.keys(),...h?.allowed_projects??[],...p.draft??[]])].sort(),x=p.draft?.filter(e=>!h?.allowed_projects.includes(e))??[],S=h?.allowed_projects.filter(e=>!p.draft?.includes(e))??[],O=p.notice&&i(p.notice.code&&D[p.notice.code]||T[p.notice.kind]),k=p.problem&&i(p.problem.code&&D[p.problem.code]||E[p.problem.kind]);return(0,w.jsx)(f,{open:e,onOpenChange:e=>{p.submitting||t(e)},children:(0,w.jsxs)(l,{showCloseButton:!p.submitting,className:`max-h-[90dvh] overflow-y-auto`,onEscapeKeyDown:e=>{p.submitting&&e.preventDefault()},onInteractOutside:e=>{p.submitting&&e.preventDefault()},onCloseAutoFocus:a?e=>{e.preventDefault(),a()}:void 0,children:[(0,w.jsxs)(s,{children:[(0,w.jsx)(u,{children:i(g?`supervisor_scope_current_user_title`:`supervisor_scope_title`)}),(0,w.jsx)(d,{children:i(g?`supervisor_scope_current_user_description`:`supervisor_scope_description`)})]}),(0,w.jsxs)(`div`,{className:`space-y-3 text-sm`,"data-testid":`supervisor-project-scope`,children:[p.reading?(0,w.jsx)(`p`,{role:`status`,children:i(`supervisor_scope_loading`)}):null,k?(0,w.jsx)(`p`,{role:`alert`,children:k}):null,O?(0,w.jsx)(`p`,{role:p.notice?.kind===`saved`?`status`:`alert`,children:O}):null,h?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`p`,{"data-testid":`project-scope-current`,children:i(g?`supervisor_scope_current_user_ready`:h.allowed_projects.length?`supervisor_scope_configured`:`supervisor_scope_empty`,{count:h.allowed_projects.length})}),(0,w.jsxs)(`dl`,{className:`space-y-1 text-xs [overflow-wrap:anywhere]`,children:[(0,w.jsx)(`dt`,{children:i(`supervisor_scope_identity_label`)}),(0,w.jsxs)(`dd`,{children:[h.supervisor.session_id,` · `,h.supervisor.incarnation_id]}),(0,w.jsx)(`dt`,{children:i(`supervisor_scope_revision`)}),(0,w.jsx)(`dd`,{children:h.state_revision})]}),g?(0,w.jsxs)(`section`,{className:`space-y-2`,"data-testid":`current-user-management`,children:[(0,w.jsx)(`p`,{className:`text-muted-foreground`,children:i(`supervisor_scope_current_user_boundaries`)}),(0,w.jsx)(`p`,{children:i(`supervisor_scope_current_user_legacy`,{count:h.allowed_projects.length})}),h.allowed_projects.length?(0,w.jsx)(`ul`,{className:`space-y-1 [overflow-wrap:anywhere]`,children:h.allowed_projects.map(e=>(0,w.jsxs)(`li`,{children:[v.get(e)?.name||e,` `,(0,w.jsx)(`code`,{children:e})]},e))}):null,(0,w.jsx)(`p`,{className:`text-muted-foreground`,children:i(`supervisor_scope_current_user_legacy_note`)})]}):(0,w.jsxs)(w.Fragment,{children:[p.reading?null:(0,w.jsx)(`p`,{role:`status`,children:i(_?.kind===`existing_access`?p.writeAvailable?`supervisor_scope_http_ready`:`supervisor_scope_unavailable`:`supervisor_scope_http_unsupported`)}),(0,w.jsx)(`p`,{className:`text-muted-foreground`,children:i(`supervisor_scope_boundaries`)}),p.catalogError?(0,w.jsx)(`p`,{role:`alert`,children:i(`supervisor_scope_catalog_error`)}):null,p.review?(0,w.jsxs)(`section`,{"data-testid":`project-scope-review`,className:`space-y-2 [overflow-wrap:anywhere]`,children:[(0,w.jsx)(`strong`,{children:i(`supervisor_scope_complete_set`,{count:p.review.mutation.allowed_projects.length})}),p.review.mutation.allowed_projects.length?(0,w.jsx)(`ul`,{className:`space-y-1 [overflow-wrap:anywhere]`,children:p.review.mutation.allowed_projects.map(e=>(0,w.jsxs)(`li`,{children:[v.get(e)?.name||e,` `,(0,w.jsx)(`code`,{children:e})]},e))}):(0,w.jsx)(`p`,{children:i(`supervisor_scope_target_empty`)}),(0,w.jsxs)(`p`,{children:[i(`supervisor_scope_added`),`: `,x.join(`, `)||i(`supervisor_scope_none`)]}),(0,w.jsxs)(`p`,{children:[i(`supervisor_scope_removed`),`: `,S.join(`, `)||i(`supervisor_scope_none`)]}),(0,w.jsx)(`p`,{children:i(`supervisor_scope_removal_effect`)}),(0,w.jsx)(`p`,{children:i(`supervisor_scope_http_review`)})]}):(0,w.jsxs)(`fieldset`,{disabled:!p.canEdit,className:`space-y-2`,children:[(0,w.jsx)(`legend`,{className:`mb-2 font-medium`,children:i(`supervisor_scope_choose`)}),b.length?null:(0,w.jsx)(`p`,{children:i(`supervisor_scope_no_projects`)}),b.map((e,t)=>{let n=v.get(e),r=p.draft?.includes(e)??!1;return(0,w.jsxs)(`label`,{htmlFor:`${m}-${t}`,className:`flex items-start gap-2 [overflow-wrap:anywhere]`,children:[(0,w.jsx)(`input`,{id:`${m}-${t}`,type:`checkbox`,checked:r,disabled:!r&&(n?.status!==`active`||(p.draft?.length??0)>=64),onChange:t=>p.edit(e,t.target.checked)}),(0,w.jsxs)(`span`,{children:[n?.name||e,` `,(0,w.jsx)(`code`,{children:e}),n?.status===`active`?``:` · ${i(`supervisor_scope_project_unavailable`)}`]})]},e)})]}),p.invalidSelection&&!p.catalogError?(0,w.jsx)(`p`,{role:`alert`,children:i(`supervisor_scope_invalid_selection`)}):null,p.review?(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,w.jsx)(o,{variant:`outline`,disabled:p.submitting||p.reading,onClick:p.backToEdit,children:i(`supervisor_scope_edit`)}),(0,w.jsx)(o,{disabled:!p.canConfirm,onClick:()=>void p.confirm(),children:i(p.submitting?`supervisor_scope_http_confirming`:`supervisor_scope_http_confirm`)})]}):(0,w.jsx)(o,{variant:`outline`,disabled:!p.canEdit,onClick:p.reviewDraft,children:i(`supervisor_scope_preview`)})]})]}):null]}),(0,w.jsxs)(c,{children:[(0,w.jsx)(o,{variant:`outline`,disabled:p.reading||p.submitting,onClick:()=>void p.refresh(),children:i(`supervisor_scope_refresh`)}),(0,w.jsx)(o,{variant:`outline`,disabled:p.submitting,onClick:()=>t(!1),children:i(`supervisor_scope_close`)})]})]})})}export{O as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i}from"./ui-OvgR8HKW.js";import{c as a}from"./api-CPcpMjoM.js";import{t as o}from"./button-Cfb4l-V4.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./dialog-CfOua_Le.js";import{a as p,c as m,n as h,o as g,s as _,t as v}from"./client-Cxjm7aQO.js";var y=e(t(),1),b=m;function x(e){if(!a(e))return{kind:`unknown`};let{status:t}=e,{code:n}=_(e);return t===401?{kind:`authentication`,code:n}:t===403?{kind:`rejected`,code:n}:t===409&&(n===`scope_revision_conflict`||n===`project_archived`)?{kind:`conflict`,code:n}:t===503&&n&&[`host_owner_authorization_unavailable`,`scope_authority_invalid`,`scope_unavailable`,`project_store_unavailable`].includes(n)?{kind:`unavailable`,code:n}:t===404&&(n===`supervisor_missing`||n===`project_unavailable`)||t===400&&n===`project_scope_invalid`?{kind:`rejected`,code:n}:{kind:`unknown`}}var S=()=>({observation:null,projects:[],draft:null,reading:!0,catalogError:!1,writeBlocked:!1,problem:null,review:null,notice:null,submitting:!1});function C(e,t=b){let[n,r]=(0,y.useState)(S),i=(0,y.useRef)(n);i.current=n;let a=(0,y.useRef)(e);a.current=e;let o=(0,y.useRef)(0),s=(0,y.useRef)(0),c=(0,y.useRef)(null),l=(0,y.useRef)(null),u=(0,y.useCallback)(async e=>{let n=++s.current,i=o.current;c.current?.abort();let l=new AbortController;c.current=l,r(e=>({...e,reading:!0,writeBlocked:!0,review:null,problem:null}));let u=()=>a.current&&o.current===i&&s.current===n,[d,f]=await Promise.allSettled([t.read(l.signal),t.projects()]);return u()?d.status===`rejected`?(r(e=>({...e,observation:null,reading:!1,writeBlocked:!0,review:null,problem:_(d.reason)})),null):(r(t=>({...t,observation:d.value,projects:f.status===`fulfilled`?f.value:[],draft:e&&t.draft!==null?t.draft:[...d.value.scope.allowed_projects],reading:!1,catalogError:f.status===`rejected`,writeBlocked:!1,problem:null,review:null,notice:t.notice?.kind===`unknown`?t.notice:null})),d.value):null},[t]);(0,y.useEffect)(()=>(o.current+=1,l.current=null,e&&(r(S()),u(!1)),()=>{o.current+=1,s.current+=1,c.current?.abort()}),[e,u]);let d=(0,y.useCallback)((e,t)=>{r(n=>{if(!n.observation||n.observation.management_access||n.reading||n.submitting||n.catalogError||!n.draft)return n;let r=n.projects.find(t=>t.id===e);if(t&&(r?.status!==`active`||!n.draft.includes(e)&&n.draft.length>=64)||!t&&!n.draft.includes(e))return n;let i=t?[...new Set([...n.draft,e])].sort():n.draft.filter(t=>t!==e);return{...n,draft:i,review:null,notice:null}})},[]),f=(0,y.useCallback)(()=>{r(e=>{if(!e.observation||e.observation.management_access||e.reading||e.submitting||e.catalogError||e.draft===null)return e;let t=Object.freeze({supervisor:Object.freeze({...e.observation.scope.supervisor}),expected_state_revision:e.observation.scope.state_revision,mutation:Object.freeze({kind:`configure_project_scope`,allowed_projects:Object.freeze([...e.draft])})});return{...e,review:t,notice:null}})},[]),m=(0,y.useCallback)(()=>a.current&&!l.current?u(!0):Promise.resolve(null),[u]),C=(0,y.useCallback)(async()=>{let e=i.current,n=e.review;if(!a.current||l.current||!n||!e.observation||e.reading||e.catalogError||e.writeBlocked||!v(e.observation)||e.draft?.some(t=>e.projects.find(e=>e.id===t)?.status!==`active`)||!g(n.supervisor,e.observation.scope.supervisor)||n.expected_state_revision!==e.observation.scope.state_revision||!p(n.mutation.allowed_projects,e.draft??[]))return;let s={};l.current=s;let c=o.current,d=()=>a.current&&c===o.current&&l.current===s;r(e=>({...e,submitting:!0,notice:null}));try{let e={kind:`unknown`},i=null;try{i=h(await t.update(n),n)}catch(t){e=x(t)}if(!d())return;let a=await u(!0);if(!d())return;i&&a&&!a.management_access&&g(i.supervisor,a.scope.supervisor)&&i.state_revision===a.scope.state_revision&&p(n.mutation.allowed_projects,a.scope.allowed_projects)&&(e={kind:`saved`}),r(t=>({...t,review:null,notice:e,writeBlocked:[`authentication`,`rejected`,`unavailable`].includes(e.kind)}))}finally{d()&&(l.current=null,r(e=>({...e,submitting:!1})))}},[t,u]),w=!!n.draft?.some(e=>n.projects.find(t=>t.id===e)?.status!==`active`),T=!n.writeBlocked&&v(n.observation);return{...n,writeAvailable:T,invalidSelection:w,edit:d,reviewDraft:f,confirm:C,refresh:m,backToEdit:()=>r(e=>({...e,review:null,notice:null})),canEdit:!!n.observation&&!n.observation.management_access&&!n.reading&&!n.submitting&&!n.catalogError,canConfirm:!w&&!!n.review&&!n.reading&&!n.submitting&&!n.catalogError&&T}}var w=n(),T={authentication:`supervisor_scope_access_required`,saved:`supervisor_scope_saved`,conflict:`supervisor_scope_conflict`,rejected:`supervisor_scope_forbidden`,unavailable:`supervisor_scope_unavailable`,unknown:`supervisor_scope_unknown`},E={unsupported:`supervisor_scope_unsupported`,missing:`supervisor_scope_missing`,authentication:`supervisor_scope_access_required`,forbidden:`supervisor_scope_forbidden`,conflict:`supervisor_scope_conflict`,unavailable:`supervisor_scope_storage`,invalid:`supervisor_scope_invalid`,error:`supervisor_scope_error`},D={scope_revision_conflict:`supervisor_scope_conflict`,project_scope_invalid:`supervisor_scope_invalid`,host_owner_authorization_unavailable:`supervisor_scope_unavailable`,host_owner_authorization_required:`supervisor_scope_rejected`,scope_authority_invalid:`supervisor_scope_authority_invalid`,supervisor_identity_mismatch:`supervisor_scope_identity`,supervisor_missing:`supervisor_scope_missing`,project_unavailable:`supervisor_scope_project_unavailable`,project_archived:`supervisor_scope_project_unavailable`,project_store_unavailable:`supervisor_scope_storage`,scope_unavailable:`supervisor_scope_storage`};function O({open:e,onOpenChange:t,dependencies:n,returnFocus:a}){r();let p=C(e,n),m=(0,y.useId)(),h=p.observation?.scope,g=p.observation?.management_access?.kind===`current_user`,_=p.observation?.owner_authorization,v=new Map(p.projects.map(e=>[e.id,e])),b=[...new Set([...v.keys(),...h?.allowed_projects??[],...p.draft??[]])].sort(),x=p.draft?.filter(e=>!h?.allowed_projects.includes(e))??[],S=h?.allowed_projects.filter(e=>!p.draft?.includes(e))??[],O=p.notice&&i(p.notice.code&&D[p.notice.code]||T[p.notice.kind]),k=p.problem&&i(p.problem.code&&D[p.problem.code]||E[p.problem.kind]);return(0,w.jsx)(f,{open:e,onOpenChange:e=>{p.submitting||t(e)},children:(0,w.jsxs)(l,{showCloseButton:!p.submitting,className:`max-h-[90dvh] overflow-y-auto`,onEscapeKeyDown:e=>{p.submitting&&e.preventDefault()},onInteractOutside:e=>{p.submitting&&e.preventDefault()},onCloseAutoFocus:a?e=>{e.preventDefault(),a()}:void 0,children:[(0,w.jsxs)(s,{children:[(0,w.jsx)(u,{children:i(g?`supervisor_scope_current_user_title`:`supervisor_scope_title`)}),(0,w.jsx)(d,{children:i(g?`supervisor_scope_current_user_description`:`supervisor_scope_description`)})]}),(0,w.jsxs)(`div`,{className:`space-y-3 text-sm`,"data-testid":`supervisor-project-scope`,children:[p.reading?(0,w.jsx)(`p`,{role:`status`,children:i(`supervisor_scope_loading`)}):null,k?(0,w.jsx)(`p`,{role:`alert`,children:k}):null,O?(0,w.jsx)(`p`,{role:p.notice?.kind===`saved`?`status`:`alert`,children:O}):null,h?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`p`,{"data-testid":`project-scope-current`,children:i(g?`supervisor_scope_current_user_ready`:h.allowed_projects.length?`supervisor_scope_configured`:`supervisor_scope_empty`,{count:h.allowed_projects.length})}),(0,w.jsxs)(`dl`,{className:`space-y-1 text-xs [overflow-wrap:anywhere]`,children:[(0,w.jsx)(`dt`,{children:i(`supervisor_scope_identity_label`)}),(0,w.jsxs)(`dd`,{children:[h.supervisor.session_id,` · `,h.supervisor.incarnation_id]}),(0,w.jsx)(`dt`,{children:i(`supervisor_scope_revision`)}),(0,w.jsx)(`dd`,{children:h.state_revision})]}),g?(0,w.jsxs)(`section`,{className:`space-y-2`,"data-testid":`current-user-management`,children:[(0,w.jsx)(`p`,{className:`text-muted-foreground`,children:i(`supervisor_scope_current_user_boundaries`)}),(0,w.jsx)(`p`,{children:i(`supervisor_scope_current_user_legacy`,{count:h.allowed_projects.length})}),h.allowed_projects.length?(0,w.jsx)(`ul`,{className:`space-y-1 [overflow-wrap:anywhere]`,children:h.allowed_projects.map(e=>(0,w.jsxs)(`li`,{children:[v.get(e)?.name||e,` `,(0,w.jsx)(`code`,{children:e})]},e))}):null,(0,w.jsx)(`p`,{className:`text-muted-foreground`,children:i(`supervisor_scope_current_user_legacy_note`)})]}):(0,w.jsxs)(w.Fragment,{children:[p.reading?null:(0,w.jsx)(`p`,{role:`status`,children:i(_?.kind===`existing_access`?p.writeAvailable?`supervisor_scope_http_ready`:`supervisor_scope_unavailable`:`supervisor_scope_http_unsupported`)}),(0,w.jsx)(`p`,{className:`text-muted-foreground`,children:i(`supervisor_scope_boundaries`)}),p.catalogError?(0,w.jsx)(`p`,{role:`alert`,children:i(`supervisor_scope_catalog_error`)}):null,p.review?(0,w.jsxs)(`section`,{"data-testid":`project-scope-review`,className:`space-y-2 [overflow-wrap:anywhere]`,children:[(0,w.jsx)(`strong`,{children:i(`supervisor_scope_complete_set`,{count:p.review.mutation.allowed_projects.length})}),p.review.mutation.allowed_projects.length?(0,w.jsx)(`ul`,{className:`space-y-1 [overflow-wrap:anywhere]`,children:p.review.mutation.allowed_projects.map(e=>(0,w.jsxs)(`li`,{children:[v.get(e)?.name||e,` `,(0,w.jsx)(`code`,{children:e})]},e))}):(0,w.jsx)(`p`,{children:i(`supervisor_scope_target_empty`)}),(0,w.jsxs)(`p`,{children:[i(`supervisor_scope_added`),`: `,x.join(`, `)||i(`supervisor_scope_none`)]}),(0,w.jsxs)(`p`,{children:[i(`supervisor_scope_removed`),`: `,S.join(`, `)||i(`supervisor_scope_none`)]}),(0,w.jsx)(`p`,{children:i(`supervisor_scope_removal_effect`)}),(0,w.jsx)(`p`,{children:i(`supervisor_scope_http_review`)})]}):(0,w.jsxs)(`fieldset`,{disabled:!p.canEdit,className:`space-y-2`,children:[(0,w.jsx)(`legend`,{className:`mb-2 font-medium`,children:i(`supervisor_scope_choose`)}),b.length?null:(0,w.jsx)(`p`,{children:i(`supervisor_scope_no_projects`)}),b.map((e,t)=>{let n=v.get(e),r=p.draft?.includes(e)??!1;return(0,w.jsxs)(`label`,{htmlFor:`${m}-${t}`,className:`flex items-start gap-2 [overflow-wrap:anywhere]`,children:[(0,w.jsx)(`input`,{id:`${m}-${t}`,type:`checkbox`,checked:r,disabled:!r&&(n?.status!==`active`||(p.draft?.length??0)>=64),onChange:t=>p.edit(e,t.target.checked)}),(0,w.jsxs)(`span`,{children:[n?.name||e,` `,(0,w.jsx)(`code`,{children:e}),n?.status===`active`?``:` · ${i(`supervisor_scope_project_unavailable`)}`]})]},e)})]}),p.invalidSelection&&!p.catalogError?(0,w.jsx)(`p`,{role:`alert`,children:i(`supervisor_scope_invalid_selection`)}):null,p.review?(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,w.jsx)(o,{variant:`outline`,disabled:p.submitting||p.reading,onClick:p.backToEdit,children:i(`supervisor_scope_edit`)}),(0,w.jsx)(o,{disabled:!p.canConfirm,onClick:()=>void p.confirm(),children:i(p.submitting?`supervisor_scope_http_confirming`:`supervisor_scope_http_confirm`)})]}):(0,w.jsx)(o,{variant:`outline`,disabled:!p.canEdit,onClick:p.reviewDraft,children:i(`supervisor_scope_preview`)})]})]}):null]}),(0,w.jsxs)(c,{children:[(0,w.jsx)(o,{variant:`outline`,disabled:p.reading||p.submitting,onClick:()=>void p.refresh(),children:i(`supervisor_scope_refresh`)}),(0,w.jsx)(o,{variant:`outline`,disabled:p.submitting,onClick:()=>t(!1),children:i(`supervisor_scope_close`)})]})]})})}export{O as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i,t as a}from"./ui-DQy0lUHc.js";import{i as o,n as s}from"./state-BgzWNmJm.js";import{t as c}from"./ticketWorkLabels-tosshWRq.js";var l=e(t(),1);function u(e,t,n){let r={"text/plain":`txt`,"text/markdown":`md`,"text/csv":`csv`,"application/json":`json`,"application/pdf":`pdf`,"application/zip":`zip`,"application/gzip":`gz`,"image/png":`png`,"image/jpeg":`jpg`,"image/gif":`gif`,"image/webp":`webp`,"image/svg+xml":`svg`,"image/avif":`avif`,"audio/mpeg":`mp3`,"video/mp4":`mp4`}[n.split(`;`)[0].trim().toLowerCase()]??t.split(/[?#]/,1)[0].match(/\.([a-z0-9]{1,16})$/i)?.[1].toLowerCase();return`work-result-`+e.slice(0,8)+(r?`.`+r:``)}var d=n(),f={get open(){return i(`ticket_pending_999a459c`)},get answered(){return i(`ticket_answered_474c9878`)},get approved(){return i(`ticket_approved_b42cb548`)},get denied(){return i(`ticket_denied_f098218a`)},get superseded(){return i(`ticket_superseded_30474a79`)},get expired(){return i(`ticket_expired_2fe0e333`)},get consumed(){return i(`ticket_authorization_used_c8eb44e4`)}};function p({controller:e,state:t,request:n}){r();let[o,c]=(0,l.useState)(``),u=s(t,n),p=t.works[n.work_id]?.ticket.contract.title??i(`supervisor_work_tab`),m=e.uncertain[n.id],h=e.busy[n.id]===!0,g=!e.canRespond||h||u!==`open`||!!m,_=n.kind.kind===`approval`?n.kind:null;return(0,d.jsxs)(`article`,{"data-testid":`ticket-request-`+n.id,className:`rounded-xl border bg-background p-3 text-sm`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,d.jsx)(`strong`,{children:p}),(0,d.jsx)(`span`,{children:f[u]})]}),(0,d.jsx)(`div`,{className:`mb-2 text-xs text-muted-foreground`,children:i(`ticket_request_metadata`,{kind:i(_?`approve_8cbe697b`:`ticket_question_33a8618c`),generation:n.generation,revision:n.prompt_revision})}),(0,d.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:n.prompt}),_?(0,d.jsxs)(`dl`,{className:`my-2 grid grid-cols-2 gap-2 text-xs`,children:[(0,d.jsx)(`dt`,{children:i(`ticket_action_be37d841`)}),(0,d.jsxs)(`dd`,{children:[_.action.kind,` → `,_.action.target]}),_.action.amount?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`dt`,{children:i(`ticket_amount_ffc62430`)}),(0,d.jsx)(`dd`,{children:_.action.amount})]}):null,(0,d.jsx)(`dt`,{children:i(`permission_978cbca6`)}),(0,d.jsx)(`dd`,{children:new Intl.ListFormat(a()).format(_.action.permissions)||i(`ticket_no_additional_permissions_25c9693a`)}),(0,d.jsx)(`dt`,{children:i(`ticket_risk_af75e78c`)}),(0,d.jsx)(`dd`,{children:_.action.risk})]}):null,_?(0,d.jsxs)(`details`,{className:`my-2 text-xs text-muted-foreground`,children:[(0,d.jsx)(`summary`,{className:`cursor-pointer`,children:i(`supervisor_work_submission_diagnostics`)}),(0,d.jsxs)(`dl`,{className:`mt-1`,children:[(0,d.jsx)(`dt`,{children:i(`ticket_data_5440f742`)}),(0,d.jsx)(`dd`,{className:`break-all font-mono`,children:_.action.data_hash})]})]}):null,u===`open`&&!_?(0,d.jsxs)(`form`,{className:`mt-2 flex gap-2`,onSubmit:t=>{t.preventDefault(),!(!o.trim()||g)&&e.respond(n,{kind:`question`,answer:o.trim()}).then(e=>{e&&c(``)})},children:[(0,d.jsx)(`input`,{"aria-label":i(`ticket_answer_label`,{title:p}),value:o,onChange:e=>c(e.target.value),disabled:g,className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1`}),(0,d.jsx)(`button`,{type:`submit`,disabled:g||!o.trim(),className:`rounded-md border px-2 py-1 disabled:opacity-50`,children:i(h?`sending_364970d8`:`ticket_answer_f3f51264`)})]}):null,u===`open`&&_?(0,d.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,disabled:g,className:`rounded-md border px-2 py-1 disabled:opacity-50`,onClick:()=>void e.respond(n,{kind:`approval`,fingerprint:_.fingerprint,approve:!0}),children:i(`ticket_approve_this_action_5615724b`)}),(0,d.jsx)(`button`,{type:`button`,disabled:g,className:`rounded-md border px-2 py-1 disabled:opacity-50`,onClick:()=>void e.respond(n,{kind:`approval`,fingerprint:_.fingerprint,approve:!1}),children:i(`deny_136de7a8`)})]}):null,m?(0,d.jsxs)(`div`,{className:`mt-2 text-muted-foreground`,children:[(0,d.jsx)(`p`,{children:i(`ticket_the_previous_send_is_not_confirmed__e67f22cb`)}),(0,d.jsx)(`button`,{type:`button`,disabled:!e.connected||h,className:`underline disabled:opacity-50`,onClick:()=>void e.respond(n,m.decision),children:i(`ticket_confirm_the_outcome_of_this_request_26ab1d31`)})]}):null,n.answer?(0,d.jsxs)(`p`,{className:`mt-2 whitespace-pre-wrap text-muted-foreground`,children:[i(`ticket_saved__cfe6f505`),n.answer]}):null]})}var m={planned:`work_execution_planned`,dispatch_pending:`work_execution_dispatch_pending`,admitted:`work_execution_admitted`,running:`running_1f0eb99b`,submitted:`work_execution_submitted`,blocked:`ticket_blocked_9059acb4`,failed:`failed_28384d7a`,cancelling:`work_execution_cancelling`,cancelled:`cancelled_a37778f1`,outcome_unknown:`work_execution_unknown`};function h({view:e}){let t=e.ticket,n=e=>e.work_id===t.id&&e.generation===t.generation&&e.contract_revision===t.contract_revision,r=e.submissions.find(e=>!e.stale&&n(e)&&e.id===(t.accepted_submission??t.current_submission)),a=t.active_assignment??r?.assignment_id,o=e.sections?.includes(`assignments`)===!0&&Array.isArray(e.assignments),s=o?e.assignments?.find(e=>e.id===a&&n(e)):void 0,c=typeof s?.runtime?.session_id==`string`?s.runtime.session_id.trim():``;return(0,d.jsxs)(`dl`,{className:`my-2 text-xs text-muted-foreground`,children:[(0,d.jsx)(`dt`,{children:i(`work_execution_session`)}),(0,d.jsx)(`dd`,{className:`break-all`,children:c||i(o&&!a?`work_execution_none`:`work_execution_unconfirmed`)}),s?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`dt`,{children:i(`work_execution_record`)}),(0,d.jsx)(`dd`,{children:i(Object.hasOwn(m,s.state)?m[s.state]:`work_execution_unknown`)})]}):null,s?.process_stopped===!0?(0,d.jsx)(`dd`,{children:i(`work_execution_stopped`)}):null]})}function g({controller:e,onReference:t,selectedWorkId:n,onShowAll:a,onReady:f}){r();let m=e.state,g=(0,l.useRef)(f);g.current=f;let _=!!m;(0,l.useEffect)(()=>{_&&g.current?.()},[_]);let[v,y]=(0,l.useState)(null);if(!m)return null;let b=n&&!m.works[n]?.ticket.archived?m.works[n]?.ticket:void 0,x=m.current.scope.overview.data,S=Object.values(m.requests).filter(e=>s(m,e)===`open`),C=Object.values(m.works).filter(e=>!e.ticket.archived),w=Object.values(m.requests).filter(e=>s(m,e)!==`open`);return(0,d.jsxs)(`section`,{"aria-label":i(`ticket_work_overview_223a6f34`),"data-testid":`ticket-work-overview`,tabIndex:-1,className:`p-4 outline-none`,children:[b&&a?(0,d.jsx)(`button`,{type:`button`,onClick:a,className:`mb-3 text-xs text-muted-foreground underline`,children:i(`supervisor_work_back`)}):null,(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,d.jsx)(`strong`,{children:i(`ticket_work_overview_223a6f34`)}),(0,d.jsx)(`button`,{type:`button`,className:`text-xs underline`,disabled:e.refreshing,onClick:()=>void e.refresh(),children:i(`refresh_aee88743`)})]}),(0,d.jsxs)(`p`,{className:`my-2 text-xs text-muted-foreground`,children:[i(`ticket_work_count`,{count:x.work_count}),` · `,i(`ticket_question_count`,{count:x.open_questions}),` · `,i(`ticket_approval_count`,{count:x.open_approvals}),` · `,i(`ticket_acceptance_count`,{count:x.needs_acceptance})]}),(0,d.jsx)(`p`,{className:`my-2 text-xs text-muted-foreground`,children:i(`supervisor_work_management_scope`)}),m.current.complete?null:(0,d.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(`ticket_only_some_work_is_shown_other_work_may_still__ee267ea7`)}),e.connected?null:(0,d.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(`ticket_the_connection_is_not_confirmed_answers_and_a_aaac8c0d`)}),m.current.scope.mutation_enabled?null:(0,d.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(`supervisor_work_mutation_disabled`)}),m.current.scope.health===`writable`?null:(0,d.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(m.current.scope.health===`read_only`?`supervisor_work_storage_read_only`:`supervisor_work_storage_unconfirmed`)}),m.current.scope.dispatch_enabled?null:(0,d.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(`supervisor_work_dispatch_disabled`)}),m.current.complete&&e.connected&&x.ticket_count===0&&C.length===0?(0,d.jsx)(`p`,{role:`status`,className:`my-2 text-sm text-muted-foreground`,children:i(`supervisor_work_empty`)}):null,e.error?(0,d.jsx)(`p`,{role:`alert`,className:`my-2 text-sm text-destructive`,children:e.error}):null,(0,d.jsx)(`div`,{className:`grid gap-3`,children:C.map(e=>(0,d.jsxs)(`section`,{hidden:!!b&&b.id!==e.ticket.id,className:`rounded-xl border bg-background p-3 text-sm`,children:[(0,d.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,d.jsx)(`strong`,{className:`min-w-0 break-words`,children:e.ticket.contract.title}),(0,d.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:c[e.ticket.state]})]}),(0,d.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.ticket.contract.objective}),(0,d.jsx)(h,{view:e}),e.ticket.blocked?(0,d.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:e.ticket.blocked.reason}):null,e.submissions.filter(t=>t.id===e.ticket.accepted_submission||t.id===e.ticket.current_submission).map(t=>(0,d.jsxs)(`div`,{className:`mt-2`,children:[(0,d.jsx)(`p`,{children:t.stale?i(`ticket_previous_submission_for_reference_only_8540a39f`):t.id===e.ticket.accepted_submission?i(`ticket_accepted_submission_a269d4af`):i(`ticket_submitted_awaiting_acceptance_14447588`)}),(0,d.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`supervisor_work_result_count`,{count:t.artifacts.length})}),t.artifacts.map((e,t)=>(0,d.jsx)(`button`,{type:`button`,style:{marginRight:`0.5rem`},className:`underline`,onClick:()=>{o.artifact(e.sha256).then(t=>{let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=u(e.sha256,e.uri,t.type),r.click(),URL.revokeObjectURL(n)}).catch(()=>y(i(`ticket_the_artifact_could_not_be_read_refresh_and_tr_d3969eb3`)))},children:i(`ticket_artifact_label`,{number:t+1})},e.sha256)),(0,d.jsxs)(`details`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,d.jsx)(`summary`,{className:`cursor-pointer`,children:i(`supervisor_work_submission_diagnostics`)}),(0,d.jsx)(`p`,{className:`mt-1 break-all font-mono`,children:t.id}),t.evidence.map((e,t)=>(0,d.jsx)(`p`,{className:`break-words`,children:e},t))]})]},t.id)),(0,d.jsxs)(`details`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,d.jsx)(`summary`,{className:`cursor-pointer`,children:i(`supervisor_work_diagnostics`)}),(0,d.jsx)(`p`,{className:`mt-1 break-all font-mono`,children:e.ticket.id})]})]},e.ticket.id))}),v?(0,d.jsx)(`p`,{role:`alert`,children:v}):null,S.length?(0,d.jsx)(`div`,{className:`mt-3 grid gap-3`,children:S.map(n=>(0,d.jsxs)(`div`,{hidden:!!b&&b.id!==n.work_id,children:[(0,d.jsx)(p,{controller:e,state:m,request:n}),t?(0,d.jsx)(`button`,{type:`button`,className:`mt-1 text-xs underline`,onClick:()=>t(n),children:i(`ticket_reference_this_request_in_the_message_box_b3e84d5b`)}):null]},n.id))}):null,w.length?(0,d.jsxs)(`details`,{className:`mt-3`,children:[(0,d.jsx)(`summary`,{className:`cursor-pointer text-xs`,children:i(`ticket_history_label`,{count:w.length})}),(0,d.jsx)(`div`,{className:`mt-2 grid gap-3`,children:w.map(t=>(0,d.jsx)(`div`,{hidden:!!b&&b.id!==t.work_id,children:(0,d.jsx)(p,{controller:e,state:m,request:t})},t.id))})]}):null]})}export{g as TicketWorkPanel};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i,t as a}from"./ui-OvgR8HKW.js";import{i as o,n as s}from"./state-BjHHK7Ni.js";import{t as c}from"./ticketWorkLabels-BNVpjOJX.js";var l=e(t(),1);function u(e,t,n){let r={"text/plain":`txt`,"text/markdown":`md`,"text/csv":`csv`,"application/json":`json`,"application/pdf":`pdf`,"application/zip":`zip`,"application/gzip":`gz`,"image/png":`png`,"image/jpeg":`jpg`,"image/gif":`gif`,"image/webp":`webp`,"image/svg+xml":`svg`,"image/avif":`avif`,"audio/mpeg":`mp3`,"video/mp4":`mp4`}[n.split(`;`)[0].trim().toLowerCase()]??t.split(/[?#]/,1)[0].match(/\.([a-z0-9]{1,16})$/i)?.[1].toLowerCase();return`work-result-`+e.slice(0,8)+(r?`.`+r:``)}var d=n(),f={get open(){return i(`ticket_pending_999a459c`)},get answered(){return i(`ticket_answered_474c9878`)},get approved(){return i(`ticket_approved_b42cb548`)},get denied(){return i(`ticket_denied_f098218a`)},get superseded(){return i(`ticket_superseded_30474a79`)},get expired(){return i(`ticket_expired_2fe0e333`)},get consumed(){return i(`ticket_authorization_used_c8eb44e4`)}};function p({controller:e,state:t,request:n}){r();let[o,c]=(0,l.useState)(``),u=s(t,n),p=t.works[n.work_id]?.ticket.contract.title??i(`supervisor_work_tab`),m=e.uncertain[n.id],h=e.busy[n.id]===!0,g=!e.canRespond||h||u!==`open`||!!m,_=n.kind.kind===`approval`?n.kind:null;return(0,d.jsxs)(`article`,{"data-testid":`ticket-request-`+n.id,className:`rounded-xl border bg-background p-3 text-sm`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,d.jsx)(`strong`,{children:p}),(0,d.jsx)(`span`,{children:f[u]})]}),(0,d.jsx)(`div`,{className:`mb-2 text-xs text-muted-foreground`,children:i(`ticket_request_metadata`,{kind:i(_?`approve_8cbe697b`:`ticket_question_33a8618c`),generation:n.generation,revision:n.prompt_revision})}),(0,d.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:n.prompt}),_?(0,d.jsxs)(`dl`,{className:`my-2 grid grid-cols-2 gap-2 text-xs`,children:[(0,d.jsx)(`dt`,{children:i(`ticket_action_be37d841`)}),(0,d.jsxs)(`dd`,{children:[_.action.kind,` → `,_.action.target]}),_.action.amount?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`dt`,{children:i(`ticket_amount_ffc62430`)}),(0,d.jsx)(`dd`,{children:_.action.amount})]}):null,(0,d.jsx)(`dt`,{children:i(`permission_978cbca6`)}),(0,d.jsx)(`dd`,{children:new Intl.ListFormat(a()).format(_.action.permissions)||i(`ticket_no_additional_permissions_25c9693a`)}),(0,d.jsx)(`dt`,{children:i(`ticket_risk_af75e78c`)}),(0,d.jsx)(`dd`,{children:_.action.risk})]}):null,_?(0,d.jsxs)(`details`,{className:`my-2 text-xs text-muted-foreground`,children:[(0,d.jsx)(`summary`,{className:`cursor-pointer`,children:i(`supervisor_work_submission_diagnostics`)}),(0,d.jsxs)(`dl`,{className:`mt-1`,children:[(0,d.jsx)(`dt`,{children:i(`ticket_data_5440f742`)}),(0,d.jsx)(`dd`,{className:`break-all font-mono`,children:_.action.data_hash})]})]}):null,u===`open`&&!_?(0,d.jsxs)(`form`,{className:`mt-2 flex gap-2`,onSubmit:t=>{t.preventDefault(),!(!o.trim()||g)&&e.respond(n,{kind:`question`,answer:o.trim()}).then(e=>{e&&c(``)})},children:[(0,d.jsx)(`input`,{"aria-label":i(`ticket_answer_label`,{title:p}),value:o,onChange:e=>c(e.target.value),disabled:g,className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1`}),(0,d.jsx)(`button`,{type:`submit`,disabled:g||!o.trim(),className:`rounded-md border px-2 py-1 disabled:opacity-50`,children:i(h?`sending_364970d8`:`ticket_answer_f3f51264`)})]}):null,u===`open`&&_?(0,d.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,disabled:g,className:`rounded-md border px-2 py-1 disabled:opacity-50`,onClick:()=>void e.respond(n,{kind:`approval`,fingerprint:_.fingerprint,approve:!0}),children:i(`ticket_approve_this_action_5615724b`)}),(0,d.jsx)(`button`,{type:`button`,disabled:g,className:`rounded-md border px-2 py-1 disabled:opacity-50`,onClick:()=>void e.respond(n,{kind:`approval`,fingerprint:_.fingerprint,approve:!1}),children:i(`deny_136de7a8`)})]}):null,m?(0,d.jsxs)(`div`,{className:`mt-2 text-muted-foreground`,children:[(0,d.jsx)(`p`,{children:i(`ticket_the_previous_send_is_not_confirmed__e67f22cb`)}),(0,d.jsx)(`button`,{type:`button`,disabled:!e.connected||h,className:`underline disabled:opacity-50`,onClick:()=>void e.respond(n,m.decision),children:i(`ticket_confirm_the_outcome_of_this_request_26ab1d31`)})]}):null,n.answer?(0,d.jsxs)(`p`,{className:`mt-2 whitespace-pre-wrap text-muted-foreground`,children:[i(`ticket_saved__cfe6f505`),n.answer]}):null]})}var m={planned:`work_execution_planned`,dispatch_pending:`work_execution_dispatch_pending`,admitted:`work_execution_admitted`,running:`running_1f0eb99b`,submitted:`work_execution_submitted`,blocked:`ticket_blocked_9059acb4`,failed:`failed_28384d7a`,cancelling:`work_execution_cancelling`,cancelled:`cancelled_a37778f1`,outcome_unknown:`work_execution_unknown`};function h({view:e}){let t=e.ticket,n=e=>e.work_id===t.id&&e.generation===t.generation&&e.contract_revision===t.contract_revision,r=e.submissions.find(e=>!e.stale&&n(e)&&e.id===(t.accepted_submission??t.current_submission)),a=t.active_assignment??r?.assignment_id,o=e.sections?.includes(`assignments`)===!0&&Array.isArray(e.assignments),s=o?e.assignments?.find(e=>e.id===a&&n(e)):void 0,c=typeof s?.runtime?.session_id==`string`?s.runtime.session_id.trim():``;return(0,d.jsxs)(`dl`,{className:`my-2 text-xs text-muted-foreground`,children:[(0,d.jsx)(`dt`,{children:i(`work_execution_session`)}),(0,d.jsx)(`dd`,{className:`break-all`,children:c||i(o&&!a?`work_execution_none`:`work_execution_unconfirmed`)}),s?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`dt`,{children:i(`work_execution_record`)}),(0,d.jsx)(`dd`,{children:i(Object.hasOwn(m,s.state)?m[s.state]:`work_execution_unknown`)})]}):null,s?.process_stopped===!0?(0,d.jsx)(`dd`,{children:i(`work_execution_stopped`)}):null]})}function g({controller:e,onReference:t,selectedWorkId:n,onShowAll:a,onReady:f}){r();let m=e.state,g=(0,l.useRef)(f);g.current=f;let _=!!m;(0,l.useEffect)(()=>{_&&g.current?.()},[_]);let[v,y]=(0,l.useState)(null);if(!m)return null;let b=n&&!m.works[n]?.ticket.archived?m.works[n]?.ticket:void 0,x=m.current.scope.overview.data,S=Object.values(m.requests).filter(e=>s(m,e)===`open`),C=Object.values(m.works).filter(e=>!e.ticket.archived),w=Object.values(m.requests).filter(e=>s(m,e)!==`open`);return(0,d.jsxs)(`section`,{"aria-label":i(`ticket_work_overview_223a6f34`),"data-testid":`ticket-work-overview`,tabIndex:-1,className:`p-4 outline-none`,children:[b&&a?(0,d.jsx)(`button`,{type:`button`,onClick:a,className:`mb-3 text-xs text-muted-foreground underline`,children:i(`supervisor_work_back`)}):null,(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,d.jsx)(`strong`,{children:i(`ticket_work_overview_223a6f34`)}),(0,d.jsx)(`button`,{type:`button`,className:`text-xs underline`,disabled:e.refreshing,onClick:()=>void e.refresh(),children:i(`refresh_aee88743`)})]}),(0,d.jsxs)(`p`,{className:`my-2 text-xs text-muted-foreground`,children:[i(`ticket_work_count`,{count:x.work_count}),` · `,i(`ticket_question_count`,{count:x.open_questions}),` · `,i(`ticket_approval_count`,{count:x.open_approvals}),` · `,i(`ticket_acceptance_count`,{count:x.needs_acceptance})]}),(0,d.jsx)(`p`,{className:`my-2 text-xs text-muted-foreground`,children:i(`supervisor_work_management_scope`)}),m.current.complete?null:(0,d.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(`ticket_only_some_work_is_shown_other_work_may_still__ee267ea7`)}),e.connected?null:(0,d.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(`ticket_the_connection_is_not_confirmed_answers_and_a_aaac8c0d`)}),m.current.scope.mutation_enabled?null:(0,d.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(`supervisor_work_mutation_disabled`)}),m.current.scope.health===`writable`?null:(0,d.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(m.current.scope.health===`read_only`?`supervisor_work_storage_read_only`:`supervisor_work_storage_unconfirmed`)}),m.current.scope.dispatch_enabled?null:(0,d.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(`supervisor_work_dispatch_disabled`)}),m.current.complete&&e.connected&&x.ticket_count===0&&C.length===0?(0,d.jsx)(`p`,{role:`status`,className:`my-2 text-sm text-muted-foreground`,children:i(`supervisor_work_empty`)}):null,e.error?(0,d.jsx)(`p`,{role:`alert`,className:`my-2 text-sm text-destructive`,children:e.error}):null,(0,d.jsx)(`div`,{className:`grid gap-3`,children:C.map(e=>(0,d.jsxs)(`section`,{hidden:!!b&&b.id!==e.ticket.id,className:`rounded-xl border bg-background p-3 text-sm`,children:[(0,d.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,d.jsx)(`strong`,{className:`min-w-0 break-words`,children:e.ticket.contract.title}),(0,d.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:c[e.ticket.state]})]}),(0,d.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.ticket.contract.objective}),(0,d.jsx)(h,{view:e}),e.ticket.blocked?(0,d.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:e.ticket.blocked.reason}):null,e.submissions.filter(t=>t.id===e.ticket.accepted_submission||t.id===e.ticket.current_submission).map(t=>(0,d.jsxs)(`div`,{className:`mt-2`,children:[(0,d.jsx)(`p`,{children:t.stale?i(`ticket_previous_submission_for_reference_only_8540a39f`):t.id===e.ticket.accepted_submission?i(`ticket_accepted_submission_a269d4af`):i(`ticket_submitted_awaiting_acceptance_14447588`)}),(0,d.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`supervisor_work_result_count`,{count:t.artifacts.length})}),t.artifacts.map((e,t)=>(0,d.jsx)(`button`,{type:`button`,style:{marginRight:`0.5rem`},className:`underline`,onClick:()=>{o.artifact(e.sha256).then(t=>{let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=u(e.sha256,e.uri,t.type),r.click(),URL.revokeObjectURL(n)}).catch(()=>y(i(`ticket_the_artifact_could_not_be_read_refresh_and_tr_d3969eb3`)))},children:i(`ticket_artifact_label`,{number:t+1})},e.sha256)),(0,d.jsxs)(`details`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,d.jsx)(`summary`,{className:`cursor-pointer`,children:i(`supervisor_work_submission_diagnostics`)}),(0,d.jsx)(`p`,{className:`mt-1 break-all font-mono`,children:t.id}),t.evidence.map((e,t)=>(0,d.jsx)(`p`,{className:`break-words`,children:e},t))]})]},t.id)),(0,d.jsxs)(`details`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,d.jsx)(`summary`,{className:`cursor-pointer`,children:i(`supervisor_work_diagnostics`)}),(0,d.jsx)(`p`,{className:`mt-1 break-all font-mono`,children:e.ticket.id})]})]},e.ticket.id))}),v?(0,d.jsx)(`p`,{role:`alert`,children:v}):null,S.length?(0,d.jsx)(`div`,{className:`mt-3 grid gap-3`,children:S.map(n=>(0,d.jsxs)(`div`,{hidden:!!b&&b.id!==n.work_id,children:[(0,d.jsx)(p,{controller:e,state:m,request:n}),t?(0,d.jsx)(`button`,{type:`button`,className:`mt-1 text-xs underline`,onClick:()=>t(n),children:i(`ticket_reference_this_request_in_the_message_box_b3e84d5b`)}):null]},n.id))}):null,w.length?(0,d.jsxs)(`details`,{className:`mt-3`,children:[(0,d.jsx)(`summary`,{className:`cursor-pointer text-xs`,children:i(`ticket_history_label`,{count:w.length})}),(0,d.jsx)(`div`,{className:`mt-2 grid gap-3`,children:w.map(t=>(0,d.jsx)(`div`,{hidden:!!b&&b.id!==t.work_id,children:(0,d.jsx)(p,{controller:e,state:m,request:t})},t.id))})]}):null]})}export{g as TicketWorkPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{r}from"./ui-DQy0lUHc.js";import{c as i,s as a,t as o}from"./api-dae15_RX.js";import{t as s}from"./button-Cfb4l-V4.js";import{n as c,t as l}from"./useWorkflowCatalog-B3e4h1Zh.js";import{t as u}from"./textarea-BKzYyWL5.js";var d=e(t(),1),f=[`queued`,`running`,`suspended`,`succeeded`,`failed`,`cancelled`],p=[`invalid_definition`,`invalid_input`,`invalid_output`,`unknown_reference`,`permission_denied`,`untrusted_workspace`,`budget_exceeded`,`retry_exhausted`,`execution_failed`,`cancelled`,`recovery_suspended`,`suspended`,`dependency_skipped`,`storage`],m=[`run_queued`,`run_started`,`phase`,`step_queued`,`step_started`,`step_suspended`,`step_completed`,`step_failed`,`step_cancelled`,`step_skipped`,`run_suspended`,`run_succeeded`,`run_failed`,`run_cancelled`],h=[`preflight_completed`,`step_reserved`,`retry_reserved`,`agent_usage_recorded`,`suspension_context_persisted`,`workflow_progressed`],g=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function _(){throw Error(r(`workflow_run_invalid_response`))}function v(e){return g(e)?e:_()}function y(e){return typeof e==`string`&&e.trim()?e:_()}function b(e){return Number.isSafeInteger(e)&&e>=0?e:_()}function x(e){return e===null?null:b(e)}function S(e){if(e===void 0)return;let t=v(e);return(!p.includes(t.code)||typeof t.retryable!=`boolean`)&&_(),{code:t.code,retryable:t.retryable}}function C(e,t,n){let r=v(e),i=v(r.budget),a=v(r.usage);(r.session_id!==t||n!==void 0&&r.run_id!==n||!f.includes(r.status)||typeof r.can_cancel!=`boolean`)&&_();let o=Object.entries(v(r.steps)).map(([e,t])=>{let n=v(t);return(n.id!==e||![...f,`skipped`].includes(n.status))&&_(),{id:y(n.id),status:n.status,attempts:b(n.attempts),failure:S(n.failure)}}),s;if(r.suspension!==void 0){let e=v(r.suspension).type;[`tool_approval`,`tool_running`,`recovery`].includes(e)||_(),s=e}let c=y(r.created_at),l=y(r.updated_at);(!Number.isFinite(Date.parse(c))||!Number.isFinite(Date.parse(l)))&&_();let u=b(r.workflow_revision);return u||_(),{run_id:y(r.run_id),session_id:t,workflow_id:y(r.workflow_id),workflow_revision:u,status:r.status,can_cancel:r.can_cancel,last_sequence:b(r.last_sequence),steps:o,budget:{max_steps:b(i.max_steps),max_retries:b(i.max_retries),max_agents:b(i.max_agents),wall_time_ms:b(i.wall_time_ms),max_tokens:x(i.max_tokens??null),max_cost_micros:x(i.max_cost_micros??null)},usage:{steps:b(a.steps),retries:b(a.retries),agents:b(a.agents),tokens:b(a.tokens),cost_micros:x(a.cost_micros)},child_agent_count:b(r.child_agent_count),failure:S(r.failure),suspension:s,created_at:c,updated_at:l}}function w(e){return e.kind===`orchestration`?e.status===`valid`?e.winner?!Number.isSafeInteger(e.revision)||e.revision<=0?r(`no_sendable_revision_119eaea0`):e.invocation_policy.explicit===!0?null:r(`explicit_selection_is_not_allowed_ac1f6f64`):r(`not_the_active_source_ed72c73c`):r(`invalid_definition_d28c9eaf`):r(`workflow_run_instruction_only`)}function T(e){let t=w(e.entry);if(t)throw Error(t);return{workflow_id:e.entry.id,revision:e.entry.revision,args:c(e.entry,e.argsText)}}function E(e,t){return(!e.trim()||t!==void 0&&!t.trim())&&_(),`sessions/${encodeURIComponent(e)}/workflow-runs${t===void 0?``:`/${encodeURIComponent(t)}`}`}var D={async list(e,t){let n=await o.get(E(e),{signal:t});Array.isArray(n)||_();let r=n.map(t=>C(t,e));return new Set(r.map(e=>e.run_id)).size!==r.length&&_(),r},async detail(e,t,n){return C(await o.get(E(e,t),{signal:n}),e,t)},async events(e,t,n,r){let i=await o.get(`${E(e,t)}/events?since=${b(n)}`,{signal:r});Array.isArray(i)||_();let a=n;return i.map(e=>{let n=v(e),r=b(n.sequence);return(n.run_id!==t||r<=a||!m.includes(n.type))&&_(),a=r,{run_id:t,sequence:r,type:n.type,...n.type===`phase`?{phase:h.includes(n.name)?n.name:`workflow_progressed`}:{}}})},async start(e,t){let n=T(t),r=C(await o.postOnce(E(e),n),e);return(r.workflow_id!==n.workflow_id||r.workflow_revision!==n.revision)&&_(),r},async cancel(e,t){return C(await o.postOnce(`${E(e,t)}/cancel`,{}),e,t)}};function O(e){return[`succeeded`,`failed`,`cancelled`].includes(e.status)}function k(e,t=!1){if(i(e)){if(e.status===401||e.status===403)return r(`workflow_run_not_authorized`);if(e.status===404)return r(`workflow_run_not_found`);if(e.status===409)return r(`workflow_run_conflict`);if(e.status===400){try{if(JSON.parse(e.body??`null`)?.code===`workflow_monetary_budget_unsupported`)return r(`workflow_run_monetary_budget_unsupported`)}catch{}return r(`workflow_run_rejected`)}}return r(t?`workflow_run_unconfirmed`:`workflow_run_unavailable`)}var A=n(),j=e=>r(`workflow_run_status_${e}`);function M({sessionId:e}){let t=l(e,!0),[n,i]=(0,d.useState)(null),[o,c]=(0,d.useState)([]),[f,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(null),[E,M]=(0,d.useState)(null),N=(0,d.useRef)([]),P=(0,d.useRef)(null),F=(0,d.useRef)({runId:``,sequence:0}),I=(0,d.useRef)({alive:!0,epoch:0,reading:!1,mutation:!1,controller:new AbortController}),L=(0,d.useCallback)(e=>{let t=N.current.find(t=>t.run_id===e.run_id);if(t&&t.last_sequence>=e.last_sequence)return;let n=[e,...N.current.filter(t=>t.run_id!==e.run_id)].sort((e,t)=>Date.parse(t.created_at)-Date.parse(e.created_at));N.current=n,c(n)},[]),R=(0,d.useCallback)(async()=>{let t=I.current;if(!t.alive||t.reading)return;t.reading=!0;let n=t.epoch,i=()=>t.alive&&t.epoch===n;y(!0);try{let n=await D.list(e,t.controller.signal);if(!i())return;let a=n.map(e=>{let t=N.current.find(t=>t.run_id===e.run_id);return t&&t.last_sequence>=e.last_sequence?t:e});N.current=a,c(a),_(!0),x(null);let o=P.current??a[0]?.run_id??null;if(!o)return;if(!a.some(e=>e.run_id===o)){P.current=null,p(null),h(null);return}P.current=o,p(o),F.current.runId!==o&&(F.current={runId:o,sequence:0});let s=F.current.sequence,[l,u]=await Promise.allSettled([D.detail(e,o,t.controller.signal),D.events(e,o,s,t.controller.signal)]);if(!i()||P.current!==o)return;if(l.status===`fulfilled`&&L(l.value),u.status===`fulfilled`){let e=u.value,t=e.findLast(e=>e.phase);t&&h(t.phase),e.length&&(F.current={runId:o,sequence:e.at(-1).sequence})}(l.status===`rejected`||u.status===`rejected`)&&x(r(`workflow_run_unavailable`))}catch(e){i()&&(x(k(e)),_(!0))}finally{t.reading=!1,t.alive&&(y(!1),t.epoch!==n&&queueMicrotask(()=>{t.alive&&R()}))}},[e,L]);(0,d.useEffect)(()=>{let e=I.current;e.epoch++,e.alive=!0,e.controller=new AbortController,R();let t=window.setInterval(()=>{e.mutation||R()},2e3);return()=>{e.epoch++,e.alive=!1,e.controller.abort(),window.clearInterval(t)}},[R]);let z=e=>{P.current=e,F.current={runId:e,sequence:0},p(e),h(null),I.current.epoch++,R()},B=async t=>{let r=I.current;if(!(r.mutation||!t&&!n)){r.mutation=!0,M(t??`start`),C(null);try{let i=t?await D.cancel(e,t):await D.start(e,n);if(!r.alive)return;r.epoch++,L(i),P.current=i.run_id,p(i.run_id),F.current.runId!==i.run_id&&(F.current={runId:i.run_id,sequence:0},h(null))}catch(e){r.alive&&C(k(e,!0))}finally{r.mutation=!1,r.alive&&(r.epoch++,M(null),R())}}},V=null;if(n)try{T(n)}catch(e){V=a(e)}let H=t.catalog?.entries.filter(e=>e.kind===`orchestration`)??[],U=o.find(e=>e.run_id===f);return(0,A.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-5 py-4 text-sm`,children:[(0,A.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`workflow_run_hint`)}),(0,A.jsx)(s,{size:`sm`,variant:`outline`,disabled:v||E!==null,onClick:()=>{t.refresh(),R()},children:r(v?`refreshing_71659de8`:`workflow_run_refresh`)})]}),(0,A.jsxs)(`section`,{className:`space-y-3 rounded-xl border bg-muted/20 p-3`,"aria-label":r(`workflow_run_start_section`),children:[t.error&&(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r(`workflow_run_catalog_unavailable`)}),(0,A.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium`,children:r(`workflow_run_choose`)}),(0,A.jsxs)(`select`,{className:`h-9 w-full rounded-md border bg-background px-2 text-sm`,disabled:t.loading||E!==null,value:n?`${n.entry.source}:${n.entry.id}:${n.entry.revision}`:``,onChange:e=>{let t=H.find(t=>`${t.source}:${t.id}:${t.revision}`===e.target.value);i(t?{entry:t,argsText:`{}`}:null),C(null)},children:[(0,A.jsx)(`option`,{value:``,children:t.loading?r(`workflow_run_loading`):r(`workflow_run_choose`)}),n&&!H.some(e=>e.id===n.entry.id&&e.source===n.entry.source&&e.revision===n.entry.revision)?(0,A.jsxs)(`option`,{value:`${n.entry.source}:${n.entry.id}:${n.entry.revision}`,children:[n.entry.name,` · r`,n.entry.revision]}):null,H.map(e=>(0,A.jsxs)(`option`,{value:`${e.source}:${e.id}:${e.revision}`,disabled:w(e)!==null,children:[e.name,` · `,e.source,` · r`,e.revision]},`${e.source}:${e.id}:${e.revision}`))]})]}),!t.loading&&!t.error&&!H.length?(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`workflow_run_no_definitions`)}):null,n?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:n.entry.description}),(0,A.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium`,children:r(`workflow_run_arguments`)}),(0,A.jsx)(u,{rows:3,className:`font-mono text-xs`,disabled:E!==null,value:n.argsText,onChange:e=>i({...n,argsText:e.target.value})})]}),V?(0,A.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:V}):null]}):null,(0,A.jsx)(s,{size:`sm`,disabled:!n||V!==null||E!==null,onClick:()=>void B(),children:r(E===`start`?`workflow_run_starting`:`workflow_run_start`)}),S?(0,A.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:S}):null]}),(0,A.jsxs)(`section`,{className:`mt-5 space-y-3`,"aria-label":r(`workflow_run_history`),children:[(0,A.jsx)(`h3`,{className:`text-sm font-medium`,children:r(`workflow_run_history`)}),b?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:b}):null,g?!b&&!o.length?(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`workflow_run_empty`)}):null:(0,A.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:r(`workflow_run_loading`)}),(0,A.jsx)(`ul`,{className:`space-y-2`,children:o.map(e=>(0,A.jsxs)(`li`,{className:`rounded-lg border`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-3 py-2 text-left hover:bg-accent`,"aria-expanded":e.run_id===f,onClick:()=>z(e.run_id),children:[(0,A.jsxs)(`span`,{className:`min-w-0 break-all text-xs font-medium`,children:[e.workflow_id,` · r`,e.workflow_revision]}),(0,A.jsx)(`span`,{className:`shrink-0 text-xs`,role:`status`,children:j(e.status)})]}),U?.run_id===e.run_id?(0,A.jsxs)(`div`,{className:`space-y-3 border-t px-3 py-3`,children:[(0,A.jsx)(`p`,{className:`break-all font-mono text-[10px] text-muted-foreground`,children:e.run_id}),m?(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`workflow_run_phase_${m}`)}):null,(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-muted-foreground`,children:[(0,A.jsxs)(`span`,{children:[r(`workflow_run_steps`),`: `,e.usage.steps,`/`,e.budget.max_steps]}),(0,A.jsxs)(`span`,{children:[r(`workflow_run_retries`),`: `,e.usage.retries,`/`,e.budget.max_retries]}),(0,A.jsxs)(`span`,{children:[r(`workflow_run_agents`),`: `,e.usage.agents,`/`,e.budget.max_agents]}),(0,A.jsxs)(`span`,{children:[r(`workflow_run_time_budget`),`: `,e.budget.wall_time_ms/1e3,`s`]}),(0,A.jsxs)(`span`,{children:[r(`workflow_run_tokens`),`: `,e.usage.tokens,e.budget.max_tokens===null?``:`/${e.budget.max_tokens}`]}),(0,A.jsx)(`span`,{children:e.usage.cost_micros===null?r(`workflow_run_cost_unmetered`):`${r(`workflow_run_cost_metered`)}: ${e.usage.cost_micros}${e.budget.max_cost_micros===null?``:`/${e.budget.max_cost_micros}`}`})]}),e.suspension?(0,A.jsx)(`p`,{className:`text-xs`,children:r(`workflow_run_suspension_${e.suspension}`)}):null,e.failure?(0,A.jsx)(`p`,{className:`text-xs text-destructive`,children:r(`workflow_run_failure_${e.failure.code}`)}):null,(0,A.jsx)(`ul`,{className:`space-y-1`,"aria-label":r(`workflow_run_steps`),children:e.steps.map(e=>(0,A.jsxs)(`li`,{className:`flex flex-wrap justify-between gap-2 rounded bg-muted/40 px-2 py-1 text-xs`,children:[(0,A.jsx)(`span`,{className:`break-all`,children:e.id}),(0,A.jsxs)(`span`,{children:[j(e.status),` · `,r(`workflow_run_attempts`,{count:e.attempts})]})]},e.id))}),e.can_cancel&&!O(e)?(0,A.jsx)(s,{size:`sm`,variant:`outline`,disabled:E!==null,onClick:()=>void B(e.run_id),children:E===e.run_id?r(`workflow_run_cancelling`):r(`workflow_run_cancel`)}):null]}):null]},e.run_id))})]})]})}export{M as default};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{r}from"./ui-OvgR8HKW.js";import{c as i,s as a,t as o}from"./api-CPcpMjoM.js";import{t as s}from"./button-Cfb4l-V4.js";import{n as c,t as l}from"./useWorkflowCatalog-BlIMJrl3.js";import{t as u}from"./textarea-BKzYyWL5.js";var d=e(t(),1),f=[`queued`,`running`,`suspended`,`succeeded`,`failed`,`cancelled`],p=[`invalid_definition`,`invalid_input`,`invalid_output`,`unknown_reference`,`permission_denied`,`untrusted_workspace`,`budget_exceeded`,`retry_exhausted`,`execution_failed`,`cancelled`,`recovery_suspended`,`suspended`,`dependency_skipped`,`storage`],m=[`run_queued`,`run_started`,`phase`,`step_queued`,`step_started`,`step_suspended`,`step_completed`,`step_failed`,`step_cancelled`,`step_skipped`,`run_suspended`,`run_succeeded`,`run_failed`,`run_cancelled`],h=[`preflight_completed`,`step_reserved`,`retry_reserved`,`agent_usage_recorded`,`suspension_context_persisted`,`workflow_progressed`],g=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function _(){throw Error(r(`workflow_run_invalid_response`))}function v(e){return g(e)?e:_()}function y(e){return typeof e==`string`&&e.trim()?e:_()}function b(e){return Number.isSafeInteger(e)&&e>=0?e:_()}function x(e){return e===null?null:b(e)}function S(e){if(e===void 0)return;let t=v(e);return(!p.includes(t.code)||typeof t.retryable!=`boolean`)&&_(),{code:t.code,retryable:t.retryable}}function C(e,t,n){let r=v(e),i=v(r.budget),a=v(r.usage);(r.session_id!==t||n!==void 0&&r.run_id!==n||!f.includes(r.status)||typeof r.can_cancel!=`boolean`)&&_();let o=Object.entries(v(r.steps)).map(([e,t])=>{let n=v(t);return(n.id!==e||![...f,`skipped`].includes(n.status))&&_(),{id:y(n.id),status:n.status,attempts:b(n.attempts),failure:S(n.failure)}}),s;if(r.suspension!==void 0){let e=v(r.suspension).type;[`tool_approval`,`tool_running`,`recovery`].includes(e)||_(),s=e}let c=y(r.created_at),l=y(r.updated_at);(!Number.isFinite(Date.parse(c))||!Number.isFinite(Date.parse(l)))&&_();let u=b(r.workflow_revision);return u||_(),{run_id:y(r.run_id),session_id:t,workflow_id:y(r.workflow_id),workflow_revision:u,status:r.status,can_cancel:r.can_cancel,last_sequence:b(r.last_sequence),steps:o,budget:{max_steps:b(i.max_steps),max_retries:b(i.max_retries),max_agents:b(i.max_agents),wall_time_ms:b(i.wall_time_ms),max_tokens:x(i.max_tokens??null),max_cost_micros:x(i.max_cost_micros??null)},usage:{steps:b(a.steps),retries:b(a.retries),agents:b(a.agents),tokens:b(a.tokens),cost_micros:x(a.cost_micros)},child_agent_count:b(r.child_agent_count),failure:S(r.failure),suspension:s,created_at:c,updated_at:l}}function w(e){return e.kind===`orchestration`?e.status===`valid`?e.winner?!Number.isSafeInteger(e.revision)||e.revision<=0?r(`no_sendable_revision_119eaea0`):e.invocation_policy.explicit===!0?null:r(`explicit_selection_is_not_allowed_ac1f6f64`):r(`not_the_active_source_ed72c73c`):r(`invalid_definition_d28c9eaf`):r(`workflow_run_instruction_only`)}function T(e){let t=w(e.entry);if(t)throw Error(t);return{workflow_id:e.entry.id,revision:e.entry.revision,args:c(e.entry,e.argsText)}}function E(e,t){return(!e.trim()||t!==void 0&&!t.trim())&&_(),`sessions/${encodeURIComponent(e)}/workflow-runs${t===void 0?``:`/${encodeURIComponent(t)}`}`}var D={async list(e,t){let n=await o.get(E(e),{signal:t});Array.isArray(n)||_();let r=n.map(t=>C(t,e));return new Set(r.map(e=>e.run_id)).size!==r.length&&_(),r},async detail(e,t,n){return C(await o.get(E(e,t),{signal:n}),e,t)},async events(e,t,n,r){let i=await o.get(`${E(e,t)}/events?since=${b(n)}`,{signal:r});Array.isArray(i)||_();let a=n;return i.map(e=>{let n=v(e),r=b(n.sequence);return(n.run_id!==t||r<=a||!m.includes(n.type))&&_(),a=r,{run_id:t,sequence:r,type:n.type,...n.type===`phase`?{phase:h.includes(n.name)?n.name:`workflow_progressed`}:{}}})},async start(e,t){let n=T(t),r=C(await o.postOnce(E(e),n),e);return(r.workflow_id!==n.workflow_id||r.workflow_revision!==n.revision)&&_(),r},async cancel(e,t){return C(await o.postOnce(`${E(e,t)}/cancel`,{}),e,t)}};function O(e){return[`succeeded`,`failed`,`cancelled`].includes(e.status)}function k(e,t=!1){if(i(e)){if(e.status===401||e.status===403)return r(`workflow_run_not_authorized`);if(e.status===404)return r(`workflow_run_not_found`);if(e.status===409)return r(`workflow_run_conflict`);if(e.status===400){try{if(JSON.parse(e.body??`null`)?.code===`workflow_monetary_budget_unsupported`)return r(`workflow_run_monetary_budget_unsupported`)}catch{}return r(`workflow_run_rejected`)}}return r(t?`workflow_run_unconfirmed`:`workflow_run_unavailable`)}var A=n(),j=e=>r(`workflow_run_status_${e}`);function M({sessionId:e}){let t=l(e,!0),[n,i]=(0,d.useState)(null),[o,c]=(0,d.useState)([]),[f,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(null),[E,M]=(0,d.useState)(null),N=(0,d.useRef)([]),P=(0,d.useRef)(null),F=(0,d.useRef)({runId:``,sequence:0}),I=(0,d.useRef)({alive:!0,epoch:0,reading:!1,mutation:!1,controller:new AbortController}),L=(0,d.useCallback)(e=>{let t=N.current.find(t=>t.run_id===e.run_id);if(t&&t.last_sequence>=e.last_sequence)return;let n=[e,...N.current.filter(t=>t.run_id!==e.run_id)].sort((e,t)=>Date.parse(t.created_at)-Date.parse(e.created_at));N.current=n,c(n)},[]),R=(0,d.useCallback)(async()=>{let t=I.current;if(!t.alive||t.reading)return;t.reading=!0;let n=t.epoch,i=()=>t.alive&&t.epoch===n;y(!0);try{let n=await D.list(e,t.controller.signal);if(!i())return;let a=n.map(e=>{let t=N.current.find(t=>t.run_id===e.run_id);return t&&t.last_sequence>=e.last_sequence?t:e});N.current=a,c(a),_(!0),x(null);let o=P.current??a[0]?.run_id??null;if(!o)return;if(!a.some(e=>e.run_id===o)){P.current=null,p(null),h(null);return}P.current=o,p(o),F.current.runId!==o&&(F.current={runId:o,sequence:0});let s=F.current.sequence,[l,u]=await Promise.allSettled([D.detail(e,o,t.controller.signal),D.events(e,o,s,t.controller.signal)]);if(!i()||P.current!==o)return;if(l.status===`fulfilled`&&L(l.value),u.status===`fulfilled`){let e=u.value,t=e.findLast(e=>e.phase);t&&h(t.phase),e.length&&(F.current={runId:o,sequence:e.at(-1).sequence})}(l.status===`rejected`||u.status===`rejected`)&&x(r(`workflow_run_unavailable`))}catch(e){i()&&(x(k(e)),_(!0))}finally{t.reading=!1,t.alive&&(y(!1),t.epoch!==n&&queueMicrotask(()=>{t.alive&&R()}))}},[e,L]);(0,d.useEffect)(()=>{let e=I.current;e.epoch++,e.alive=!0,e.controller=new AbortController,R();let t=window.setInterval(()=>{e.mutation||R()},2e3);return()=>{e.epoch++,e.alive=!1,e.controller.abort(),window.clearInterval(t)}},[R]);let z=e=>{P.current=e,F.current={runId:e,sequence:0},p(e),h(null),I.current.epoch++,R()},B=async t=>{let r=I.current;if(!(r.mutation||!t&&!n)){r.mutation=!0,M(t??`start`),C(null);try{let i=t?await D.cancel(e,t):await D.start(e,n);if(!r.alive)return;r.epoch++,L(i),P.current=i.run_id,p(i.run_id),F.current.runId!==i.run_id&&(F.current={runId:i.run_id,sequence:0},h(null))}catch(e){r.alive&&C(k(e,!0))}finally{r.mutation=!1,r.alive&&(r.epoch++,M(null),R())}}},V=null;if(n)try{T(n)}catch(e){V=a(e)}let H=t.catalog?.entries.filter(e=>e.kind===`orchestration`)??[],U=o.find(e=>e.run_id===f);return(0,A.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-5 py-4 text-sm`,children:[(0,A.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`workflow_run_hint`)}),(0,A.jsx)(s,{size:`sm`,variant:`outline`,disabled:v||E!==null,onClick:()=>{t.refresh(),R()},children:r(v?`refreshing_71659de8`:`workflow_run_refresh`)})]}),(0,A.jsxs)(`section`,{className:`space-y-3 rounded-xl border bg-muted/20 p-3`,"aria-label":r(`workflow_run_start_section`),children:[t.error&&(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r(`workflow_run_catalog_unavailable`)}),(0,A.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium`,children:r(`workflow_run_choose`)}),(0,A.jsxs)(`select`,{className:`h-9 w-full rounded-md border bg-background px-2 text-sm`,disabled:t.loading||E!==null,value:n?`${n.entry.source}:${n.entry.id}:${n.entry.revision}`:``,onChange:e=>{let t=H.find(t=>`${t.source}:${t.id}:${t.revision}`===e.target.value);i(t?{entry:t,argsText:`{}`}:null),C(null)},children:[(0,A.jsx)(`option`,{value:``,children:t.loading?r(`workflow_run_loading`):r(`workflow_run_choose`)}),n&&!H.some(e=>e.id===n.entry.id&&e.source===n.entry.source&&e.revision===n.entry.revision)?(0,A.jsxs)(`option`,{value:`${n.entry.source}:${n.entry.id}:${n.entry.revision}`,children:[n.entry.name,` · r`,n.entry.revision]}):null,H.map(e=>(0,A.jsxs)(`option`,{value:`${e.source}:${e.id}:${e.revision}`,disabled:w(e)!==null,children:[e.name,` · `,e.source,` · r`,e.revision]},`${e.source}:${e.id}:${e.revision}`))]})]}),!t.loading&&!t.error&&!H.length?(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`workflow_run_no_definitions`)}):null,n?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:n.entry.description}),(0,A.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,A.jsx)(`span`,{className:`text-xs font-medium`,children:r(`workflow_run_arguments`)}),(0,A.jsx)(u,{rows:3,className:`font-mono text-xs`,disabled:E!==null,value:n.argsText,onChange:e=>i({...n,argsText:e.target.value})})]}),V?(0,A.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:V}):null]}):null,(0,A.jsx)(s,{size:`sm`,disabled:!n||V!==null||E!==null,onClick:()=>void B(),children:r(E===`start`?`workflow_run_starting`:`workflow_run_start`)}),S?(0,A.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:S}):null]}),(0,A.jsxs)(`section`,{className:`mt-5 space-y-3`,"aria-label":r(`workflow_run_history`),children:[(0,A.jsx)(`h3`,{className:`text-sm font-medium`,children:r(`workflow_run_history`)}),b?(0,A.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:b}):null,g?!b&&!o.length?(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`workflow_run_empty`)}):null:(0,A.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:r(`workflow_run_loading`)}),(0,A.jsx)(`ul`,{className:`space-y-2`,children:o.map(e=>(0,A.jsxs)(`li`,{className:`rounded-lg border`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-3 py-2 text-left hover:bg-accent`,"aria-expanded":e.run_id===f,onClick:()=>z(e.run_id),children:[(0,A.jsxs)(`span`,{className:`min-w-0 break-all text-xs font-medium`,children:[e.workflow_id,` · r`,e.workflow_revision]}),(0,A.jsx)(`span`,{className:`shrink-0 text-xs`,role:`status`,children:j(e.status)})]}),U?.run_id===e.run_id?(0,A.jsxs)(`div`,{className:`space-y-3 border-t px-3 py-3`,children:[(0,A.jsx)(`p`,{className:`break-all font-mono text-[10px] text-muted-foreground`,children:e.run_id}),m?(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`workflow_run_phase_${m}`)}):null,(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-muted-foreground`,children:[(0,A.jsxs)(`span`,{children:[r(`workflow_run_steps`),`: `,e.usage.steps,`/`,e.budget.max_steps]}),(0,A.jsxs)(`span`,{children:[r(`workflow_run_retries`),`: `,e.usage.retries,`/`,e.budget.max_retries]}),(0,A.jsxs)(`span`,{children:[r(`workflow_run_agents`),`: `,e.usage.agents,`/`,e.budget.max_agents]}),(0,A.jsxs)(`span`,{children:[r(`workflow_run_time_budget`),`: `,e.budget.wall_time_ms/1e3,`s`]}),(0,A.jsxs)(`span`,{children:[r(`workflow_run_tokens`),`: `,e.usage.tokens,e.budget.max_tokens===null?``:`/${e.budget.max_tokens}`]}),(0,A.jsx)(`span`,{children:e.usage.cost_micros===null?r(`workflow_run_cost_unmetered`):`${r(`workflow_run_cost_metered`)}: ${e.usage.cost_micros}${e.budget.max_cost_micros===null?``:`/${e.budget.max_cost_micros}`}`})]}),e.suspension?(0,A.jsx)(`p`,{className:`text-xs`,children:r(`workflow_run_suspension_${e.suspension}`)}):null,e.failure?(0,A.jsx)(`p`,{className:`text-xs text-destructive`,children:r(`workflow_run_failure_${e.failure.code}`)}):null,(0,A.jsx)(`ul`,{className:`space-y-1`,"aria-label":r(`workflow_run_steps`),children:e.steps.map(e=>(0,A.jsxs)(`li`,{className:`flex flex-wrap justify-between gap-2 rounded bg-muted/40 px-2 py-1 text-xs`,children:[(0,A.jsx)(`span`,{className:`break-all`,children:e.id}),(0,A.jsxs)(`span`,{children:[j(e.status),` · `,r(`workflow_run_attempts`,{count:e.attempts})]})]},e.id))}),e.can_cancel&&!O(e)?(0,A.jsx)(s,{size:`sm`,variant:`outline`,disabled:E!==null,onClick:()=>void B(e.run_id),children:E===e.run_id?r(`workflow_run_cancelling`):r(`workflow_run_cancel`)}):null]}):null]},e.run_id))})]})]})}export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./runtimeConfig-DNyol2mX.js";var t=class extends Error{status;statusText;body;kind=`http`;constructor(e,t,n,r){super(e),this.status=t,this.statusText=n,this.body=r,this.name=`ApiError`}},n=class extends Error{kind=`network`;constructor(e){super(`A network error prevented the request. Check your connection and try again.`,{cause:e}),this.name=`NetworkRequestError`}},r=class extends Error{kind=`timeout`;constructor(e){super(`The request timed out. Please try again.`,{cause:e}),this.name=`RequestTimeoutError`}},i=class extends Error{kind=`cancelled`;constructor(e){super(`The request was cancelled.`,{cause:e}),this.name=`RequestCancelledError`}};function a(e){return e instanceof t}function o(e){return e instanceof r?`The request timed out. Please try again.`:e instanceof i?`The request was cancelled.`:e instanceof n?`A network error prevented the request. Check your connection and try again.`:a(e)?e.status===401?`Authentication failed. Please check your credentials.`:e.status===403?`You don't have permission to perform this action.`:e.status===404?`The requested resource was not found.`:e.status>=500?e.message?.trim()?e.message:`Server error. Please try again later.`:e.message:e instanceof Error?e.message:`An unexpected error occurred`}var s=[/\/api\/v1\/respond\/[^/]+\/pending/,/\/api\/v1\/sessions\/?$/,/\/api\/v1\/events\/[^/]+/],c=!1;function l(){return c&&typeof localStorage<`u`&&localStorage.getItem(`lotus_debug_api_requests`)===`1`}function u(e){try{let t=new URL(e,typeof window<`u`?window.location.origin:`http://localhost`).pathname;return s.some(e=>e.test(t))}catch{return!1}}var d={};function f(e,t){if(!l()||!u(t))return;let n=`${e} ${new URL(t,typeof window<`u`?window.location.origin:`http://localhost`).pathname}`;d[n]=(d[n]||0)+1,console.debug(`[ApiClient] ${e} ${n} (total: ${d[n]})`)}var p=e=>{c=e,!(!e||typeof window>`u`)&&(window.__lotusApiCounters=()=>(console.table(d),{...d}),window.__lotusResetApiCounters=()=>{d={}})},m=class{baseUrl;defaultHeaders;requestCredentials;transport;constructor(e){this.baseUrl=e.baseUrl.trim().replace(/\/+$/,``),this.defaultHeaders=e.defaultHeaders??{"Content-Type":`application/json`},this.requestCredentials=e.requestCredentials,this.transport=e.transport}resolveUrl(e){let t=e.replace(/^\/+/,``);return`${this.baseUrl}/${t}`}mergeHeaders(e){let t=new Headers(this.defaultHeaders);return e&&new Headers(e).forEach((e,n)=>t.set(n,e)),t}createRequestInit(e,t,n){return{...t,method:e,headers:this.mergeHeaders(t?.headers),credentials:this.requestCredentials,...n?{body:n.value?JSON.stringify(n.value):void 0}:{}}}async handleResponse(e){if(!e.ok){let n=await e.text(),r=e.statusText;if(n)try{let t=JSON.parse(n),i=typeof t.error==`object`?t.error?.message:void 0,a=typeof t.error==`string`?t.error:void 0,o=typeof t.message==`string`?t.message:void 0,s=typeof t.detail==`string`?t.detail:void 0;r=a||(typeof i==`string`?i:void 0)||o||s||e.statusText}catch{r=n}throw new t(r,e.status,e.statusText,n)}if(e.status!==204)return(e.headers?.get?.(`content-type`)||``).includes(`application/json`)?e.json():typeof e.text==`function`?await e.text():e.json()}async send(e,t,n,r){let i=this.resolveUrl(t);f(e.toUpperCase(),i);let a=await this.transport.request(i,this.createRequestInit(e,n,r));return this.handleResponse(a)}async get(e,t){return this.send(`GET`,e,t)}async getOnce(e,t){let n=this.resolveUrl(e);f(`GET`,n);let r=await this.transport.requestOnce(n,this.createRequestInit(`GET`,t));return this.handleResponse(r)}async post(e,t,n){return this.send(`POST`,e,n,{value:t})}async postOnce(e,t,{logicalTimeoutMs:n,...r}={}){let i=this.resolveUrl(e);f(`POST`,i);let a=await this.transport.requestOnce(i,this.createRequestInit(`POST`,r,{value:t}),n);return this.handleResponse(a)}async put(e,t,n){return this.send(`PUT`,e,n,{value:t})}async putOnce(e,t,n){let r=this.resolveUrl(e);f(`PUT`,r);let i=await this.transport.requestOnce(r,this.createRequestInit(`PUT`,n,{value:t}));return this.handleResponse(i)}async patch(e,t,n){return this.send(`PATCH`,e,n,{value:t})}async delete(e,t){return this.send(`DELETE`,e,t)}async deleteOnce(e,t){let n=this.resolveUrl(e);f(`DELETE`,n);let r=await this.transport.requestOnce(n,this.createRequestInit(`DELETE`,t));return this.handleResponse(r)}async request(e,t,n){return this.send(e,t,n)}async fetchRaw(e,n){let r=this.resolveUrl(e);f(n?.method?.toUpperCase()??`GET`,r);let i=this.mergeHeaders(n?.headers),a=(n?.method??`GET`).toUpperCase();(a===`GET`||a===`HEAD`)&&!n?.body&&!new Headers(n?.headers).has(`Content-Type`)&&i.delete(`Content-Type`);let o=await this.transport.requestOnce(r,{...n,headers:i,credentials:this.requestCredentials});if(!o.ok){let e=o.body?.cancel();throw e&&e.catch(()=>void 0),new t(`API request failed: ${o.statusText}`,o.status,o.statusText)}return o}},h=new Set([`GET`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`]),g=new Set([408,429,500,502,503,504]),_=new Set([101,103,204,205,304]),v=3e4,y=3,b=2e3,x=typeof ReadableStream>`u`?void 0:Object.getOwnPropertyDescriptor(ReadableStream.prototype,`locked`)?.get;function S(e){return 250*2**Math.max(0,e-1)}function C(e,t){if(!Number.isFinite(e)||e<=0)throw TypeError(`${t} must be a positive finite number.`)}function w(e,t){if(typeof DOMException<`u`)return new DOMException(t,e);let n=Error(t);return n.name=e,n}function T(e){return typeof e==`object`&&!!e&&`name`in e&&e.name===`TimeoutError`}function E(e,t){let n=new AbortController,r,i,a,o=(e,t)=>{r===void 0&&(r=e,i=t,n.abort(t))},s=()=>{let t=e?.reason;o(T(t)?`caller-timeout`:`caller-cancelled`,t)};return e?.aborted?s():(e?.addEventListener(`abort`,s,{once:!0}),a=setTimeout(()=>{o(`logical-timeout`,w(`TimeoutError`,`The logical request deadline elapsed.`))},t)),{signal:n.signal,get source(){return r},get cause(){return i},cleanup(){a!==void 0&&clearTimeout(a),e?.removeEventListener(`abort`,s)}}}function D(e,t){let n=e.cause??t;return e.source===`caller-timeout`||e.source===`logical-timeout`?new r(n):new i(n)}function O(e,t){return t.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=()=>{t.removeEventListener(`abort`,i),r(t.reason)};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}function k(e,t){return t.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),t.removeEventListener(`abort`,a),r(t.reason)};t.addEventListener(`abort`,a,{once:!0})})}function A(e){if(typeof e!=`string`){if(typeof URL<`u`)try{URL.prototype.toString.call(e);return}catch{}throw TypeError(`HttpTransport input must be a string or URL; Request is unsupported.`)}}function j(e){if(e===null||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`RequestInit must be an object.`);let t=e,n=Object.create(null),r,i,a,o=!1,s=!1,c=!1;for(let[t,l]of Object.entries(e)){if(t===`method`){r=l,o=!0;continue}if(t===`body`){i=l,s=!0;continue}if(t===`signal`){a=l,c=!0;continue}Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:l,writable:!0})}o||(r=t.method),s||(i=t.body),c||(a=t.signal);for(let[e,t]of[[`method`,r],[`body`,i]])Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0});return{method:r,body:i,callerSignal:a,requestInit:n}}function M(e){if(e===void 0)return`GET`;if(typeof e==`string`)return e.replace(/[a-z]/g,e=>String.fromCharCode(e.charCodeAt(0)-32))}function N(e){if(typeof e!=`object`||!e)return!1;if(x)try{return x.call(e),!0}catch{}try{let t=new Set,n=e;for(;n!==null;){if(t.has(n)||(t.add(n),Object.getOwnPropertyDescriptor(n,`getReader`)!==void 0))return!0;n=Object.getPrototypeOf(n)}return!1}catch{return!0}}async function P(e,t){try{let n=e.body?.cancel();n&&await O(n,t)}catch(e){if(t.aborted)throw e}}function F(e,t){if(_.has(e.status)||!e.body)return t.cleanup(),e;let r;try{r=e.body.getReader()}catch(r){let i=new n(r);throw e.body.cancel(r).catch(()=>void 0),t.cleanup(),i}let i=!1,a,o=()=>i?!1:(i=!0,t.signal.removeEventListener(`abort`,s),t.cleanup(),!0),s=()=>{let e=D(t,t.signal.reason);if(o()){r.cancel(t.signal.reason).catch(()=>void 0);try{a?.error(e)}catch{}}},c;try{c=new ReadableStream({start(e){a=e,t.signal.addEventListener(`abort`,s,{once:!0}),t.signal.aborted&&s()},async pull(e){try{let t=await r.read();if(i)return;if(t.done){o();try{e.close()}catch{}}else e.enqueue(t.value)}catch(r){if(!o())return;try{e.error(t.signal.aborted?D(t,r):new n(r))}catch{}}},async cancel(e){o(),await r.cancel(e)}})}catch(t){let i=new n(t);throw o(),r.releaseLock(),e.body.cancel(t).catch(()=>void 0),i}let l;try{l=new Response(c,{headers:e.headers,status:e.status,statusText:e.statusText})}catch(e){let t=new n(e);if(o()){r.cancel(e).catch(()=>void 0);try{a?.error(t)}catch{}}throw t}for(let[t,n]of[[`redirected`,e.redirected],[`type`,e.type],[`url`,e.url]])try{Object.defineProperty(l,t,{configurable:!0,enumerable:!0,value:n})}catch{}return l}var I=class{fetchImplementation;logicalTimeoutMs;totalAttempts;retryDelayMs;maxRetryDelayMs;constructor(e){let t=e.logicalTimeoutMs??v,n=e.totalAttempts??y,r=e.maxRetryDelayMs??b;if(C(t,`logicalTimeoutMs`),C(n,`totalAttempts`),C(r,`maxRetryDelayMs`),!Number.isInteger(n))throw TypeError(`totalAttempts must be an integer.`);this.fetchImplementation=e.fetchImplementation,this.logicalTimeoutMs=t,this.totalAttempts=n,this.retryDelayMs=e.retryDelayMs??S,this.maxRetryDelayMs=r}request(e,t={}){return this.execute(e,t,this.totalAttempts)}requestOnce(e,t={},n){return this.execute(e,t,1,n)}async execute(e,t,a,o=this.logicalTimeoutMs){C(o,`logicalTimeoutMs`),A(e);let s;try{s=j(t)}catch(e){throw new n(e)}let c=M(s.method),l=c!==void 0&&h.has(c)&&!N(s.body)?a:1,u=E(s.callerSignal,o),d=Object.freeze({...s.requestInit,signal:u.signal}),f=!1;try{if(u.signal.aborted)throw D(u);for(let t=1;t<=l;t+=1)try{if(u.signal.aborted)throw D(u);let n=await O(Promise.resolve(this.fetchImplementation(e,d)),u.signal);if(!(t<l&&g.has(n.status))){let e=F(n,u);return f=!0,e}await P(n,u.signal),await this.waitBeforeRetry(t,u.signal)}catch(e){if(u.signal.aborted)throw D(u,e);if(e instanceof n||e instanceof r||e instanceof i)throw e;if(t>=l)throw new n(e);try{await this.waitBeforeRetry(t,u.signal)}catch(e){throw u.signal.aborted?D(u,e):e}}throw new n}finally{f||u.cleanup()}}waitBeforeRetry(e,t){let n=this.retryDelayMs(e);return k(Number.isFinite(n)?Math.min(this.maxRetryDelayMs,Math.max(0,n)):this.maxRetryDelayMs,t)}};function L(){return new I({fetchImplementation:(e,t)=>globalThis.fetch(e,t)})}var R=e();p(R.publicMetadata.development);var z=L(),B=new m({baseUrl:R.endpoints.nativeApi,requestCredentials:R.auth.requestCredentials,transport:z}),V=()=>B.resolveUrl(``).replace(/\/+$/,``);export{i as a,a as c,n as i,V as n,r as o,t as r,o as s,B as t};
|