Files
openclaw-config/cache/control-ui-assets/d08fd045b9cb86d13f0b4aa403c8a06ddcd32e533058ae463245169e5cff5e85/assets/normalization-m-N_6hXH.js
T

2 lines
9.3 KiB
JavaScript

import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{$r as t,Gr as n,Hr as r,Jr as i,Kr as a,Qr as o,Wr as s,Xr as c,Yr as ee,Zr as te,ei as ne,ni as l,qr as u,ti as d,wn as f}from"./control-ui-foundation-CeFMP1Ly.js";import{bl as re,yl as p}from"./control-ui-boot-Cdpgu1Gm.js";import{D as m,E as h,T as g,b as _,d as v,h as y,s as b,x}from"./config-runtime-C4gfjhZc.js";function S(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim()!==``):[]}function C(e){if(!(!f(e)||typeof e.unrestricted!=`boolean`)){if(e.unrestricted)return{unrestricted:!0};if(!(!Array.isArray(e.roots)||typeof e.writable!=`boolean`))return{unrestricted:!1,roots:e.roots.filter(e=>typeof e==`string`),writable:e.writable}}}function w(e){if(!f(e))return;let t=f(e.workspace)?{kind:e.workspace.kind===`scratch`||e.workspace.kind===`dir`||e.workspace.kind===`worktree`?e.workspace.kind:void 0,...typeof e.workspace.path==`string`?{path:e.workspace.path}:{},...typeof e.workspace.branch==`string`?{branch:e.workspace.branch}:{},...typeof e.workspace.sourcePath==`string`?{sourcePath:e.workspace.sourcePath}:{},...typeof e.workspace.sourceBranch==`string`?{sourceBranch:e.workspace.sourceBranch}:{}}:void 0,n=C(e.workspaceAccess),r=S(e.skills),i=S(e.createdCardIds),a={...typeof e.tenant==`string`?{tenant:e.tenant}:{},...typeof e.boardId==`string`?{boardId:e.boardId}:{},...typeof e.createdByCardId==`string`?{createdByCardId:e.createdByCardId}:{},...typeof e.idempotencyKey==`string`?{idempotencyKey:e.idempotencyKey}:{},...r.length?{skills:r}:{},...t?.kind?{workspace:t}:{},...n?{workspaceAccess:n}:{},...typeof e.maxRuntimeSeconds==`number`?{maxRuntimeSeconds:e.maxRuntimeSeconds}:{},...typeof e.maxRetries==`number`?{maxRetries:e.maxRetries}:{},...typeof e.scheduledAt==`number`?{scheduledAt:e.scheduledAt}:{},...typeof e.summary==`string`?{summary:e.summary}:{},...i.length?{createdCardIds:i}:{},...typeof e.dispatchCount==`number`?{dispatchCount:e.dispatchCount}:{},...typeof e.lastDispatchAt==`number`?{lastDispatchAt:e.lastDispatchAt}:{}};return Object.keys(a).length?a:void 0}function T(e){return!f(e)||e.kind!==`claim`&&e.kind!==`unblock`&&e.kind!==`promote`&&e.kind!==`reclaim`&&e.kind!==`reassign`&&e.kind!==`add_proof`&&e.kind!==`open_session`||typeof e.label!=`string`?null:{kind:e.kind,label:e.label}}function E(){return(E=e((()=>{})))()}function D(e){return v(h([e,N])).transform(e=>e.filter(e=>e!==null)).optional().catch(void 0)}function O(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function ie(e){let t=P.safeParse(e);return t.success?t.data:void 0}function ae(e){let t=D(F).safeParse(e);return t.success?t.data??[]:[]}function k(e){let t=J.safeParse(e);return t.success?t.data:void 0}var A,j,M,N,P,F,I,L,R,z,B,V,H,U,W,G,K,q,J;function Y(){return(Y=e((()=>{y(),E(),d(),A=g().optional().catch(void 0),j=_().optional().catch(void 0),M=g().transform(e=>e.trim()).pipe(g().min(1)),N=m().transform(()=>null),P=x({id:M,engine:A.transform(e=>e?.trim()||void 0),mode:b(u),status:b(i).catch(`idle`),model:A.transform(e=>e?.trim()||void 0),sessionKey:A,runId:A,startedAt:_().refine(e=>e!==0),updatedAt:j}).transform(e=>({id:e.id,kind:`agent-session`,mode:e.mode,status:e.status,startedAt:e.startedAt,updatedAt:e.updatedAt??e.startedAt,...e.engine?{engine:e.engine}:{},...e.model?{model:e.model}:{},...e.sessionKey===void 0?{}:{sessionKey:e.sessionKey},...e.runId===void 0?{}:{runId:e.runId}})),F=x({id:M,kind:b(a),at:_().finite().refine(e=>e!==0),fromStatus:b(t).optional().catch(void 0),toStatus:b(t).optional().catch(void 0),sessionKey:A,runId:A}).transform(O),I=x({id:g(),status:b(r).catch(`running`),startedAt:_(),endedAt:j,engine:A.transform(e=>e?.trim()||void 0),mode:b(u).optional().catch(void 0),model:A,sessionKey:A,runId:A,error:A}).transform(O),L=x({id:g(),body:g(),createdAt:_(),updatedAt:j}).transform(O),R=x({id:g(),type:b(ee).catch(`relates_to`),createdAt:_(),targetCardId:A,title:A,url:A}).transform(O),z=x({id:g(),status:b(o).catch(`unknown`),createdAt:_(),label:A,command:A,url:A,note:A}).transform(O),B=x({id:g(),createdAt:_(),label:A,url:A,path:A,mimeType:A}).transform(O),V=x({id:g(),cardId:g(),fileName:g(),byteSize:_(),createdAt:_(),mimeType:A,note:A}).transform(O),H=x({id:g(),level:b([`info`,`warning`,`error`]).catch(`info`),message:g(),createdAt:_(),sessionKey:A,runId:A}).transform(O),U=x({state:b([`idle`,`running`,`completed`,`blocked`,`violated`]),updatedAt:_().catch(()=>Date.now()),detail:A}).transform(O).optional().catch(void 0),W=x({ownerId:g(),token:g(),claimedAt:_(),lastHeartbeatAt:_(),expiresAt:j}).transform(O).optional().catch(void 0),G=x({kind:b(s),severity:b(n),title:g(),detail:A,firstSeenAt:j,lastSeenAt:j,count:j,actions:v(m()).transform(e=>e.map(T).filter(e=>e!==null)).optional().catch(void 0)}).transform(e=>({kind:e.kind,severity:e.severity,title:e.title,detail:e.detail??e.title,firstSeenAt:e.firstSeenAt??Date.now(),lastSeenAt:e.lastSeenAt??Date.now(),count:e.count??1,actions:e.actions??[]})),K=x({id:g(),kind:b(c),message:g(),createdAt:_(),sequence:j,sessionKey:A,runId:A}).transform(O),q=x({detectedAt:j,lastSessionUpdatedAt:j,reason:A}).transform(e=>({detectedAt:e.detectedAt??Date.now(),...e.lastSessionUpdatedAt===void 0?{}:{lastSessionUpdatedAt:e.lastSessionUpdatedAt},reason:e.reason??`Session has not reported recent activity.`})).optional().catch(void 0),J=x({attempts:D(I),comments:D(L),links:D(R),proof:D(z),artifacts:D(B),attachments:D(V),workerLogs:D(H),workerProtocol:U,automation:m().transform(w).optional(),claim:W,diagnostics:D(G),notifications:D(K),templateId:b(ne).optional().catch(void 0),archivedAt:j,stale:q,lifecycleStatusSourceUpdatedAt:_().finite().transform(e=>Math.max(0,Math.trunc(e))).optional().catch(void 0),failureCount:j}).transform(e=>{let t={...e.attempts?.length?{attempts:e.attempts}:{},...e.comments?.length?{comments:e.comments}:{},...e.links?.length?{links:e.links}:{},...e.proof?.length?{proof:e.proof}:{},...e.artifacts?.length?{artifacts:e.artifacts}:{},...e.attachments?.length?{attachments:e.attachments}:{},...e.workerLogs?.length?{workerLogs:e.workerLogs}:{},...e.workerProtocol?{workerProtocol:e.workerProtocol}:{},...e.automation?{automation:e.automation}:{},...e.claim?{claim:e.claim}:{},...e.diagnostics?.length?{diagnostics:e.diagnostics}:{},...e.notifications?.length?{notifications:e.notifications}:{},...e.templateId?{templateId:e.templateId}:{},...e.archivedAt===void 0?{}:{archivedAt:e.archivedAt},...e.stale?{stale:e.stale}:{},...e.lifecycleStatusSourceUpdatedAt===void 0?{}:{lifecycleStatusSourceUpdatedAt:e.lifecycleStatusSourceUpdatedAt},...e.failureCount===void 0?{}:{failureCount:e.failureCount}};return Object.keys(t).length?t:void 0})})))()}function X(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.trunc(e):0}function Z(e){if(!f(e))return null;let n=typeof e.id==`string`?e.id.trim():``;if(!l(n))return null;let r={};if(f(e.byStatus))for(let n of t)e.byStatus[n]!==void 0&&(r[n]=X(e.byStatus[n]));let i=typeof e.automationJobId==`string`?e.automationJobId.trim():``;return{id:n,total:X(e.total),active:X(e.active),archived:X(e.archived),byStatus:r,...typeof e.name==`string`&&e.name.trim()?{name:e.name.trim()}:{},...typeof e.description==`string`&&e.description.trim()?{description:e.description.trim()}:{},...typeof e.icon==`string`&&e.icon.trim()?{icon:e.icon.trim()}:{},...typeof e.color==`string`&&e.color.trim()?{color:e.color.trim()}:{},...i&&i.length<=128?{automationJobId:i}:{},...typeof e.updatedAt==`number`?{updatedAt:e.updatedAt}:{},...typeof e.archivedAt==`number`?{archivedAt:e.archivedAt}:{}}}function Q(e){if(!f(e))return null;let n=typeof e.id==`string`?e.id:``,r=typeof e.title==`string`?e.title:``,i=t.includes(e.status)?e.status:`todo`,a=te.includes(e.priority)?e.priority:`normal`;if(!n||!r)return null;let o=ie(e.execution),s=ae(e.events),c=k(e.metadata);return{id:n,title:r,status:i,priority:a,labels:Array.isArray(e.labels)?e.labels.filter(e=>typeof e==`string`):[],position:typeof e.position==`number`?e.position:0,createdAt:typeof e.createdAt==`number`?e.createdAt:0,updatedAt:typeof e.updatedAt==`number`?e.updatedAt:0,...typeof e.notes==`string`?{notes:e.notes}:{},...typeof e.agentId==`string`?{agentId:e.agentId}:{},...typeof e.sessionKey==`string`?{sessionKey:e.sessionKey}:{},...typeof e.runId==`string`?{runId:e.runId}:{},...typeof e.taskId==`string`?{taskId:e.taskId}:{},...typeof e.sourceUrl==`string`?{sourceUrl:e.sourceUrl}:{},...o?{execution:o}:{},...typeof e.startedAt==`number`?{startedAt:e.startedAt}:{},...typeof e.completedAt==`number`?{completedAt:e.completedAt}:{},...s.length?{events:s}:{},...c?{metadata:c}:{}}}function oe(e){if(!f(e))return{cards:[],boards:[],statuses:t};let n=Array.isArray(e.cards)?e.cards.map(Q).filter(e=>e!==null):[],r=Array.isArray(e.statuses)?e.statuses.filter(e=>t.includes(e)):t;return{cards:n,boards:Array.isArray(e.boards)?e.boards.map(Z).filter(e=>e!==null):[],statuses:r.length?r:t}}function se(e){return!f(e)||!Array.isArray(e.boards)?null:e.boards.map(Z).filter(e=>e!==null)}function ce(e){let t=f(e)?Q(e.card):null;if(!t)throw Error(`workboard response did not include a card`);return t}function le(e){return!f(e)||!Array.isArray(e.tasks)?{tasks:[],nextCursor:null}:{tasks:e.tasks.map(re).filter(e=>e!==null),nextCursor:typeof e.nextCursor==`string`&&e.nextCursor.trim()?e.nextCursor.trim():null}}function $(){return($=e((()=>{p(),Y(),d()})))()}export{le as a,oe as i,se as n,ce as r,$ as t};
//# sourceMappingURL=normalization-m-N_6hXH.js.map