onboardconnect-agent 1.2.8 → 1.2.9
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/package.json
CHANGED
|
@@ -44,7 +44,7 @@ Error generating stack: `+o.message+`
|
|
|
44
44
|
text-sm text-slate-300 hover:text-slate-100 hover:border-oc-navy-500
|
|
45
45
|
transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:[l&&u.jsx("span",{className:"oc-spinner",style:{width:12,height:12}}),i.paused?"Resume":"Pause"]}),!i.connected&&u.jsxs("button",{onClick:C,disabled:d||!i.configured,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-oc-navy-600
|
|
46
46
|
text-sm text-slate-300 hover:text-slate-100 hover:border-oc-navy-500
|
|
47
|
-
transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:[d&&u.jsx("span",{className:"oc-spinner",style:{width:12,height:12}}),"Reconnect"]})]})}function ii({label:i,value:l,mono:a=!1,accent:d=!1}){const p=!!l;return u.jsxs("div",{className:"flex items-start gap-3 py-3 border-b border-oc-navy-700 last:border-0",children:[u.jsx("p",{className:"w-32 flex-shrink-0 text-xs font-medium text-slate-500 pt-0.5",children:i}),u.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1",children:[u.jsx("span",{className:ce("text-sm break-all",a&&"font-mono",!p&&"text-slate-600 italic",p&&d&&"text-teal-300",p&&!d&&"text-slate-200"),children:l||"—"}),p&&u.jsx(D0,{value:l})]})]})}function U0({status:i}){return i?u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-lg font-bold text-slate-100 mb-1",children:"Agent Status"}),u.jsx(F0,{status:i})]}),u.jsx(z0,{status:i})]}),!i.configured&&u.jsx(A0,{}),i.configured&&!i.canRun&&u.jsx(I0,{reason:i.runBlockedReason}),u.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[u.jsxs(li,{label:"Connection",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[u.jsx("span",{className:ce("w-2.5 h-2.5 rounded-full flex-shrink-0",i.configured?i.canRun?i.paused?"bg-yellow-400 oc-pulse-dot":i.connected?"bg-green-400 oc-pulse-dot":"bg-slate-600":"bg-red-500":"bg-amber-400")}),u.jsx("span",{className:ce("text-lg font-bold",i.configured?i.canRun?i.paused?"text-yellow-300":i.connected?"text-green-400":"text-slate-400":"text-red-400":"text-amber-300"),children:i.configured?i.canRun?i.paused?"Paused":i.connected?"Connected":"Disconnected":"Blocked":"Setup Required"})]}),i.reconnectAttempts>0&&u.jsxs("p",{className:"text-xs text-yellow-500",children:[i.reconnectAttempts," reconnect attempt",i.reconnectAttempts!==1?"s":""]})]}),u.jsxs(li,{label:"Last Heartbeat",children:[u.jsx("p",{className:"text-xl font-bold text-slate-100",children:b0(i.lastHeartbeatAt)}),i.lastHeartbeatAt&&u.jsx("p",{className:"text-xs text-slate-500 mt-1 font-mono",children:new Date(i.lastHeartbeatAt).toLocaleTimeString()})]}),u.jsxs(li,{label:"Uptime",children:[u.jsx("p",{className:"text-xl font-bold text-slate-100",children:T0(i.uptimeSeconds)}),u.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"since last restart"})]}),u.jsxs(li,{label:"Pending Commands",children:[u.jsx("p",{className:ce("text-xl font-bold",i.pendingCount>0?"text-violet-400":"text-slate-100"),children:i.pendingCount}),u.jsx("p",{className:"text-xs text-slate-500 mt-1",children:i.pendingCount===1?"command queued":"commands queued"})]})]}),u.jsxs("div",{className:"bg-oc-navy-800 border border-oc-navy-700 rounded-xl overflow-hidden",children:[u.jsxs("div",{className:"px-6 py-4 border-b border-oc-navy-700",children:[u.jsx("h2",{className:"text-sm font-bold text-slate-200",children:"Agent Info"}),u.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Tenant association cannot be changed after registration."})]}),u.jsxs("div",{className:"px-6",children:[u.jsx(ii,{label:"Connection ID",value:i.connectionId,mono:!0,accent:!0}),u.jsx(ii,{label:"Agent ID",value:i.agentId,mono:!0}),u.jsx(ii,{label:"Tenant ID",value:i.tenantId,mono:!0}),u.jsx(ii,{label:"Relay URL",value:i.relayUrl,mono:!0})]})]}),u.jsxs("div",{className:"bg-oc-navy-800 border border-oc-navy-700 rounded-xl p-6",children:[u.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider mb-4",children:"System Info"}),u.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-x-6 gap-y-4",children:[{label:"Version",value:i.version},{label:"Platform",value:i.platform},{label:"Hostname",value:i.hostname},{label:"Arch",value:i.arch},{label:"Node.js",value:i.nodeVersion},{label:"Free Memory",value:`${i.freeMemoryMb.toFixed(0)} MB`},{label:"Total Memory",value:`${i.totalMemoryMb.toFixed(0)} MB`}].map(({label:l,value:a})=>u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-slate-500 mb-0.5",children:l}),u.jsx("p",{className:"text-sm text-slate-300 truncate",children:a})]},l))})]})]}):u.jsx("div",{className:"flex items-center justify-center h-64",children:u.jsxs("div",{className:"text-center",children:[u.jsx("span",{className:"oc-spinner"}),u.jsx("p",{className:"text-slate-500 text-sm mt-3",children:"Connecting to agent stream"})]})})}function Fs(i){return i.split("_").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")}function Q0(i){return i==null?"—":i<1?"<1ms":i<1e3?`${i}ms`:`${(i/1e3).toFixed(1)}s`}function B0(i){return new Date(i).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}const rf={error:0,pending:1,skipped:2,success:3};function H0(i,l,a){switch(a){case"time":return new Date(i.receivedAt).getTime()-new Date(l.receivedAt).getTime();case"command":return Fs(i.commandType).localeCompare(Fs(l.commandType));case"status":return rf[i.status]-rf[l.status];case"duration":return(i.durationMs??-1)-(l.durationMs??-1)}}const W0=[10,25,50,100];function $0({status:i}){const l={pending:"bg-amber-500/15 text-amber-400 border-amber-500/30",success:"bg-green-500/15 text-green-400 border-green-500/30",error:"bg-red-500/15 text-red-400 border-red-500/30",skipped:"bg-slate-500/15 text-slate-400 border-slate-500/30"};return u.jsx("span",{className:ce("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold border",l[i]),children:i.charAt(0).toUpperCase()+i.slice(1)})}function V0({error:i}){const[l,a]=H.useState(!1);if(!i)return u.jsx("span",{className:"text-slate-600",children:"—"});const d=70,p=i.length>d,y=l?i:i.slice(0,d)+(p?"…":"");return u.jsx("span",{className:ce("text-red-400 text-xs font-mono",p&&"cursor-pointer hover:text-red-300 underline underline-offset-2 decoration-dashed"),onClick:()=>p&&a(S=>!S),title:p&&!l?"Click to expand":void 0,children:y})}function oi({label:i,sortKey:l,active:a,dir:d,onSort:p,className:y}){return u.jsx("th",{className:ce("px-4 py-3 text-left whitespace-nowrap",y),children:u.jsxs("button",{type:"button",onClick:()=>p(l),className:ce("group inline-flex items-center gap-1 text-xs font-semibold uppercase tracking-wider transition-colors",a?"text-slate-200":"text-slate-500 hover:text-slate-300"),title:`Sort by ${i}`,children:[i,u.jsx("span",{className:ce("text-[10px] leading-none",a?"opacity-100":"opacity-0 group-hover:opacity-40"),children:a&&d==="asc"?"▲":"▼"})]})})}function K0(){return u.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center",children:[u.jsx("div",{className:"w-14 h-14 rounded-2xl bg-oc-navy-700 flex items-center justify-center mb-4",children:u.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:"w-7 h-7 text-slate-500",children:u.jsx("path",{d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),u.jsx("p",{className:"text-slate-300 font-semibold text-sm",children:"No commands received yet"}),u.jsx("p",{className:"text-slate-500 text-sm mt-1 max-w-xs",children:"The agent is connected and waiting. Commands dispatched from OnboardConnect will appear here."})]})}function q0({onClear:i}){return u.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[u.jsx("p",{className:"text-slate-300 font-semibold text-sm",children:"No commands match your filters"}),u.jsx("button",{type:"button",onClick:i,className:"mt-3 text-xs font-semibold text-oc-teal-400 hover:opacity-80 underline underline-offset-2",children:"Clear filters"})]})}const ai="h-9 rounded-lg bg-oc-navy-900 border border-oc-navy-700 text-xs text-slate-200 px-3 focus:outline-none focus:ring-2 focus:ring-oc-teal-500/40 focus:border-oc-teal-500/40 placeholder:text-slate-600";function G0(){const i=Kr(),l=Mf(),[a,d]=H.useState(""),[p,y]=H.useState("all"),[S,j]=H.useState("all"),[C,F]=H.useState("time"),[T,L]=H.useState("desc"),[b,U]=H.useState(10),[$,D]=H.useState(1);H.useEffect(()=>{l!==null&&i.invalidateQueries({queryKey:["oc-agent-requests"]})},[l,i]);const{data:O=[],isLoading:ee}=Aa({queryKey:["oc-agent-requests"],queryFn:Pt.requests,refetchInterval:3e4}),ie=H.useMemo(()=>Array.from(new Set(O.map(G=>G.commandType))).sort(),[O]),re=H.useMemo(()=>{const G=a.trim().toLowerCase(),Me=O.filter(be=>!(p!=="all"&&be.status!==p||S!=="all"&&be.commandType!==S||G&&!`${Fs(be.commandType)} ${be.error??""}`.toLowerCase().includes(G))),Ke=T==="asc"?1:-1;return Me.sort((be,Ce)=>H0(be,Ce,C)*Ke)},[O,a,p,S,C,T]),_=re.length,te=Math.max(1,Math.ceil(_/b)),ne=Math.min($,te);H.useEffect(()=>{$>te&&D(te)},[$,te]);const je=H.useMemo(()=>re.slice((ne-1)*b,ne*b),[re,ne,b]),se=a.trim()!==""||p!=="all"||S!=="all",ve=()=>{d(""),y("all"),j("all"),D(1)};function ye(G){G===C?L(Me=>Me==="asc"?"desc":"asc"):(F(G),L(G==="command"?"asc":"desc")),D(1)}if(ee)return u.jsxs("div",{className:"flex items-center justify-center h-48",children:[u.jsx("span",{className:"oc-spinner"}),u.jsx("span",{className:"ml-3 text-slate-500 text-sm",children:"Loading requests"})]});const Qe=_===0?0:(ne-1)*b+1,Ve=Math.min(ne*b,_);return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-lg font-bold text-slate-100",children:"Command History"}),u.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Commands received and executed by this agent. Refreshes every 30s."})]}),O.length>0&&u.jsx("span",{className:"text-xs font-semibold text-slate-400 bg-oc-navy-800 border border-oc-navy-700 px-3 py-1.5 rounded-full",children:se?`${_} of ${O.length}`:`${O.length} ${O.length===1?"entry":"entries"}`})]}),O.length>0&&u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsxs("div",{className:"relative flex-1 min-w-[180px]",children:[u.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:"w-4 h-4 text-slate-500 absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",children:u.jsx("path",{d:"M21 21l-4.3-4.3M11 19a8 8 0 100-16 8 8 0 000 16z",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}),u.jsx("input",{type:"text",value:a,onChange:G=>{d(G.target.value),D(1)},placeholder:"Search command or error…",className:ce(ai,"w-full pl-9")})]}),u.jsxs("select",{value:p,onChange:G=>{y(G.target.value),D(1)},className:ai,"aria-label":"Filter by status",children:[u.jsx("option",{value:"all",children:"All statuses"}),u.jsx("option",{value:"success",children:"Success"}),u.jsx("option",{value:"error",children:"Error"}),u.jsx("option",{value:"pending",children:"Pending"}),u.jsx("option",{value:"skipped",children:"Skipped"})]}),u.jsxs("select",{value:S,onChange:G=>{j(G.target.value),D(1)},className:ai,"aria-label":"Filter by command",children:[u.jsx("option",{value:"all",children:"All commands"}),ie.map(G=>u.jsx("option",{value:G,children:Fs(G)},G))]}),se&&u.jsx("button",{type:"button",onClick:ve,className:"h-9 px-3 rounded-lg text-xs font-semibold text-slate-400 hover:text-slate-200 border border-oc-navy-700 hover:border-oc-navy-600 transition-colors",children:"Clear"})]}),u.jsx("div",{className:"bg-oc-navy-800 border border-oc-navy-700 rounded-xl overflow-hidden",children:O.length===0?u.jsx(K0,{}):_===0?u.jsx(q0,{onClear:ve}):u.jsx("div",{className:"overflow-x-auto",children:u.jsxs("table",{className:"w-full text-sm",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"border-b border-oc-navy-700 bg-oc-navy-900/50",children:[u.jsx(oi,{label:"Time",sortKey:"time",active:C==="time",dir:T,onSort:ye}),u.jsx(oi,{label:"Command",sortKey:"command",active:C==="command",dir:T,onSort:ye}),u.jsx(oi,{label:"Status",sortKey:"status",active:C==="status",dir:T,onSort:ye}),u.jsx(oi,{label:"Duration",sortKey:"duration",active:C==="duration",dir:T,onSort:ye}),u.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider whitespace-nowrap",children:"Dry Run"}),u.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider whitespace-nowrap",children:"Error"})]})}),u.jsx("tbody",{children:je.map((G,Me)=>u.jsxs("tr",{className:ce("border-b border-oc-navy-700/60 last:border-0 transition-colors",Me%2===0?"bg-transparent":"bg-oc-navy-900/20","hover:bg-oc-navy-700/30"),children:[u.jsx("td",{className:"px-4 py-3.5 whitespace-nowrap text-slate-400 text-xs font-mono",children:B0(G.receivedAt)}),u.jsx("td",{className:"px-4 py-3.5 whitespace-nowrap",children:u.jsx("span",{className:"text-slate-200 font-medium",children:Fs(G.commandType)})}),u.jsx("td",{className:"px-4 py-3.5 whitespace-nowrap",children:u.jsx($0,{status:G.status})}),u.jsx("td",{className:"px-4 py-3.5 whitespace-nowrap text-slate-400 text-xs font-mono",children:Q0(G.durationMs)}),u.jsx("td",{className:"px-4 py-3.5 whitespace-nowrap",children:G.dryRun?u.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold bg-slate-500/15 text-slate-400 border border-slate-500/30",children:"Dry Run"}):u.jsx("span",{className:"text-slate-600",children:"—"})}),u.jsx("td",{className:"px-4 py-3.5 max-w-xs",children:u.jsx(V0,{error:G.error})})]},G.id))})]})})}),O.length>0&&_>0&&u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500",children:[u.jsx("span",{children:"Rows per page"}),u.jsx("select",{value:b,onChange:G=>{U(Number(G.target.value)),D(1)},className:ce(ai,"h-7 py-0"),"aria-label":"Rows per page",children:W0.map(G=>u.jsx("option",{value:G,children:G},G))}),u.jsxs("span",{className:"ml-1 text-slate-600",children:[Qe,"–",Ve," of ",_]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{type:"button",onClick:()=>D(G=>Math.max(1,G-1)),disabled:ne<=1,className:"h-8 px-3 rounded-lg text-xs font-semibold border border-oc-navy-700 text-slate-300 hover:border-oc-navy-600 hover:text-slate-100 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:border-oc-navy-700",children:"Prev"}),u.jsxs("span",{className:"text-xs text-slate-500 tabular-nums",children:["Page ",ne," / ",te]}),u.jsx("button",{type:"button",onClick:()=>D(G=>Math.min(te,G+1)),disabled:ne>=te,className:"h-8 px-3 rounded-lg text-xs font-semibold border border-oc-navy-700 text-slate-300 hover:border-oc-navy-600 hover:text-slate-100 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:border-oc-navy-700",children:"Next"})]}),u.jsx("p",{className:"text-xs text-slate-600 w-full text-right sm:w-auto",children:"Live · refreshes every 30 seconds"})]})]})}const Lf=[{label:"User Lifecycle",desc:"Create, modify, and manage user account states in Active Directory.",commands:[{type:"create_user",label:"Create User",desc:"Provision new AD user accounts"},{type:"update_user",label:"Update User",desc:"Modify attributes like display name, email, and department"},{type:"disable_user",label:"Disable User",desc:"Disable an AD account without deleting it"},{type:"activate_user",label:"Activate User",desc:"Re-enable a previously disabled account"},{type:"delete_user",label:"Delete User",desc:"Permanently remove an AD user account",destructive:!0}]},{label:"Passwords",desc:"Set and reset user passwords in Active Directory.",commands:[{type:"set_password",label:"Set Password",desc:"Assign an initial password to a new account"},{type:"reset_password",label:"Reset Password",desc:"Reset a user's existing password"}]},{label:"Directory Queries",desc:"Read-only operations that query Active Directory data.",commands:[{type:"search_users",label:"Search Users",desc:"Search for users matching a filter"},{type:"read_users",label:"Read Users",desc:"Read attribute data for user accounts"},{type:"read_groups",label:"Read Groups",desc:"List and read AD group memberships"},{type:"get_schema",label:"Get Schema",desc:"Read the Active Directory schema definition"},{type:"move_ou",label:"Move OU",desc:"Move user accounts between organizational units"}]},{label:"File I/O",desc:"Read and write files on the local server filesystem.",commands:[{type:"read_file",label:"Read File",desc:"Read CSV files from configured local filesystem paths"},{type:"write_file",label:"Write File",desc:"Write CSV files to configured local filesystem paths"}]}],bs=Lf.flatMap(i=>i.commands.map(l=>l.type));function Z0({on:i,onChange:l}){return u.jsx("button",{type:"button",role:"switch","aria-checked":i,onClick:()=>l(!i),className:ce("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent","transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-teal-500 focus:ring-offset-2 focus:ring-offset-oc-navy-800",i?"bg-teal-600":"bg-oc-navy-600"),children:u.jsx("span",{className:ce("pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow","transition duration-200 ease-in-out",i?"translate-x-4":"translate-x-0")})})}function Tf({title:i,description:l,badge:a}){return u.jsxs("div",{className:"px-6 py-5 border-b border-oc-navy-700 flex items-start justify-between gap-4",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-bold text-slate-200",children:i}),u.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:l})]}),a]})}function pa({label:i,result:l}){return u.jsxs("div",{className:"flex items-start gap-4 px-5 py-4 border-b border-oc-navy-700 last:border-0",children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-sm font-medium text-slate-300",children:i}),(l==null?void 0:l.path)&&u.jsx("p",{className:"text-xs font-mono text-slate-500 truncate mt-0.5",children:l.path}),l&&!l.ok&&l.error&&u.jsx("p",{className:"text-xs text-red-400 mt-1",children:l.error}),(l==null?void 0:l.ok)&&l.latencyMs!==void 0&&u.jsxs("p",{className:"text-xs text-green-400 mt-0.5",children:[l.latencyMs,"ms"]})]}),u.jsx("div",{className:"flex-shrink-0 mt-0.5",children:l===null?u.jsx("span",{className:"text-xs text-slate-600",children:"Not run"}):l.ok?u.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold text-green-400 bg-green-500/10 border border-green-500/20 px-2 py-0.5 rounded-full",children:[u.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-3.5 w-3.5",children:u.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z",clipRule:"evenodd"})}),"OK"]}):u.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold text-red-400 bg-red-500/10 border border-red-500/20 px-2 py-0.5 rounded-full",children:[u.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-3.5 w-3.5",children:u.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z",clipRule:"evenodd"})}),"Failed"]})})]})}function Y0(){const[i,l]=H.useState(null),[a,d]=H.useState(!1),[p,y]=H.useState(null);async function S(){d(!0),y(null);try{const C=await Pt.checkAccess();l(C)}catch(C){y(C instanceof Error?C.message:"Check failed")}finally{d(!1)}}const j=i?i.fileRead.ok&&i.fileWrite.ok&&i.adAccess.ok:null;return u.jsxs("div",{className:"bg-oc-navy-800 border border-oc-navy-700 rounded-xl overflow-hidden",children:[u.jsx(Tf,{title:"Access Check",description:"Verify the Windows service account has permission to read/write file paths and connect to Active Directory.",badge:j!==null?u.jsx("span",{className:ce("flex-shrink-0 text-xs font-semibold px-2.5 py-1 rounded-full border",j?"text-green-400 bg-green-500/10 border-green-500/20":"text-red-400 bg-red-500/10 border-red-500/20"),children:j?"All checks passed":"Issues found"}):void 0}),i&&u.jsx("div",{className:"px-5 pt-4",children:u.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 rounded-xl bg-oc-navy-900 border border-oc-navy-700",children:[u.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wide",children:"Running as"}),u.jsx("p",{className:"text-sm font-mono text-teal-300 ml-1",children:i.serviceUser})]})}),u.jsxs("div",{className:ce("divide-y-0",i?"mt-3":""),children:[u.jsx(pa,{label:"File Read Path",result:i?i.fileRead:null}),u.jsx(pa,{label:"File Write Path",result:i?i.fileWrite:null}),u.jsx(pa,{label:"Active Directory (LDAP)",result:i?i.adAccess:null})]}),p&&u.jsx("div",{className:"mx-5 mb-4 px-4 py-3 rounded-xl text-sm border bg-red-500/10 border-red-500/30 text-red-400",children:p}),u.jsxs("div",{className:"px-5 py-5 flex items-center gap-3 border-t border-oc-navy-700",children:[u.jsxs("button",{onClick:S,disabled:a,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl bg-teal-600 hover:bg-teal-500
|
|
47
|
+
transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:[d&&u.jsx("span",{className:"oc-spinner",style:{width:12,height:12}}),"Reconnect"]})]})}function ii({label:i,value:l,mono:a=!1,accent:d=!1}){const p=!!l;return u.jsxs("div",{className:"flex items-start gap-3 py-3 border-b border-oc-navy-700 last:border-0",children:[u.jsx("p",{className:"w-32 flex-shrink-0 text-xs font-medium text-slate-500 pt-0.5",children:i}),u.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1",children:[u.jsx("span",{className:ce("text-sm break-all",a&&"font-mono",!p&&"text-slate-600 italic",p&&d&&"text-teal-300",p&&!d&&"text-slate-200"),children:l||"—"}),p&&u.jsx(D0,{value:l})]})]})}function U0({status:i}){return i?u.jsxs("div",{className:"space-y-6",children:[u.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-lg font-bold text-slate-100 mb-1",children:"Agent Status"}),u.jsx(F0,{status:i})]}),u.jsx(z0,{status:i})]}),!i.configured&&u.jsx(A0,{}),i.configured&&!i.canRun&&u.jsx(I0,{reason:i.runBlockedReason}),u.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[u.jsxs(li,{label:"Connection",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[u.jsx("span",{className:ce("w-2.5 h-2.5 rounded-full flex-shrink-0",i.configured?i.canRun?i.paused?"bg-yellow-400 oc-pulse-dot":i.connected?"bg-green-400 oc-pulse-dot":"bg-slate-600":"bg-red-500":"bg-amber-400")}),u.jsx("span",{className:ce("text-lg font-bold",i.configured?i.canRun?i.paused?"text-yellow-300":i.connected?"text-green-400":"text-slate-400":"text-red-400":"text-amber-300"),children:i.configured?i.canRun?i.paused?"Paused":i.connected?"Connected":"Disconnected":"Blocked":"Setup Required"})]}),i.reconnectAttempts>0&&u.jsxs("p",{className:"text-xs text-yellow-500",children:[i.reconnectAttempts," reconnect attempt",i.reconnectAttempts!==1?"s":""]})]}),u.jsxs(li,{label:"Last Heartbeat",children:[u.jsx("p",{className:"text-xl font-bold text-slate-100",children:b0(i.lastHeartbeatAt)}),i.lastHeartbeatAt&&u.jsx("p",{className:"text-xs text-slate-500 mt-1 font-mono",children:new Date(i.lastHeartbeatAt).toLocaleTimeString()})]}),u.jsxs(li,{label:"Uptime",children:[u.jsx("p",{className:"text-xl font-bold text-slate-100",children:T0(i.uptimeSeconds)}),u.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"since last restart"})]}),u.jsxs(li,{label:"Pending Commands",children:[u.jsx("p",{className:ce("text-xl font-bold",i.pendingCount>0?"text-violet-400":"text-slate-100"),children:i.pendingCount}),u.jsx("p",{className:"text-xs text-slate-500 mt-1",children:i.pendingCount===1?"command queued":"commands queued"})]})]}),u.jsxs("div",{className:"bg-oc-navy-800 border border-oc-navy-700 rounded-xl overflow-hidden",children:[u.jsxs("div",{className:"px-6 py-4 border-b border-oc-navy-700",children:[u.jsx("h2",{className:"text-sm font-bold text-slate-200",children:"Agent Info"}),u.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Tenant association cannot be changed after registration."})]}),u.jsxs("div",{className:"px-6",children:[u.jsx(ii,{label:"Connection ID",value:i.connectionId,mono:!0,accent:!0}),u.jsx(ii,{label:"Agent ID",value:i.agentId,mono:!0}),u.jsx(ii,{label:"Tenant ID",value:i.tenantId,mono:!0}),u.jsx(ii,{label:"Relay URL",value:i.relayUrl,mono:!0})]})]}),u.jsxs("div",{className:"bg-oc-navy-800 border border-oc-navy-700 rounded-xl p-6",children:[u.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider mb-4",children:"System Info"}),u.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-x-6 gap-y-4",children:[{label:"Version",value:i.version},{label:"Platform",value:i.platform},{label:"Hostname",value:i.hostname},{label:"Arch",value:i.arch},{label:"Node.js",value:i.nodeVersion},{label:"Free Memory",value:`${i.freeMemoryMb.toFixed(0)} MB`},{label:"Total Memory",value:`${i.totalMemoryMb.toFixed(0)} MB`}].map(({label:l,value:a})=>u.jsxs("div",{children:[u.jsx("p",{className:"text-xs text-slate-500 mb-0.5",children:l}),u.jsx("p",{className:"text-sm text-slate-300 truncate",children:a})]},l))})]})]}):u.jsx("div",{className:"flex items-center justify-center h-64",children:u.jsxs("div",{className:"text-center",children:[u.jsx("span",{className:"oc-spinner"}),u.jsx("p",{className:"text-slate-500 text-sm mt-3",children:"Connecting to agent stream"})]})})}function Fs(i){return i.split("_").map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")}function Q0(i){return i==null?"—":i<1?"<1ms":i<1e3?`${i}ms`:`${(i/1e3).toFixed(1)}s`}function B0(i){return new Date(i).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}const rf={error:0,pending:1,skipped:2,success:3};function H0(i,l,a){switch(a){case"time":return new Date(i.receivedAt).getTime()-new Date(l.receivedAt).getTime();case"command":return Fs(i.commandType).localeCompare(Fs(l.commandType));case"status":return rf[i.status]-rf[l.status];case"duration":return(i.durationMs??-1)-(l.durationMs??-1)}}const W0=[10,25,50,100];function $0({status:i}){const l={pending:"bg-amber-500/15 text-amber-400 border-amber-500/30",success:"bg-green-500/15 text-green-400 border-green-500/30",error:"bg-red-500/15 text-red-400 border-red-500/30",skipped:"bg-slate-500/15 text-slate-400 border-slate-500/30"};return u.jsx("span",{className:ce("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold border",l[i]),children:i.charAt(0).toUpperCase()+i.slice(1)})}function V0({error:i}){const[l,a]=H.useState(!1);if(!i)return u.jsx("span",{className:"text-slate-600",children:"—"});const d=70,p=i.length>d,y=l?i:i.slice(0,d)+(p?"…":"");return u.jsx("span",{className:ce("text-red-400 text-xs font-mono",p&&"cursor-pointer hover:text-red-300 underline underline-offset-2 decoration-dashed"),onClick:()=>p&&a(S=>!S),title:p&&!l?"Click to expand":void 0,children:y})}function oi({label:i,sortKey:l,active:a,dir:d,onSort:p,className:y}){return u.jsx("th",{className:ce("px-4 py-3 text-left whitespace-nowrap",y),children:u.jsxs("button",{type:"button",onClick:()=>p(l),className:ce("group inline-flex items-center gap-1 text-xs font-semibold uppercase tracking-wider transition-colors",a?"text-slate-200":"text-slate-500 hover:text-slate-300"),title:`Sort by ${i}`,children:[i,u.jsx("span",{className:ce("text-[10px] leading-none",a?"opacity-100":"opacity-0 group-hover:opacity-40"),children:a&&d==="asc"?"▲":"▼"})]})})}function K0(){return u.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center",children:[u.jsx("div",{className:"w-14 h-14 rounded-2xl bg-oc-navy-700 flex items-center justify-center mb-4",children:u.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:"w-7 h-7 text-slate-500",children:u.jsx("path",{d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),u.jsx("p",{className:"text-slate-300 font-semibold text-sm",children:"No commands received yet"}),u.jsx("p",{className:"text-slate-500 text-sm mt-1 max-w-xs",children:"The agent is connected and waiting. Commands dispatched from OnboardConnect will appear here."})]})}function q0({onClear:i}){return u.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[u.jsx("p",{className:"text-slate-300 font-semibold text-sm",children:"No commands match your filters"}),u.jsx("button",{type:"button",onClick:i,className:"mt-3 text-xs font-semibold text-oc-teal-400 hover:opacity-80 underline underline-offset-2",children:"Clear filters"})]})}const ai="h-9 rounded-lg bg-oc-navy-900 border border-oc-navy-700 text-xs text-slate-200 px-3 focus:outline-none focus:ring-2 focus:ring-oc-teal-500/40 focus:border-oc-teal-500/40 placeholder:text-slate-600";function G0(){const i=Kr(),l=Mf(),[a,d]=H.useState(""),[p,y]=H.useState("all"),[S,j]=H.useState("all"),[C,F]=H.useState("time"),[T,L]=H.useState("desc"),[b,U]=H.useState(10),[$,D]=H.useState(1);H.useEffect(()=>{l!==null&&i.invalidateQueries({queryKey:["oc-agent-requests"]})},[l,i]);const{data:O=[],isLoading:ee}=Aa({queryKey:["oc-agent-requests"],queryFn:Pt.requests,refetchInterval:3e4}),ie=H.useMemo(()=>Array.from(new Set(O.map(G=>G.commandType))).sort(),[O]),re=H.useMemo(()=>{const G=a.trim().toLowerCase(),Me=O.filter(be=>!(p!=="all"&&be.status!==p||S!=="all"&&be.commandType!==S||G&&!`${Fs(be.commandType)} ${be.error??""}`.toLowerCase().includes(G))),Ke=T==="asc"?1:-1;return Me.sort((be,Ce)=>H0(be,Ce,C)*Ke)},[O,a,p,S,C,T]),_=re.length,te=Math.max(1,Math.ceil(_/b)),ne=Math.min($,te);H.useEffect(()=>{$>te&&D(te)},[$,te]);const je=H.useMemo(()=>re.slice((ne-1)*b,ne*b),[re,ne,b]),se=a.trim()!==""||p!=="all"||S!=="all",ve=()=>{d(""),y("all"),j("all"),D(1)};function ye(G){G===C?L(Me=>Me==="asc"?"desc":"asc"):(F(G),L(G==="command"?"asc":"desc")),D(1)}if(ee)return u.jsxs("div",{className:"flex items-center justify-center h-48",children:[u.jsx("span",{className:"oc-spinner"}),u.jsx("span",{className:"ml-3 text-slate-500 text-sm",children:"Loading requests"})]});const Qe=_===0?0:(ne-1)*b+1,Ve=Math.min(ne*b,_);return u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-lg font-bold text-slate-100",children:"Command History"}),u.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Commands received and executed by this agent. Refreshes every 30s."})]}),O.length>0&&u.jsx("span",{className:"text-xs font-semibold text-slate-400 bg-oc-navy-800 border border-oc-navy-700 px-3 py-1.5 rounded-full",children:se?`${_} of ${O.length}`:`${O.length} ${O.length===1?"entry":"entries"}`})]}),O.length>0&&u.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.jsxs("div",{className:"relative flex-1 min-w-[180px]",children:[u.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:"w-4 h-4 text-slate-500 absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",children:u.jsx("path",{d:"M21 21l-4.3-4.3M11 19a8 8 0 100-16 8 8 0 000 16z",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}),u.jsx("input",{type:"text",value:a,onChange:G=>{d(G.target.value),D(1)},placeholder:"Search command or error…",className:ce(ai,"w-full pl-9")})]}),u.jsxs("select",{value:p,onChange:G=>{y(G.target.value),D(1)},className:ai,"aria-label":"Filter by status",children:[u.jsx("option",{value:"all",children:"All statuses"}),u.jsx("option",{value:"success",children:"Success"}),u.jsx("option",{value:"error",children:"Error"}),u.jsx("option",{value:"pending",children:"Pending"}),u.jsx("option",{value:"skipped",children:"Skipped"})]}),u.jsxs("select",{value:S,onChange:G=>{j(G.target.value),D(1)},className:ai,"aria-label":"Filter by command",children:[u.jsx("option",{value:"all",children:"All commands"}),ie.map(G=>u.jsx("option",{value:G,children:Fs(G)},G))]}),se&&u.jsx("button",{type:"button",onClick:ve,className:"h-9 px-3 rounded-lg text-xs font-semibold text-slate-400 hover:text-slate-200 border border-oc-navy-700 hover:border-oc-navy-600 transition-colors",children:"Clear"})]}),u.jsx("div",{className:"bg-oc-navy-800 border border-oc-navy-700 rounded-xl overflow-hidden",children:O.length===0?u.jsx(K0,{}):_===0?u.jsx(q0,{onClear:ve}):u.jsx("div",{className:"overflow-x-auto",children:u.jsxs("table",{className:"w-full text-sm",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"border-b border-oc-navy-700 bg-oc-navy-900/50",children:[u.jsx(oi,{label:"Time",sortKey:"time",active:C==="time",dir:T,onSort:ye}),u.jsx(oi,{label:"Command",sortKey:"command",active:C==="command",dir:T,onSort:ye}),u.jsx(oi,{label:"Status",sortKey:"status",active:C==="status",dir:T,onSort:ye}),u.jsx(oi,{label:"Duration",sortKey:"duration",active:C==="duration",dir:T,onSort:ye}),u.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider whitespace-nowrap",children:"Dry Run"}),u.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider whitespace-nowrap",children:"Error"})]})}),u.jsx("tbody",{children:je.map((G,Me)=>u.jsxs("tr",{className:ce("border-b border-oc-navy-700/60 last:border-0 transition-colors",Me%2===0?"bg-transparent":"bg-oc-navy-900/20","hover:bg-oc-navy-700/30"),children:[u.jsx("td",{className:"px-4 py-3.5 whitespace-nowrap text-slate-400 text-xs font-mono",children:B0(G.receivedAt)}),u.jsx("td",{className:"px-4 py-3.5 whitespace-nowrap",children:u.jsx("span",{className:"text-slate-200 font-medium",children:Fs(G.commandType)})}),u.jsx("td",{className:"px-4 py-3.5 whitespace-nowrap",children:u.jsx($0,{status:G.status})}),u.jsx("td",{className:"px-4 py-3.5 whitespace-nowrap text-slate-400 text-xs font-mono",children:Q0(G.durationMs)}),u.jsx("td",{className:"px-4 py-3.5 whitespace-nowrap",children:G.dryRun?u.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold bg-slate-500/15 text-slate-400 border border-slate-500/30",children:"Dry Run"}):u.jsx("span",{className:"text-slate-600",children:"—"})}),u.jsx("td",{className:"px-4 py-3.5 max-w-xs",children:u.jsx(V0,{error:G.error})})]},G.id))})]})})}),O.length>0&&_>0&&u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500",children:[u.jsx("span",{children:"Rows per page"}),u.jsx("select",{value:b,onChange:G=>{U(Number(G.target.value)),D(1)},className:ce(ai,"h-7 py-0"),"aria-label":"Rows per page",children:W0.map(G=>u.jsx("option",{value:G,children:G},G))}),u.jsxs("span",{className:"ml-1 text-slate-600",children:[Qe,"–",Ve," of ",_]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{type:"button",onClick:()=>D(G=>Math.max(1,G-1)),disabled:ne<=1,className:"h-8 px-3 rounded-lg text-xs font-semibold border border-oc-navy-700 text-slate-300 hover:border-oc-navy-600 hover:text-slate-100 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:border-oc-navy-700",children:"Prev"}),u.jsxs("span",{className:"text-xs text-slate-500 tabular-nums",children:["Page ",ne," / ",te]}),u.jsx("button",{type:"button",onClick:()=>D(G=>Math.min(te,G+1)),disabled:ne>=te,className:"h-8 px-3 rounded-lg text-xs font-semibold border border-oc-navy-700 text-slate-300 hover:border-oc-navy-600 hover:text-slate-100 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:border-oc-navy-700",children:"Next"})]}),u.jsx("p",{className:"text-xs text-slate-600 w-full text-right sm:w-auto",children:"Live · refreshes every 30 seconds"})]})]})}const Lf=[{label:"User Lifecycle",desc:"Create, modify, and manage user account states in Active Directory.",commands:[{type:"create_user",label:"Create User",desc:"Provision new AD user accounts"},{type:"update_user",label:"Update User",desc:"Modify attributes like display name, email, and department"},{type:"disable_user",label:"Disable User",desc:"Disable an AD account without deleting it"},{type:"activate_user",label:"Activate User",desc:"Re-enable a previously disabled account"},{type:"delete_user",label:"Delete User",desc:"Permanently remove an AD user account",destructive:!0}]},{label:"Passwords",desc:"Set and reset user passwords in Active Directory.",commands:[{type:"set_password",label:"Set Password",desc:"Assign an initial password to a new account"},{type:"reset_password",label:"Reset Password",desc:"Reset a user's existing password"}]},{label:"Group Membership",desc:"Manage security group and distribution list memberships in Active Directory.",commands:[{type:"set_securitygroups",label:"Security Groups",desc:"Add or replace a user's AD security group memberships"},{type:"set_distributionlists",label:"Distribution Lists",desc:"Add or replace a user's AD distribution list memberships"}]},{label:"Directory Queries",desc:"Read-only operations that query Active Directory data.",commands:[{type:"search_users",label:"Search Users",desc:"Search for users matching a filter"},{type:"read_users",label:"Read Users",desc:"Read attribute data for user accounts"},{type:"read_groups",label:"Read Groups",desc:"List and read AD group memberships"},{type:"get_schema",label:"Get Schema",desc:"Read the Active Directory schema definition"},{type:"move_ou",label:"Move OU",desc:"Move user accounts between organizational units"}]},{label:"File I/O",desc:"Read and write files on the local server filesystem.",commands:[{type:"read_file",label:"Read File",desc:"Read CSV files from configured local filesystem paths"},{type:"write_file",label:"Write File",desc:"Write CSV files to configured local filesystem paths"}]}],bs=Lf.flatMap(i=>i.commands.map(l=>l.type));function Z0({on:i,onChange:l}){return u.jsx("button",{type:"button",role:"switch","aria-checked":i,onClick:()=>l(!i),className:ce("relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent","transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-teal-500 focus:ring-offset-2 focus:ring-offset-oc-navy-800",i?"bg-teal-600":"bg-oc-navy-600"),children:u.jsx("span",{className:ce("pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow","transition duration-200 ease-in-out",i?"translate-x-4":"translate-x-0")})})}function Tf({title:i,description:l,badge:a}){return u.jsxs("div",{className:"px-6 py-5 border-b border-oc-navy-700 flex items-start justify-between gap-4",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-bold text-slate-200",children:i}),u.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:l})]}),a]})}function pa({label:i,result:l}){return u.jsxs("div",{className:"flex items-start gap-4 px-5 py-4 border-b border-oc-navy-700 last:border-0",children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-sm font-medium text-slate-300",children:i}),(l==null?void 0:l.path)&&u.jsx("p",{className:"text-xs font-mono text-slate-500 truncate mt-0.5",children:l.path}),l&&!l.ok&&l.error&&u.jsx("p",{className:"text-xs text-red-400 mt-1",children:l.error}),(l==null?void 0:l.ok)&&l.latencyMs!==void 0&&u.jsxs("p",{className:"text-xs text-green-400 mt-0.5",children:[l.latencyMs,"ms"]})]}),u.jsx("div",{className:"flex-shrink-0 mt-0.5",children:l===null?u.jsx("span",{className:"text-xs text-slate-600",children:"Not run"}):l.ok?u.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold text-green-400 bg-green-500/10 border border-green-500/20 px-2 py-0.5 rounded-full",children:[u.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-3.5 w-3.5",children:u.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z",clipRule:"evenodd"})}),"OK"]}):u.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold text-red-400 bg-red-500/10 border border-red-500/20 px-2 py-0.5 rounded-full",children:[u.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-3.5 w-3.5",children:u.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z",clipRule:"evenodd"})}),"Failed"]})})]})}function Y0(){const[i,l]=H.useState(null),[a,d]=H.useState(!1),[p,y]=H.useState(null);async function S(){d(!0),y(null);try{const C=await Pt.checkAccess();l(C)}catch(C){y(C instanceof Error?C.message:"Check failed")}finally{d(!1)}}const j=i?i.fileRead.ok&&i.fileWrite.ok&&i.adAccess.ok:null;return u.jsxs("div",{className:"bg-oc-navy-800 border border-oc-navy-700 rounded-xl overflow-hidden",children:[u.jsx(Tf,{title:"Access Check",description:"Verify the Windows service account has permission to read/write file paths and connect to Active Directory.",badge:j!==null?u.jsx("span",{className:ce("flex-shrink-0 text-xs font-semibold px-2.5 py-1 rounded-full border",j?"text-green-400 bg-green-500/10 border-green-500/20":"text-red-400 bg-red-500/10 border-red-500/20"),children:j?"All checks passed":"Issues found"}):void 0}),i&&u.jsx("div",{className:"px-5 pt-4",children:u.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 rounded-xl bg-oc-navy-900 border border-oc-navy-700",children:[u.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wide",children:"Running as"}),u.jsx("p",{className:"text-sm font-mono text-teal-300 ml-1",children:i.serviceUser})]})}),u.jsxs("div",{className:ce("divide-y-0",i?"mt-3":""),children:[u.jsx(pa,{label:"File Read Path",result:i?i.fileRead:null}),u.jsx(pa,{label:"File Write Path",result:i?i.fileWrite:null}),u.jsx(pa,{label:"Active Directory (LDAP)",result:i?i.adAccess:null})]}),p&&u.jsx("div",{className:"mx-5 mb-4 px-4 py-3 rounded-xl text-sm border bg-red-500/10 border-red-500/30 text-red-400",children:p}),u.jsxs("div",{className:"px-5 py-5 flex items-center gap-3 border-t border-oc-navy-700",children:[u.jsxs("button",{onClick:S,disabled:a,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl bg-teal-600 hover:bg-teal-500
|
|
48
48
|
text-white text-sm font-semibold transition-colors
|
|
49
49
|
disabled:opacity-40 disabled:cursor-not-allowed`,children:[a&&u.jsx("span",{className:"oc-spinner"}),a?"Checking":"Run Access Check"]}),i&&!a&&u.jsx("span",{className:"text-xs text-slate-500",children:"Last check completed"})]})]})}function X0({initial:i}){const l=Kr(),[a,d]=H.useState(()=>new Set(i??bs)),[p,y]=H.useState(null);H.useEffect(()=>{d(new Set(i??bs))},[i]);function S(b){d(U=>{const $=new Set(U);return $.has(b)?$.delete(b):$.add(b),$}),y(null)}function j(b,U){d($=>{const D=new Set($);return b.forEach(O=>U?D.delete(O):D.add(O)),D}),y(null)}function C(){d(new Set(bs)),y(null)}const F=a.size,T=F===bs.length,L=zs({mutationFn:()=>{const b=T?null:Array.from(a);return Pt.saveAllowedCommands(b)},onSuccess:()=>{y({ok:!0,msg:"Saved. Restart the service for changes to take effect."}),l.invalidateQueries({queryKey:["oc-agent-allowed-commands"]})},onError:()=>y({ok:!1,msg:"Failed to save command filter."})});return u.jsxs("div",{className:"bg-oc-navy-800 border border-oc-navy-700 rounded-xl overflow-hidden",children:[u.jsx(Tf,{title:"Allowed Command Types",description:"Control which operations this agent is permitted to execute. Disabled types are rejected before any AD action is taken.",badge:u.jsxs("span",{className:ce("flex-shrink-0 text-xs font-mono px-2.5 py-1 rounded-full border",T?"text-teal-400 bg-teal-500/10 border-teal-500/20":"text-amber-400 bg-amber-500/10 border-amber-500/20"),children:[F," / ",bs.length," enabled"]})}),u.jsxs("div",{className:"mx-5 mt-4 flex items-start gap-2.5 rounded-xl bg-amber-500/10 border border-amber-500/20 px-4 py-3",children:[u.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4 text-amber-400 flex-shrink-0 mt-0.5",children:u.jsx("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",clipRule:"evenodd"})}),u.jsxs("p",{className:"text-xs text-amber-300/90",children:[u.jsx("strong",{className:"font-semibold",children:"Restart required."})," Changes are loaded at agent startup and will not take effect until the service is restarted."]})]}),u.jsx("div",{className:"p-5 space-y-6",children:Lf.map(b=>{const U=b.commands.map(O=>O.type),$=U.every(O=>a.has(O)),D=U.some(O=>a.has(O));return u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[u.jsxs("div",{children:[u.jsx("p",{className:"text-xs font-bold text-slate-300",children:b.label}),u.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:b.desc})]}),u.jsx("button",{type:"button",onClick:()=>j(U,$),className:"text-xs text-slate-500 hover:text-teal-400 transition-colors ml-4 whitespace-nowrap",children:$?"Disable all":"Enable all"})]}),u.jsx("div",{className:"rounded-xl border border-oc-navy-700 overflow-hidden divide-y divide-oc-navy-700",children:b.commands.map(O=>{const ee=a.has(O.type),ie="destructive"in O&&O.destructive;return u.jsxs("div",{className:ce("flex items-center gap-4 px-4 py-3.5 bg-oc-navy-900/40 transition-opacity",ie&&"border-l-2 border-red-500/40",!ee&&"opacity-55"),children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u.jsx("span",{className:"text-sm text-slate-200 font-medium",children:O.label}),ie&&u.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wide text-red-400 bg-red-500/10 border border-red-500/20 rounded-full px-1.5 py-0.5",children:"Destructive"})]}),u.jsx("span",{className:"text-xs text-slate-500 leading-snug",children:O.desc})]}),u.jsx("code",{className:"hidden sm:inline-block text-[11px] font-mono text-slate-500 bg-oc-navy-800 border border-oc-navy-700 rounded-lg px-2 py-1 whitespace-nowrap",children:O.type}),u.jsx(Z0,{on:ee,onChange:()=>S(O.type)})]},O.type)})})]},b.label)})}),p&&u.jsx("div",{className:ce("mx-5 mb-3 px-4 py-3 rounded-xl text-sm border",p.ok?"bg-green-500/10 border-green-500/30 text-green-400":"bg-red-500/10 border-red-500/30 text-red-400"),children:p.msg}),u.jsxs("div",{className:"px-5 py-5 flex items-center gap-3 border-t border-oc-navy-700",children:[u.jsxs("button",{type:"button",onClick:()=>L.mutate(),disabled:L.isPending,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl bg-teal-600 hover:bg-teal-500
|
|
50
50
|
text-white text-sm font-semibold transition-colors
|
package/ui/index.html
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap"
|
|
16
16
|
rel="stylesheet"
|
|
17
17
|
/>
|
|
18
|
-
<script type="module" crossorigin src="/assets/index-
|
|
18
|
+
<script type="module" crossorigin src="/assets/index-D6p-R1Fk.js"></script>
|
|
19
19
|
<link rel="stylesheet" crossorigin href="/assets/index-wrJnV4d-.css">
|
|
20
20
|
</head>
|
|
21
21
|
<body>
|