morpheus-cli 0.9.22 → 0.9.23
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/channels/discord.js +5 -0
- package/dist/channels/telegram.js +5 -0
- package/dist/http/routers/display.js +5 -0
- package/dist/runtime/audit/repository.js +69 -1
- package/dist/runtime/chronos/worker.js +2 -0
- package/dist/runtime/display.js +32 -0
- package/dist/runtime/memory/sati/service.js +5 -0
- package/dist/runtime/oracle.js +5 -0
- package/dist/runtime/providers/factory.js +14 -2
- package/dist/runtime/smiths/delegator.js +3 -0
- package/dist/runtime/subagents/devkit-instrument.js +5 -0
- package/dist/runtime/subagents/link/link.js +120 -77
- package/dist/runtime/subagents/trinity/trinity.js +64 -34
- package/dist/runtime/tools/factory.js +6 -2
- package/dist/ui/assets/{AuditDashboard-z3OBbJ8I.js → AuditDashboard-ClqEr7jg.js} +1 -1
- package/dist/ui/assets/{Chat-aFz9FjrD.js → Chat-BwxZJphx.js} +1 -1
- package/dist/ui/assets/{Chronos-MP_NCj2A.js → Chronos-BafOMteb.js} +1 -1
- package/dist/ui/assets/{ConfirmationModal-B3gHIVKY.js → ConfirmationModal-DU0AwhXD.js} +1 -1
- package/dist/ui/assets/{Dashboard-OyZXnj44.js → Dashboard-DvJb72Xe.js} +174 -174
- package/dist/ui/assets/{DeleteConfirmationModal-D8QsQzwP.js → DeleteConfirmationModal-FSWLK6-I.js} +1 -1
- package/dist/ui/assets/{Documents-B8g_yv4f.js → Documents-D73CeGkW.js} +1 -1
- package/dist/ui/assets/{Logs-BWufAtHa.js → Logs-BrFWnLIL.js} +1 -1
- package/dist/ui/assets/{MCPManager-lLoGEyBy.js → MCPManager-_L2Yo-uY.js} +1 -1
- package/dist/ui/assets/{ModelPricing-CuYIUwXt.js → ModelPricing-CyXMdxJD.js} +1 -1
- package/dist/ui/assets/{Notifications-nI--fmYx.js → Notifications-BpHokTLS.js} +1 -1
- package/dist/ui/assets/{SatiMemories-DO3JDQBi.js → SatiMemories-CfSTgr9V.js} +1 -1
- package/dist/ui/assets/{SessionAudit-BWtJRkj1.js → SessionAudit-pOWRgJtc.js} +1 -1
- package/dist/ui/assets/{Settings-CblauAVd.js → Settings-CPDXAk18.js} +1 -1
- package/dist/ui/assets/{Skills-Dw6G5c8W.js → Skills-GIkCxMS3.js} +1 -1
- package/dist/ui/assets/{Smiths-B6-CnRMv.js → Smiths-ZcHXcrMt.js} +1 -1
- package/dist/ui/assets/{Tasks-DzUyw5z3.js → Tasks-DJ6R3d4f.js} +1 -1
- package/dist/ui/assets/{TrinityDatabases-DCjdwnLH.js → TrinityDatabases-CnRAkDuu.js} +1 -1
- package/dist/ui/assets/{UsageStats-VajzjndO.js → UsageStats-Bl7bs4ay.js} +1 -1
- package/dist/ui/assets/{WebhookManager-BbfMCiy-.js → WebhookManager-CEjjk4tx.js} +1 -1
- package/dist/ui/assets/{agents-CN_AKX_I.js → agents-DO69pNM1.js} +1 -1
- package/dist/ui/assets/{audit-M-5UGwoK.js → audit-CP5fC4m8.js} +1 -1
- package/dist/ui/assets/{chronos-mZ0RIvh4.js → chronos-DPhK718h.js} +1 -1
- package/dist/ui/assets/{config-7LGRnJ26.js → config-OLGQFNJL.js} +1 -1
- package/dist/ui/assets/{index-Db1XEN8v.js → index-B9ePr-vB.js} +2 -2
- package/dist/ui/assets/index-D_0tPLCk.css +1 -0
- package/dist/ui/assets/{mcp-YiYC-9IH.js → mcp-BeBznKtK.js} +1 -1
- package/dist/ui/assets/{skills-dc6Xqqhb.js → skills-wEUxSGB3.js} +1 -1
- package/dist/ui/assets/{stats-BzqxCDuj.js → stats-KMbKDMJ-.js} +1 -1
- package/dist/ui/assets/{useCurrency-CEc5edm2.js → useCurrency-Bgg-7MTE.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/ui/sw.js +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/index-Bko2TlZY.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as i}from"./vendor-motion-C3CZ8ZlO.js";import{r as I}from"./vendor-react-DikRIOlj.js";import{t as jr,u as ce,Z as Sr,m as ue}from"./vendor-utils-BIYveU_1.js";import{u as Nr,c as Cr}from"./chronos-mZ0RIvh4.js";import{T as k,S as F}from"./SelectInput-BPDcd3y7.js";import{N as O,S as te}from"./Switch-C7TxLq0E.js";import{c as Q}from"./config-7LGRnJ26.js";import{h as He}from"./index-Db1XEN8v.js";import{C as Or}from"./ConfirmationModal-B3gHIVKY.js";import{d as $r,X as Ar,V as Tr}from"./vendor-icons-DE7PWdkN.js";function J({title:e,description:t,children:r}){return i.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg p-6 bg-azure-surface/50 dark:bg-matrix-base/50",children:[i.jsxs("div",{className:"mb-4",children:[i.jsx("h3",{className:"text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:e}),t&&i.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mt-1",children:t})]}),i.jsx("div",{className:"space-y-4",children:r})]})}function ut({label:e,error:t,helperText:r,className:n,...a}){return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-secondary",children:e}),i.jsx("textarea",{className:jr("bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-secondary placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors resize-y min-h-[80px]",t&&"border-red-500 focus:border-red-500 focus:ring-red-500",n),rows:10,...a}),r&&!t&&i.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:r}),t&&i.jsx("p",{className:"text-xs text-red-500",children:t})]})}function m(e,t,r){function n(c,d){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:d,constr:o,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,d);const p=o.prototype,f=Object.keys(p);for(let h=0;h<f.length;h++){const u=f[h];u in c||(c[u]=p[u].bind(c))}}const a=r?.Parent??Object;class s extends a{}Object.defineProperty(s,"name",{value:e});function o(c){var d;const p=r?.Parent?new s:this;n(p,c),(d=p._zod).deferred??(d.deferred=[]);for(const f of p._zod.deferred)f();return p}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}class ke extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Et extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const It={};function de(e){return It}function Pt(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,a])=>t.indexOf(+n)===-1).map(([n,a])=>a)}function Ye(e,t){return typeof t=="bigint"?t.toString():t}function Le(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function et(e){return e==null}function tt(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Zr(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let a=(n.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(n)){const d=n.match(/\d?e-(\d?)/);d?.[1]&&(a=Number.parseInt(d[1]))}const s=r>a?r:a,o=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return o%c/10**s}const dt=Symbol("evaluating");function S(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==dt)return n===void 0&&(n=dt,n=r()),n},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function ge(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function pe(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function mt(e){return JSON.stringify(e)}function Er(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Rt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ir=Le(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function we(e){if(Ae(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Ae(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Dt(e){return we(e)?{...e}:Array.isArray(e)?[...e]:e}const Pr=new Set(["string","number","symbol"]);function ze(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fe(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function g(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Rr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Dr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Mr(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=pe(e._zod.def,{get shape(){const o={};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(o[c]=r.shape[c])}return ge(this,"shape",o),o},checks:[]});return fe(e,s)}function Ur(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=pe(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete o[c]}return ge(this,"shape",o),o},checks:[]});return fe(e,s)}function Lr(e,t){if(!we(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const s=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=pe(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return ge(this,"shape",s),s}});return fe(e,a)}function Fr(e,t){if(!we(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=pe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return ge(this,"shape",n),n}});return fe(e,r)}function Jr(e,t){const r=pe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return ge(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return fe(e,r)}function Br(e,t,r){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=pe(t._zod.def,{get shape(){const c=t._zod.def.shape,d={...c};if(r)for(const p in r){if(!(p in c))throw new Error(`Unrecognized key: "${p}"`);r[p]&&(d[p]=e?new e({type:"optional",innerType:c[p]}):c[p])}else for(const p in c)d[p]=e?new e({type:"optional",innerType:c[p]}):c[p];return ge(this,"shape",d),d},checks:[]});return fe(t,o)}function Kr(e,t,r){const n=pe(t._zod.def,{get shape(){const a=t._zod.def.shape,s={...a};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)s[o]=new e({type:"nonoptional",innerType:a[o]});return ge(this,"shape",s),s}});return fe(t,n)}function ye(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function _e(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ee(e){return typeof e=="string"?e:e?.message}function me(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const a=Ee(e.inst?._zod.def?.error?.(e))??Ee(t?.error?.(e))??Ee(r.customError?.(e))??Ee(r.localeError?.(e))??"Invalid input";n.message=a}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function rt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Te(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Mt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ye,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ut=m("$ZodError",Mt),Lt=m("$ZodError",Mt,{Parent:Error});function Vr(e,t=r=>r.message){const r={},n=[];for(const a of e.issues)a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(t(a))):n.push(t(a));return{formErrors:n,fieldErrors:r}}function Wr(e,t=r=>r.message){const r={_errors:[]},n=a=>{for(const s of a.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>n({issues:o}));else if(s.code==="invalid_key")n({issues:s.issues});else if(s.code==="invalid_element")n({issues:s.issues});else if(s.path.length===0)r._errors.push(t(s));else{let o=r,c=0;for(;c<s.path.length;){const d=s.path[c];c===s.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(s))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}};return n(e),r}const nt=e=>(t,r,n,a)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new ke;if(o.issues.length){const c=new(a?.Err??e)(o.issues.map(d=>me(d,s,de())));throw Rt(c,a?.callee),c}return o.value},at=e=>async(t,r,n,a)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const c=new(a?.Err??e)(o.issues.map(d=>me(d,s,de())));throw Rt(c,a?.callee),c}return o.value},Fe=e=>(t,r,n)=>{const a=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},a);if(s instanceof Promise)throw new ke;return s.issues.length?{success:!1,error:new(e??Ut)(s.issues.map(o=>me(o,a,de())))}:{success:!0,data:s.value}},Gr=Fe(Lt),Je=e=>async(t,r,n)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:r,issues:[]},a);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(o=>me(o,a,de())))}:{success:!0,data:s.value}},qr=Je(Lt),Hr=e=>(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return nt(e)(t,r,a)},Yr=e=>(t,r,n)=>nt(e)(t,r,n),Xr=e=>async(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return at(e)(t,r,a)},Qr=e=>async(t,r,n)=>at(e)(t,r,n),en=e=>(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Fe(e)(t,r,a)},tn=e=>(t,r,n)=>Fe(e)(t,r,n),rn=e=>async(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Je(e)(t,r,a)},nn=e=>async(t,r,n)=>Je(e)(t,r,n),an=/^[cC][^\s-]{8,}$/,on=/^[0-9a-z]+$/,sn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ln=/^[0-9a-vA-V]{20}$/,cn=/^[A-Za-z0-9]{27}$/,un=/^[a-zA-Z0-9_-]{21}$/,dn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,mn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,pn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,fn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function hn(){return new RegExp(fn,"u")}const gn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,bn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,vn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,xn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ft=/^[A-Za-z0-9_-]*$/,_n=/^\+[1-9]\d{6,14}$/,Jt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",kn=new RegExp(`^${Jt}$`);function Bt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function wn(e){return new RegExp(`^${Bt(e)}$`)}function zn(e){const t=Bt({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Jt}T(?:${n})$`)}const jn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Sn=/^-?\d+$/,Kt=/^-?\d+(?:\.\d+)?$/,Nn=/^(?:true|false)$/i,Cn=/^[^A-Z]*$/,On=/^[^a-z]*$/,H=m("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Vt={number:"number",bigint:"bigint",object:"date"},Wt=m("$ZodCheckLessThan",(e,t)=>{H.init(e,t);const r=Vt[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,s=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gt=m("$ZodCheckGreaterThan",(e,t)=>{H.init(e,t);const r=Vt[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,s=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$n=m("$ZodCheckMultipleOf",(e,t)=>{H.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Zr(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),An=m("$ZodCheckNumberFormat",(e,t)=>{H.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[a,s]=Dr[t.format];e._zod.onattach.push(o=>{const c=o._zod.bag;c.format=t.format,c.minimum=a,c.maximum=s,r&&(c.pattern=Sn)}),e._zod.check=o=>{const c=o.value;if(r){if(!Number.isInteger(c)){o.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?o.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):o.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<a&&o.issues.push({origin:"number",input:c,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),c>s&&o.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Tn=m("$ZodCheckMaxLength",(e,t)=>{var r;H.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!et(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const a=n.value;if(a.length<=t.maximum)return;const o=rt(a);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Zn=m("$ZodCheckMinLength",(e,t)=>{var r;H.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!et(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const a=n.value;if(a.length>=t.minimum)return;const o=rt(a);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),En=m("$ZodCheckLengthEquals",(e,t)=>{var r;H.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!et(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=n=>{const a=n.value,s=a.length;if(s===t.length)return;const o=rt(a),c=s>t.length;n.issues.push({origin:o,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Be=m("$ZodCheckStringFormat",(e,t)=>{var r,n;H.init(e,t),e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),In=m("$ZodCheckRegex",(e,t)=>{Be.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Pn=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Cn),Be.init(e,t)}),Rn=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=On),Be.init(e,t)}),Dn=m("$ZodCheckIncludes",(e,t)=>{H.init(e,t);const r=ze(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(a=>{const s=a._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),Mn=m("$ZodCheckStartsWith",(e,t)=>{H.init(e,t);const r=new RegExp(`^${ze(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Un=m("$ZodCheckEndsWith",(e,t)=>{H.init(e,t);const r=new RegExp(`.*${ze(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ln=m("$ZodCheckOverwrite",(e,t)=>{H.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Fn{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
|
|
1
|
+
import{j as i}from"./vendor-motion-C3CZ8ZlO.js";import{r as I}from"./vendor-react-DikRIOlj.js";import{t as jr,u as ce,Z as Sr,m as ue}from"./vendor-utils-BIYveU_1.js";import{u as Nr,c as Cr}from"./chronos-DPhK718h.js";import{T as k,S as F}from"./SelectInput-BPDcd3y7.js";import{N as O,S as te}from"./Switch-C7TxLq0E.js";import{c as Q}from"./config-OLGQFNJL.js";import{h as He}from"./index-B9ePr-vB.js";import{C as Or}from"./ConfirmationModal-DU0AwhXD.js";import{d as $r,X as Ar,V as Tr}from"./vendor-icons-DE7PWdkN.js";function J({title:e,description:t,children:r}){return i.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg p-6 bg-azure-surface/50 dark:bg-matrix-base/50",children:[i.jsxs("div",{className:"mb-4",children:[i.jsx("h3",{className:"text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:e}),t&&i.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mt-1",children:t})]}),i.jsx("div",{className:"space-y-4",children:r})]})}function ut({label:e,error:t,helperText:r,className:n,...a}){return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-secondary",children:e}),i.jsx("textarea",{className:jr("bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-secondary placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors resize-y min-h-[80px]",t&&"border-red-500 focus:border-red-500 focus:ring-red-500",n),rows:10,...a}),r&&!t&&i.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:r}),t&&i.jsx("p",{className:"text-xs text-red-500",children:t})]})}function m(e,t,r){function n(c,d){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:d,constr:o,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,d);const p=o.prototype,f=Object.keys(p);for(let h=0;h<f.length;h++){const u=f[h];u in c||(c[u]=p[u].bind(c))}}const a=r?.Parent??Object;class s extends a{}Object.defineProperty(s,"name",{value:e});function o(c){var d;const p=r?.Parent?new s:this;n(p,c),(d=p._zod).deferred??(d.deferred=[]);for(const f of p._zod.deferred)f();return p}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}class ke extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Et extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const It={};function de(e){return It}function Pt(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,a])=>t.indexOf(+n)===-1).map(([n,a])=>a)}function Ye(e,t){return typeof t=="bigint"?t.toString():t}function Le(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function et(e){return e==null}function tt(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Zr(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let a=(n.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(n)){const d=n.match(/\d?e-(\d?)/);d?.[1]&&(a=Number.parseInt(d[1]))}const s=r>a?r:a,o=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return o%c/10**s}const dt=Symbol("evaluating");function S(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==dt)return n===void 0&&(n=dt,n=r()),n},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function ge(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function pe(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function mt(e){return JSON.stringify(e)}function Er(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Rt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ir=Le(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function we(e){if(Ae(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Ae(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Dt(e){return we(e)?{...e}:Array.isArray(e)?[...e]:e}const Pr=new Set(["string","number","symbol"]);function ze(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fe(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function g(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Rr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Dr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Mr(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=pe(e._zod.def,{get shape(){const o={};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(o[c]=r.shape[c])}return ge(this,"shape",o),o},checks:[]});return fe(e,s)}function Ur(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=pe(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete o[c]}return ge(this,"shape",o),o},checks:[]});return fe(e,s)}function Lr(e,t){if(!we(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const s=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=pe(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return ge(this,"shape",s),s}});return fe(e,a)}function Fr(e,t){if(!we(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=pe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return ge(this,"shape",n),n}});return fe(e,r)}function Jr(e,t){const r=pe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return ge(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return fe(e,r)}function Br(e,t,r){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=pe(t._zod.def,{get shape(){const c=t._zod.def.shape,d={...c};if(r)for(const p in r){if(!(p in c))throw new Error(`Unrecognized key: "${p}"`);r[p]&&(d[p]=e?new e({type:"optional",innerType:c[p]}):c[p])}else for(const p in c)d[p]=e?new e({type:"optional",innerType:c[p]}):c[p];return ge(this,"shape",d),d},checks:[]});return fe(t,o)}function Kr(e,t,r){const n=pe(t._zod.def,{get shape(){const a=t._zod.def.shape,s={...a};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)s[o]=new e({type:"nonoptional",innerType:a[o]});return ge(this,"shape",s),s}});return fe(t,n)}function ye(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function _e(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ee(e){return typeof e=="string"?e:e?.message}function me(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const a=Ee(e.inst?._zod.def?.error?.(e))??Ee(t?.error?.(e))??Ee(r.customError?.(e))??Ee(r.localeError?.(e))??"Invalid input";n.message=a}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function rt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Te(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Mt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ye,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ut=m("$ZodError",Mt),Lt=m("$ZodError",Mt,{Parent:Error});function Vr(e,t=r=>r.message){const r={},n=[];for(const a of e.issues)a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(t(a))):n.push(t(a));return{formErrors:n,fieldErrors:r}}function Wr(e,t=r=>r.message){const r={_errors:[]},n=a=>{for(const s of a.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>n({issues:o}));else if(s.code==="invalid_key")n({issues:s.issues});else if(s.code==="invalid_element")n({issues:s.issues});else if(s.path.length===0)r._errors.push(t(s));else{let o=r,c=0;for(;c<s.path.length;){const d=s.path[c];c===s.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(s))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}};return n(e),r}const nt=e=>(t,r,n,a)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new ke;if(o.issues.length){const c=new(a?.Err??e)(o.issues.map(d=>me(d,s,de())));throw Rt(c,a?.callee),c}return o.value},at=e=>async(t,r,n,a)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const c=new(a?.Err??e)(o.issues.map(d=>me(d,s,de())));throw Rt(c,a?.callee),c}return o.value},Fe=e=>(t,r,n)=>{const a=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},a);if(s instanceof Promise)throw new ke;return s.issues.length?{success:!1,error:new(e??Ut)(s.issues.map(o=>me(o,a,de())))}:{success:!0,data:s.value}},Gr=Fe(Lt),Je=e=>async(t,r,n)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:r,issues:[]},a);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(o=>me(o,a,de())))}:{success:!0,data:s.value}},qr=Je(Lt),Hr=e=>(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return nt(e)(t,r,a)},Yr=e=>(t,r,n)=>nt(e)(t,r,n),Xr=e=>async(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return at(e)(t,r,a)},Qr=e=>async(t,r,n)=>at(e)(t,r,n),en=e=>(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Fe(e)(t,r,a)},tn=e=>(t,r,n)=>Fe(e)(t,r,n),rn=e=>async(t,r,n)=>{const a=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Je(e)(t,r,a)},nn=e=>async(t,r,n)=>Je(e)(t,r,n),an=/^[cC][^\s-]{8,}$/,on=/^[0-9a-z]+$/,sn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ln=/^[0-9a-vA-V]{20}$/,cn=/^[A-Za-z0-9]{27}$/,un=/^[a-zA-Z0-9_-]{21}$/,dn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,mn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,pn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,fn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function hn(){return new RegExp(fn,"u")}const gn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,bn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,vn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,xn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ft=/^[A-Za-z0-9_-]*$/,_n=/^\+[1-9]\d{6,14}$/,Jt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",kn=new RegExp(`^${Jt}$`);function Bt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function wn(e){return new RegExp(`^${Bt(e)}$`)}function zn(e){const t=Bt({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Jt}T(?:${n})$`)}const jn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Sn=/^-?\d+$/,Kt=/^-?\d+(?:\.\d+)?$/,Nn=/^(?:true|false)$/i,Cn=/^[^A-Z]*$/,On=/^[^a-z]*$/,H=m("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Vt={number:"number",bigint:"bigint",object:"date"},Wt=m("$ZodCheckLessThan",(e,t)=>{H.init(e,t);const r=Vt[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,s=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gt=m("$ZodCheckGreaterThan",(e,t)=>{H.init(e,t);const r=Vt[typeof t.value];e._zod.onattach.push(n=>{const a=n._zod.bag,s=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$n=m("$ZodCheckMultipleOf",(e,t)=>{H.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Zr(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),An=m("$ZodCheckNumberFormat",(e,t)=>{H.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[a,s]=Dr[t.format];e._zod.onattach.push(o=>{const c=o._zod.bag;c.format=t.format,c.minimum=a,c.maximum=s,r&&(c.pattern=Sn)}),e._zod.check=o=>{const c=o.value;if(r){if(!Number.isInteger(c)){o.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?o.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):o.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<a&&o.issues.push({origin:"number",input:c,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),c>s&&o.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Tn=m("$ZodCheckMaxLength",(e,t)=>{var r;H.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!et(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const a=n.value;if(a.length<=t.maximum)return;const o=rt(a);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),Zn=m("$ZodCheckMinLength",(e,t)=>{var r;H.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!et(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const a=n.value;if(a.length>=t.minimum)return;const o=rt(a);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),En=m("$ZodCheckLengthEquals",(e,t)=>{var r;H.init(e,t),(r=e._zod.def).when??(r.when=n=>{const a=n.value;return!et(a)&&a.length!==void 0}),e._zod.onattach.push(n=>{const a=n._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=n=>{const a=n.value,s=a.length;if(s===t.length)return;const o=rt(a),c=s>t.length;n.issues.push({origin:o,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Be=m("$ZodCheckStringFormat",(e,t)=>{var r,n;H.init(e,t),e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),In=m("$ZodCheckRegex",(e,t)=>{Be.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Pn=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Cn),Be.init(e,t)}),Rn=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=On),Be.init(e,t)}),Dn=m("$ZodCheckIncludes",(e,t)=>{H.init(e,t);const r=ze(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(a=>{const s=a._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),Mn=m("$ZodCheckStartsWith",(e,t)=>{H.init(e,t);const r=new RegExp(`^${ze(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Un=m("$ZodCheckEndsWith",(e,t)=>{H.init(e,t);const r=new RegExp(`.*${ze(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ln=m("$ZodCheckOverwrite",(e,t)=>{H.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Fn{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
|
|
2
2
|
`).filter(o=>o),a=Math.min(...n.map(o=>o.length-o.trimStart().length)),s=n.map(o=>o.slice(a)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const t=Function,r=this?.args,a=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...r,a.join(`
|
|
3
3
|
`))}}const Jn={major:4,minor:3,patch:6},P=m("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Jn;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const a of n)for(const s of a._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const a=(o,c,d)=>{let p=ye(o),f;for(const h of c){if(h._zod.def.when){if(!h._zod.def.when(o))continue}else if(p)continue;const u=o.issues.length,b=h._zod.check(o);if(b instanceof Promise&&d?.async===!1)throw new ke;if(f||b instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await b,o.issues.length!==u&&(p||(p=ye(o,u)))});else{if(o.issues.length===u)continue;p||(p=ye(o,u))}}return f?f.then(()=>o):o},s=(o,c,d)=>{if(ye(o))return o.aborted=!0,o;const p=a(c,n,d);if(p instanceof Promise){if(d.async===!1)throw new ke;return p.then(f=>e._zod.parse(f,d))}return e._zod.parse(p,d)};e._zod.run=(o,c)=>{if(c.skipChecks)return e._zod.parse(o,c);if(c.direction==="backward"){const p=e._zod.parse({value:o.value,issues:[]},{...c,skipChecks:!0});return p instanceof Promise?p.then(f=>s(f,o,c)):s(p,o,c)}const d=e._zod.parse(o,c);if(d instanceof Promise){if(c.async===!1)throw new ke;return d.then(p=>a(p,n,c))}return a(d,n,c)}}S(e,"~standard",()=>({validate:a=>{try{const s=Gr(e,a);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return qr(e,a).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),ot=m("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??jn(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Z=m("$ZodStringFormat",(e,t)=>{Be.init(e,t),ot.init(e,t)}),Bn=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=mn),Z.init(e,t)}),Kn=m("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=pt(n))}else t.pattern??(t.pattern=pt());Z.init(e,t)}),Vn=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=pn),Z.init(e,t)}),Wn=m("$ZodURL",(e,t)=>{Z.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),a=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(":")?a.protocol.slice(0,-1):a.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=a.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Gn=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=hn()),Z.init(e,t)}),qn=m("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=un),Z.init(e,t)}),Hn=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=an),Z.init(e,t)}),Yn=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=on),Z.init(e,t)}),Xn=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=sn),Z.init(e,t)}),Qn=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ln),Z.init(e,t)}),ea=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=cn),Z.init(e,t)}),ta=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=zn(t)),Z.init(e,t)}),ra=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=kn),Z.init(e,t)}),na=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=wn(t)),Z.init(e,t)}),aa=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=dn),Z.init(e,t)}),oa=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=gn),Z.init(e,t),e._zod.bag.format="ipv4"}),ia=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=bn),Z.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),sa=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=vn),Z.init(e,t)}),la=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=xn),Z.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[a,s]=n;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${a}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function qt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ca=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=yn),Z.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{qt(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function ua(e){if(!Ft.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return qt(r)}const da=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ft),Z.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{ua(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ma=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=_n),Z.init(e,t)});function pa(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const a=JSON.parse(atob(n));return!("typ"in a&&a?.typ!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const fa=m("$ZodJWT",(e,t)=>{Z.init(e,t),e._zod.check=r=>{pa(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Ht=m("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=e._zod.bag.pattern??Kt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const a=r.value;if(typeof a=="number"&&!Number.isNaN(a)&&Number.isFinite(a))return r;const s=typeof a=="number"?Number.isNaN(a)?"NaN":Number.isFinite(a)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:a,inst:e,...s?{received:s}:{}}),r}}),ha=m("$ZodNumberFormat",(e,t)=>{An.init(e,t),Ht.init(e,t)}),ga=m("$ZodBoolean",(e,t)=>{P.init(e,t),e._zod.pattern=Nn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const a=r.value;return typeof a=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),r}}),ba=m("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=r=>r}),va=m("$ZodNever",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function ft(e,t,r){e.issues.length&&t.issues.push(..._e(r,e.issues)),t.value[r]=e.value}const xa=m("$ZodArray",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{const a=r.value;if(!Array.isArray(a))return r.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),r;r.value=Array(a.length);const s=[];for(let o=0;o<a.length;o++){const c=a[o],d=t.element._zod.run({value:c,issues:[]},n);d instanceof Promise?s.push(d.then(p=>ft(p,r,o))):ft(d,r,o)}return s.length?Promise.all(s).then(()=>r):r}});function De(e,t,r,n,a){if(e.issues.length){if(a&&!(r in n))return;t.issues.push(..._e(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Yt(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=Rr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Xt(e,t,r,n,a,s){const o=[],c=a.keySet,d=a.catchall._zod,p=d.def.type,f=d.optout==="optional";for(const h in t){if(c.has(h))continue;if(p==="never"){o.push(h);continue}const u=d.run({value:t[h],issues:[]},n);u instanceof Promise?e.push(u.then(b=>De(b,r,h,t,f))):De(u,r,h,t,f)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}const ya=m("$ZodObject",(e,t)=>{if(P.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...c};return Object.defineProperty(t,"shape",{value:d}),d}})}const n=Le(()=>Yt(t));S(e._zod,"propValues",()=>{const c=t.shape,d={};for(const p in c){const f=c[p]._zod;if(f.values){d[p]??(d[p]=new Set);for(const h of f.values)d[p].add(h)}}return d});const a=Ae,s=t.catchall;let o;e._zod.parse=(c,d)=>{o??(o=n.value);const p=c.value;if(!a(p))return c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c;c.value={};const f=[],h=o.shape;for(const u of o.keys){const b=h[u],y=b._zod.optout==="optional",U=b._zod.run({value:p[u],issues:[]},d);U instanceof Promise?f.push(U.then(N=>De(N,c,u,p,y))):De(U,c,u,p,y)}return s?Xt(f,p,c,d,n.value,e):f.length?Promise.all(f).then(()=>c):c}}),_a=m("$ZodObjectJIT",(e,t)=>{ya.init(e,t);const r=e._zod.parse,n=Le(()=>Yt(t)),a=u=>{const b=new Fn(["shape","payload","ctx"]),y=n.value,U=V=>{const w=mt(V);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};b.write("const input = payload.value;");const N=Object.create(null);let be=0;for(const V of y.keys)N[V]=`key_${be++}`;b.write("const newResult = {};");for(const V of y.keys){const w=N[V],K=mt(V),Ne=u[V]?._zod?.optout==="optional";b.write(`const ${w} = ${U(V)};`),Ne?b.write(`
|
|
4
4
|
if (${w}.issues.length) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,m as n}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as Z}from"./vendor-utils-BIYveU_1.js";import{s as l}from"./skills-dc6Xqqhb.js";import{D as K,j as O,k as V}from"./index-Db1XEN8v.js";import{W as y,am as u,Y as b,a4 as W,J as F,Z as L,U as I,a0 as q,a5 as A,a6 as B,X as H,an as J}from"./vendor-icons-DE7PWdkN.js";const U={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},g={hidden:{opacity:0,y:8},show:{opacity:1,y:0}};function M({skill:r,onToggle:i,onView:d}){return e.jsxs(n.div,{variants:g,className:`rounded-lg border flex flex-col transition-all ${r.enabled?"border-azure-primary/50 dark:border-matrix-primary bg-white dark:bg-zinc-900 shadow-sm":"border-azure-border dark:border-matrix-primary/30 bg-azure-surface/50 dark:bg-zinc-900 shadow-sm"}`,children:[e.jsxs("div",{className:"p-4 flex items-start gap-3 flex-1",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${r.enabled?"bg-azure-primary/10 dark:bg-matrix-highlight/10":"bg-azure-surface dark:bg-zinc-900"}`,children:e.jsx(y,{className:`w-4 h-4 ${r.enabled?"text-azure-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:`font-semibold truncate ${r.enabled?"text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary"}`,children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]}),!r.enabled&&e.jsx("span",{className:"text-[10px] font-medium text-zinc-400 dark:text-zinc-500 bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded px-1.5 py-0.5 shrink-0",children:"disabled"})]}),e.jsx("p",{className:`text-sm mt-1.5 line-clamp-2 leading-relaxed ${r.enabled?"text-azure-text-secondary dark:text-matrix-secondary":"text-azure-text-secondary/70 dark:text-matrix-tertiary"}`,children:r.description}),r.tags&&r.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]})]}),e.jsxs("div",{className:"px-4 py-3 border-t border-azure-border dark:border-matrix-primary/30 flex items-center justify-between gap-2",children:[r.author?e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary min-w-0",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:r.author})]}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:d,className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:i,className:`p-1.5 rounded border transition-colors ${r.enabled?"border-emerald-300 dark:border-emerald-700/60 text-emerald-500 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20":"border-azure-border dark:border-matrix-primary/40 text-zinc-400 dark:text-zinc-600 hover:text-azure-text dark:hover:text-matrix-secondary hover:border-azure-border dark:hover:border-matrix-primary"}`,title:r.enabled?"Disable skill":"Enable skill",children:r.enabled?e.jsx(A,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]})]})]})}function X({skill:r,open:i,onOpenChange:d}){return!i||!r?null:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>d(!1)}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(y,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight truncate",children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]})]}),r.author&&e.jsxs("div",{className:"flex items-center gap-1 mt-0.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),r.author]})]})]}),e.jsx("button",{onClick:()=>d(!1),className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(H,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[r.description&&e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary leading-relaxed",children:r.description}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsxs("div",{className:"flex items-start gap-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(J,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"break-all font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2 py-0.5",children:r.path})]})}),r.tags&&r.tags.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]}),r.examples&&r.examples.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Examples"}),e.jsx("ul",{className:"space-y-1.5",children:r.examples.map((t,x)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-azure-text-secondary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/30 rounded px-3 py-2",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary font-mono text-xs mt-0.5 shrink-0",children:[x+1,"."]}),t]},x))})]}),r.content&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"SKILL.md"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-72 whitespace-pre-wrap leading-relaxed font-mono",children:r.content})]})]})]})]})}function ae(){const[r,i]=s.useState(null),[d,t]=s.useState(!1),[x,N]=s.useState(!1),[o,v]=s.useState(!1),[c,k]=s.useState(null),[w,f]=s.useState(null),j=s.useRef(null),{data:S,mutate:z,isLoading:D}=Z("/skills",()=>l.fetchSkills(),{refreshInterval:1e4}),m=S?.skills??[],E=S?.enabled??0,R=async()=>{await l.reloadSkills(),z()},T=async a=>{a.enabled?await l.disableSkill(a.name):await l.enableSkill(a.name),z()},$=async a=>{t(!0);try{const p=await l.fetchSkill(a.name);i(p)}finally{t(!1)}},P=async a=>{const p=a.target.files?.[0];if(p){k(null),f(null),v(!0);try{const h=await l.uploadSkill(p);f(`Skill "${h.skill.name}" uploaded successfully!`),z(),j.current&&(j.current.value="")}catch(h){k({error:h.message||"Upload failed",details:h.details})}finally{v(!1)}}},C=()=>{k(null),f(null),N(!0)};return e.jsxs(n.div,{variants:U,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.div,{variants:g,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(y,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Skills"}),e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:[m.length," skill",m.length!==1?"s":"",", ",E," enabled"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:C,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-azure-primary dark:border-matrix-primary text-azure-primary dark:text-matrix-primary font-medium hover:bg-azure-primary/10 dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload"]}),e.jsxs("button",{onClick:R,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(b,{className:"w-4 h-4"}),"Reload"]})]})]}),D?e.jsxs(n.div,{variants:g,className:"text-center py-12",children:[e.jsx(b,{className:"w-8 h-8 animate-spin mx-auto text-azure-text-secondary dark:text-matrix-dim"}),e.jsx("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-dim",children:"Loading skills..."})]}):m.length===0?e.jsxs(n.div,{variants:g,className:"rounded-lg border border-dashed border-azure-border dark:border-matrix-primary p-8 text-center",children:[e.jsx(y,{className:"w-12 h-12 mx-auto text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("h3",{className:"mt-4 text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:"No skills found"}),e.jsxs("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-secondary max-w-md mx-auto",children:["Upload a skill ZIP or add skills manually to"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"~/.morpheus/skills/"}),". Each skill folder must contain a"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file with frontmatter."]}),e.jsxs("button",{onClick:C,className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload Skill"]})]}):e.jsx(n.div,{variants:U,initial:"hidden",animate:"show",className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:m.map(a=>e.jsx(M,{skill:a,onToggle:()=>T(a),onView:()=>$(a)},a.name))}),e.jsx(X,{skill:r,open:!!r,onOpenChange:a=>!a&&i(null)}),e.jsxs(K,{open:x,onOpenChange:N,children:[e.jsx(O,{children:e.jsx(V,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5"}),"Upload Skill"]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm",children:["Upload a ZIP file containing your skill folder. The ZIP must have exactly one folder at root level with a valid ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file."]}),e.jsxs("div",{className:"border-2 border-dashed border-azure-border dark:border-matrix-primary rounded-lg p-6",children:[e.jsx("input",{ref:j,type:"file",accept:".zip,application/zip,application/x-zip-compressed",onChange:P,disabled:o,className:"hidden",id:"skill-upload-input"}),e.jsxs("label",{htmlFor:"skill-upload-input",className:`flex flex-col items-center gap-2 cursor-pointer ${o?"opacity-50 cursor-not-allowed":""}`,children:[o?e.jsx(b,{className:"w-8 h-8 animate-spin text-azure-primary dark:text-matrix-primary"}):e.jsx(u,{className:"w-8 h-8 text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:o?"Uploading...":"Click to select ZIP file"})]})]}),c&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800",children:[e.jsx(W,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:c.error}),c.details&&e.jsx("p",{className:"text-xs text-red-600 dark:text-red-300 mt-1",children:c.details})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800",children:[e.jsx(F,{className:"w-5 h-5 text-green-600 dark:text-green-400"}),e.jsx("p",{className:"text-sm text-green-800 dark:text-green-200",children:w})]}),e.jsxs("div",{className:"rounded-lg bg-azure-hover dark:bg-zinc-900 p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight mb-2",children:"ZIP Structure Example"}),e.jsx("pre",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:`my-skill.zip
|
|
1
|
+
import{j as e,m as n}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as Z}from"./vendor-utils-BIYveU_1.js";import{s as l}from"./skills-wEUxSGB3.js";import{D as K,j as O,k as V}from"./index-B9ePr-vB.js";import{W as y,am as u,Y as b,a4 as W,J as F,Z as L,U as I,a0 as q,a5 as A,a6 as B,X as H,an as J}from"./vendor-icons-DE7PWdkN.js";const U={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},g={hidden:{opacity:0,y:8},show:{opacity:1,y:0}};function M({skill:r,onToggle:i,onView:d}){return e.jsxs(n.div,{variants:g,className:`rounded-lg border flex flex-col transition-all ${r.enabled?"border-azure-primary/50 dark:border-matrix-primary bg-white dark:bg-zinc-900 shadow-sm":"border-azure-border dark:border-matrix-primary/30 bg-azure-surface/50 dark:bg-zinc-900 shadow-sm"}`,children:[e.jsxs("div",{className:"p-4 flex items-start gap-3 flex-1",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${r.enabled?"bg-azure-primary/10 dark:bg-matrix-highlight/10":"bg-azure-surface dark:bg-zinc-900"}`,children:e.jsx(y,{className:`w-4 h-4 ${r.enabled?"text-azure-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:`font-semibold truncate ${r.enabled?"text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary"}`,children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]}),!r.enabled&&e.jsx("span",{className:"text-[10px] font-medium text-zinc-400 dark:text-zinc-500 bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded px-1.5 py-0.5 shrink-0",children:"disabled"})]}),e.jsx("p",{className:`text-sm mt-1.5 line-clamp-2 leading-relaxed ${r.enabled?"text-azure-text-secondary dark:text-matrix-secondary":"text-azure-text-secondary/70 dark:text-matrix-tertiary"}`,children:r.description}),r.tags&&r.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]})]}),e.jsxs("div",{className:"px-4 py-3 border-t border-azure-border dark:border-matrix-primary/30 flex items-center justify-between gap-2",children:[r.author?e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary min-w-0",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:r.author})]}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:d,className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:i,className:`p-1.5 rounded border transition-colors ${r.enabled?"border-emerald-300 dark:border-emerald-700/60 text-emerald-500 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20":"border-azure-border dark:border-matrix-primary/40 text-zinc-400 dark:text-zinc-600 hover:text-azure-text dark:hover:text-matrix-secondary hover:border-azure-border dark:hover:border-matrix-primary"}`,title:r.enabled?"Disable skill":"Enable skill",children:r.enabled?e.jsx(A,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]})]})]})}function X({skill:r,open:i,onOpenChange:d}){return!i||!r?null:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>d(!1)}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(y,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight truncate",children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]})]}),r.author&&e.jsxs("div",{className:"flex items-center gap-1 mt-0.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),r.author]})]})]}),e.jsx("button",{onClick:()=>d(!1),className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(H,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[r.description&&e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary leading-relaxed",children:r.description}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsxs("div",{className:"flex items-start gap-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(J,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"break-all font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2 py-0.5",children:r.path})]})}),r.tags&&r.tags.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]}),r.examples&&r.examples.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Examples"}),e.jsx("ul",{className:"space-y-1.5",children:r.examples.map((t,x)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-azure-text-secondary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/30 rounded px-3 py-2",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary font-mono text-xs mt-0.5 shrink-0",children:[x+1,"."]}),t]},x))})]}),r.content&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"SKILL.md"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-72 whitespace-pre-wrap leading-relaxed font-mono",children:r.content})]})]})]})]})}function ae(){const[r,i]=s.useState(null),[d,t]=s.useState(!1),[x,N]=s.useState(!1),[o,v]=s.useState(!1),[c,k]=s.useState(null),[w,f]=s.useState(null),j=s.useRef(null),{data:S,mutate:z,isLoading:D}=Z("/skills",()=>l.fetchSkills(),{refreshInterval:1e4}),m=S?.skills??[],E=S?.enabled??0,R=async()=>{await l.reloadSkills(),z()},T=async a=>{a.enabled?await l.disableSkill(a.name):await l.enableSkill(a.name),z()},$=async a=>{t(!0);try{const p=await l.fetchSkill(a.name);i(p)}finally{t(!1)}},P=async a=>{const p=a.target.files?.[0];if(p){k(null),f(null),v(!0);try{const h=await l.uploadSkill(p);f(`Skill "${h.skill.name}" uploaded successfully!`),z(),j.current&&(j.current.value="")}catch(h){k({error:h.message||"Upload failed",details:h.details})}finally{v(!1)}}},C=()=>{k(null),f(null),N(!0)};return e.jsxs(n.div,{variants:U,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.div,{variants:g,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(y,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Skills"}),e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:[m.length," skill",m.length!==1?"s":"",", ",E," enabled"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:C,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-azure-primary dark:border-matrix-primary text-azure-primary dark:text-matrix-primary font-medium hover:bg-azure-primary/10 dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload"]}),e.jsxs("button",{onClick:R,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(b,{className:"w-4 h-4"}),"Reload"]})]})]}),D?e.jsxs(n.div,{variants:g,className:"text-center py-12",children:[e.jsx(b,{className:"w-8 h-8 animate-spin mx-auto text-azure-text-secondary dark:text-matrix-dim"}),e.jsx("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-dim",children:"Loading skills..."})]}):m.length===0?e.jsxs(n.div,{variants:g,className:"rounded-lg border border-dashed border-azure-border dark:border-matrix-primary p-8 text-center",children:[e.jsx(y,{className:"w-12 h-12 mx-auto text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("h3",{className:"mt-4 text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:"No skills found"}),e.jsxs("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-secondary max-w-md mx-auto",children:["Upload a skill ZIP or add skills manually to"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"~/.morpheus/skills/"}),". Each skill folder must contain a"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file with frontmatter."]}),e.jsxs("button",{onClick:C,className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload Skill"]})]}):e.jsx(n.div,{variants:U,initial:"hidden",animate:"show",className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:m.map(a=>e.jsx(M,{skill:a,onToggle:()=>T(a),onView:()=>$(a)},a.name))}),e.jsx(X,{skill:r,open:!!r,onOpenChange:a=>!a&&i(null)}),e.jsxs(K,{open:x,onOpenChange:N,children:[e.jsx(O,{children:e.jsx(V,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5"}),"Upload Skill"]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm",children:["Upload a ZIP file containing your skill folder. The ZIP must have exactly one folder at root level with a valid ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file."]}),e.jsxs("div",{className:"border-2 border-dashed border-azure-border dark:border-matrix-primary rounded-lg p-6",children:[e.jsx("input",{ref:j,type:"file",accept:".zip,application/zip,application/x-zip-compressed",onChange:P,disabled:o,className:"hidden",id:"skill-upload-input"}),e.jsxs("label",{htmlFor:"skill-upload-input",className:`flex flex-col items-center gap-2 cursor-pointer ${o?"opacity-50 cursor-not-allowed":""}`,children:[o?e.jsx(b,{className:"w-8 h-8 animate-spin text-azure-primary dark:text-matrix-primary"}):e.jsx(u,{className:"w-8 h-8 text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:o?"Uploading...":"Click to select ZIP file"})]})]}),c&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800",children:[e.jsx(W,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:c.error}),c.details&&e.jsx("p",{className:"text-xs text-red-600 dark:text-red-300 mt-1",children:c.details})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800",children:[e.jsx(F,{className:"w-5 h-5 text-green-600 dark:text-green-400"}),e.jsx("p",{className:"text-sm text-green-800 dark:text-green-200",children:w})]}),e.jsxs("div",{className:"rounded-lg bg-azure-hover dark:bg-zinc-900 p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight mb-2",children:"ZIP Structure Example"}),e.jsx("pre",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:`my-skill.zip
|
|
2
2
|
└── my-skill/
|
|
3
3
|
├── SKILL.md (required)
|
|
4
4
|
├── scripts/ (optional)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as c}from"./vendor-react-DikRIOlj.js";import{u as O}from"./vendor-utils-BIYveU_1.js";import{c as b}from"./config-7LGRnJ26.js";import{S as Q,T as C}from"./SelectInput-BPDcd3y7.js";import{S as V,N as w}from"./Switch-C7TxLq0E.js";import{C as Z}from"./ConfirmationModal-B3gHIVKY.js";import{h as ee,a4 as $,H as _,Y as te,ao as H,a8 as I,ae as re,ap as q,af as ae,aq as se,ar as ie,as as ne,y as le,G as de,n as oe,at as ce,g as me,ag as xe,K as he,X as ue}from"./vendor-icons-DE7PWdkN.js";import"./index-Db1XEN8v.js";const ge={name:"",host:"",port:7900,auth_token:"",tls:!1};function be(t){const n=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60);return n>0?`${n}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function pe(t,n){const i=t>=1024?`${(t/1024).toFixed(1)}GB`:`${Math.round(t)}MB`,o=n>=1024?`${(n/1024).toFixed(1)}GB`:`${Math.round(n)}MB`;return`${i} / ${o}`}function fe({state:t}){return t==="online"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"online"]}):t==="connecting"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),"connecting"]}):t==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-red-500 bg-red-500/10 border border-red-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"error"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-zinc-500 bg-zinc-500/10 border border-zinc-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-500"}),"offline"]})}function je({cap:t}){const i={filesystem:"text-blue-400 bg-blue-400/10 border-blue-400/30",shell:"text-yellow-400 bg-yellow-400/10 border-yellow-400/30",git:"text-orange-400 bg-orange-400/10 border-orange-400/30",browser:"text-purple-400 bg-purple-400/10 border-purple-400/30",network:"text-cyan-400 bg-cyan-400/10 border-cyan-400/30",packages:"text-green-400 bg-green-400/10 border-green-400/30",processes:"text-pink-400 bg-pink-400/10 border-pink-400/30",system:"text-indigo-400 bg-indigo-400/10 border-indigo-400/30"}[t]??"text-zinc-400 bg-zinc-400/10 border-zinc-400/30";return e.jsx("span",{className:`text-[10px] font-medium border rounded px-1.5 py-0.5 ${i}`,children:t})}function ye({status:t,entry:n,onPing:i,onEdit:o,onDelete:a}){const[l,h]=c.useState(!1),s=t.state==="online";return e.jsxs("div",{className:`rounded-lg border bg-white dark:bg-zinc-900 shadow-sm transition-all ${s?"border-emerald-500/40 dark:border-emerald-500/30":t.state==="error"?"border-red-500/40 dark:border-red-500/30":t.state==="connecting"?"border-amber-500/40 dark:border-amber-500/30":"border-azure-border dark:border-matrix-primary"}`,children:[e.jsxs("div",{className:"p-4 bg-white dark:bg-zinc-900 shadow-sm rounded-tl-lg rounded-tr-lg",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${s?"bg-emerald-500/10":"bg-zinc-100 dark:bg-zinc-900"}`,children:e.jsx(ie,{className:`w-4 h-4 ${s?"text-emerald-500":"text-zinc-400 dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-highlight truncate",children:t.name}),e.jsx(fe,{state:t.state}),n?.tls&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded px-1.5 py-0.5",children:[e.jsx(ne,{className:"w-2.5 h-2.5"}),"TLS"]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:[t.host,":",t.port]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>i(t.name),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Ping",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>o(n??{name:t.name,host:t.host,port:t.port,auth_token:"",tls:!1}),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Edit",children:e.jsx(le,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>a(t.name),className:"p-1.5 rounded border border-red-200 dark:border-red-800/50 text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-500 transition-colors",title:"Remove",children:e.jsx(de,{className:"w-3.5 h-3.5"})})]})]}),t.error&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded p-2",children:[e.jsx($,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{children:t.error})]}),s&&t.stats&&e.jsx("div",{className:"mt-3 space-y-2",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"OS"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:t.stats.os})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Hostname"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate max-w-[120px]",children:t.stats.hostname})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(oe,{className:"w-3 h-3"})," CPU"]}),e.jsxs("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:[t.stats.cpu_percent.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(ce,{className:"w-3 h-3"})," RAM"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:pe(t.stats.memory_used_mb,t.stats.memory_total_mb)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(me,{className:"w-3 h-3"})," Uptime"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:be(t.stats.uptime_seconds)})]}),t.config?.sandbox_dir&&e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:"Sandbox"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate text-right ml-2",children:t.config.sandbox_dir})]}),t.config&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Read-only"}),e.jsx("span",{className:`font-medium ${t.config.readonly_mode?"text-amber-500":"text-emerald-500"}`,children:t.config.readonly_mode?"yes":"no"})]})]})}),!s&&t.lastSeen&&e.jsxs("div",{className:"mt-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]}),t.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>h(!l),className:"w-full flex items-center justify-between px-4 py-2 border-t border-azure-border dark:border-matrix-primary/30 text-xs text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-secondary hover:bg-azure-surface/50 dark:hover:bg-zinc-900/50 transition-colors",children:[e.jsxs("span",{children:["Capabilities (",t.capabilities.length,")"]}),l?e.jsx(xe,{className:"w-3.5 h-3.5"}):e.jsx(he,{className:"w-3.5 h-3.5"})]}),l&&e.jsxs("div",{className:"px-4 pb-4 pt-3 border-t border-azure-border dark:border-matrix-primary/30 bg-azure-surface/30 dark:bg-zinc-900/30",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.capabilities.map(x=>e.jsx(je,{cap:x},x))}),t.lastSeen&&e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-3",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]})]})]})}function U({title:t,initial:n,isEdit:i,onSave:o,onClose:a,saving:l,error:h}){const[s,x]=c.useState(n),[j,p]=c.useState(null),f=()=>{if(!s.name.trim()){p("Name is required.");return}if(!s.host.trim()){p("Host is required.");return}if(!i&&!s.auth_token.trim()){p("Auth token is required.");return}p(null),o(s)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsxs("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(_,{className:"w-4 h-4"}),t]}),e.jsx("button",{onClick:a,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:e.jsx(ue,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[(j||h)&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded p-3",children:[e.jsx($,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsx("span",{children:j||h})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(C,{label:"Name",value:s.name,onChange:m=>x({...s,name:m.target.value}),disabled:i,helperText:i?"Name cannot be changed after creation.":"Unique identifier (lowercase, hyphens ok)."})}),e.jsx(C,{label:"Host",value:s.host,onChange:m=>x({...s,host:m.target.value}),placeholder:"localhost"}),e.jsx(w,{label:"Port",value:s.port,onChange:m=>x({...s,port:Number(m.target.value)}),min:1,max:65535}),e.jsx("div",{className:"col-span-2",children:e.jsx(C,{label:"Auth Token",value:s.auth_token,onChange:m=>x({...s,auth_token:m.target.value}),placeholder:i?"Leave blank to keep existing token":"Shared secret",helperText:i?"Leave blank to keep the current token.":void 0})})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",id:"smith-tls",checked:s.tls??!1,onChange:m=>x({...s,tls:m.target.checked}),className:"w-4 h-4 accent-azure-primary dark:accent-matrix-highlight"}),e.jsxs("label",{htmlFor:"smith-tls",className:"text-sm text-azure-text-secondary dark:text-matrix-secondary cursor-pointer",children:["Use TLS (",e.jsx("code",{className:"text-xs font-mono",children:"wss://"}),")"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 rounded text-sm text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:"Cancel"}),e.jsx("button",{onClick:f,disabled:l,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:l?"Saving…":i?"Update Smith":"Add Smith"})]})]})})}function Te(){const{data:t,mutate:n}=O("/api/smiths",b.getSmithsList,{refreshInterval:1e4}),{data:i,mutate:o}=O("/api/smiths/config",b.getSmithsConfig),[a,l]=c.useState(null),[h,s]=c.useState(!1),[x,j]=c.useState(!1),[p,f]=c.useState(!1),[m,z]=c.useState(null),[T,v]=c.useState(!1),[M,u]=c.useState(null),[N,A]=c.useState(null),[B,L]=c.useState(!1),[y,S]=c.useState(null);i&&!a&&l(i);const g=(r,d)=>{A({type:r,message:d}),setTimeout(()=>A(null),4e3)},G=async r=>{try{const d=await b.pingSmith(r);g("success",`Ping ${r}: ${d.latency_ms}ms`)}catch(d){g("error",`Ping failed: ${d.message}`)}},W=r=>{S(r)},K=async()=>{if(y)try{await b.removeSmith(y),n(),o(),l(null),g("success",`Smith "${y}" removed.`)}catch(r){g("error",`Failed to remove: ${r.message}`)}finally{S(null)}},Y=async r=>{if(a){if(a.entries.some(d=>d.name===r.name)){u(`Smith "${r.name}" already exists.`);return}v(!0),u(null);try{const d={...a,entries:[...a.entries,r]};await b.updateSmithsConfig(d),f(!1),l(null),n(),o(),g("success",`Smith "${r.name}" added.`)}catch(d){u(d.message)}finally{v(!1)}}},J=async r=>{if(a){v(!0),u(null);try{const d={...a,entries:a.entries.map(F=>F.name===r.name?r:F)};await b.updateSmithsConfig(d),z(null),l(null),n(),o(),g("success",`Smith "${r.name}" updated.`)}catch(d){u(d.message)}finally{v(!1)}}},X=async()=>{if(a){j(!0);try{await b.updateSmithsConfig(a),n(),o(),g("success","Settings saved."),s(!1)}catch(r){g("error",r.message)}finally{j(!1)}}},k=t?.smiths??[],P=k.filter(r=>r.state==="online").length,E=k.filter(r=>r.state==="offline"||r.state==="error").length,R=k.filter(r=>r.state==="connecting").length,D={};return(a??i)?.entries?.forEach(r=>{D[r.name]=r}),e.jsxs("div",{className:"space-y-6",children:[N&&e.jsxs("div",{className:`fixed top-4 right-4 z-50 flex items-center gap-2 px-4 py-3 rounded-lg shadow-xl text-sm border ${N.type==="success"?"bg-emerald-50 dark:bg-emerald-900/30 border-emerald-300 dark:border-emerald-500/50 text-emerald-700 dark:text-emerald-400":"bg-red-50 dark:bg-red-900/30 border-red-300 dark:border-red-500/50 text-red-700 dark:text-red-400"}`,children:[N.type==="success"?e.jsx(ee,{className:"w-4 h-4"}):e.jsx($,{className:"w-4 h-4"}),N.message]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(_,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Smiths"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Remote DevKit agents via WebSocket"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:async()=>{L(!0),await Promise.all([n(),o(),new Promise(r=>setTimeout(r,500))]),L(!1)},className:"p-2 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",title:"Refresh",children:e.jsx(te,{className:`w-4 h-4 transition-transform ${B?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{s(!h),!a&&i&&l(i)},className:`flex items-center gap-1.5 px-3 py-2 rounded border text-sm transition-colors ${h?"bg-azure-primary/10 border-azure-primary dark:bg-matrix-highlight/10 dark:border-matrix-highlight text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight"}`,children:[e.jsx(H,{className:"w-4 h-4"}),"Settings"]}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-1.5 px-3 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 text-sm font-medium transition-colors",children:[e.jsx(I,{className:"w-4 h-4"}),"Add Smith"]})]})]}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Total"}),e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-secondary",children:t.total})]}),P>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(re,{className:"w-3.5 h-3.5 text-emerald-500"}),e.jsxs("span",{className:"font-semibold text-emerald-500",children:[P," online"]})]}),R>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(q,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsxs("span",{className:"font-semibold text-amber-500",children:[R," connecting"]})]}),E>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(ae,{className:"w-3.5 h-3.5 text-zinc-400 dark:text-matrix-tertiary"}),e.jsxs("span",{className:"font-semibold text-zinc-500 dark:text-matrix-tertiary",children:[E," offline"]})]}),!t.enabled&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2.5 py-0.5",children:[e.jsx(se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Smiths subsystem disabled"})]})]}),h&&a&&e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-5 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-sm font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4"}),"Global Settings"]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx("div",{className:"sm:col-span-2",children:e.jsx(V,{label:"Enable Smiths",checked:a.enabled,onChange:r=>l({...a,enabled:r}),helperText:"Master switch — disabling stops all Smith connections."})}),e.jsx(Q,{label:"Execution Mode",value:a.execution_mode,onChange:r=>l({...a,execution_mode:r.target.value}),options:[{label:"Sync — inline result",value:"sync"},{label:"Async — background task",value:"async"}]}),e.jsx(w,{label:"Heartbeat Interval (s)",value:Math.round(a.heartbeat_interval_ms/1e3),onChange:r=>l({...a,heartbeat_interval_ms:Number(r.target.value)*1e3}),min:5}),e.jsx(w,{label:"Connection Timeout (s)",value:Math.round(a.connection_timeout_ms/1e3),onChange:r=>l({...a,connection_timeout_ms:Number(r.target.value)*1e3}),min:1}),e.jsx(w,{label:"Task Timeout (s)",value:Math.round(a.task_timeout_ms/1e3),onChange:r=>l({...a,task_timeout_ms:Number(r.target.value)*1e3}),min:5})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx("button",{onClick:X,disabled:x,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:x?"Saving…":"Save Settings"})})]}),k.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary flex items-center justify-center mb-4",children:e.jsx(_,{className:"w-7 h-7 text-azure-text-secondary dark:text-matrix-tertiary"})}),e.jsx("h3",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight mb-1",children:"No Smiths configured"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mb-4",children:"Add a remote agent to delegate DevKit tasks to isolated environments."}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-2 px-4 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black text-sm font-medium transition-colors",children:[e.jsx(I,{className:"w-4 h-4"}),"Add First Smith"]})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:k.map(r=>e.jsx(ye,{status:r,entry:D[r.name],onPing:G,onEdit:d=>{z({...d,auth_token:""}),u(null)},onDelete:W},r.name))}),p&&e.jsx(U,{title:"Add Smith",initial:ge,onSave:Y,onClose:()=>f(!1),saving:T,error:M}),m&&e.jsx(U,{title:"Edit Smith",initial:m,isEdit:!0,onSave:J,onClose:()=>z(null),saving:T,error:M}),e.jsx(Z,{isOpen:!!y,onClose:()=>S(null),onConfirm:K,title:"Remove Smith",description:`Are you sure you want to remove "${y}" from the registry? This action cannot be undone.`,confirmJson:"Remove",variant:"destructive"})]})}export{Te as SmithsPage};
|
|
1
|
+
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as c}from"./vendor-react-DikRIOlj.js";import{u as O}from"./vendor-utils-BIYveU_1.js";import{c as b}from"./config-OLGQFNJL.js";import{S as Q,T as C}from"./SelectInput-BPDcd3y7.js";import{S as V,N as w}from"./Switch-C7TxLq0E.js";import{C as Z}from"./ConfirmationModal-DU0AwhXD.js";import{h as ee,a4 as $,H as _,Y as te,ao as H,a8 as I,ae as re,ap as q,af as ae,aq as se,ar as ie,as as ne,y as le,G as de,n as oe,at as ce,g as me,ag as xe,K as he,X as ue}from"./vendor-icons-DE7PWdkN.js";import"./index-B9ePr-vB.js";const ge={name:"",host:"",port:7900,auth_token:"",tls:!1};function be(t){const n=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60);return n>0?`${n}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function pe(t,n){const i=t>=1024?`${(t/1024).toFixed(1)}GB`:`${Math.round(t)}MB`,o=n>=1024?`${(n/1024).toFixed(1)}GB`:`${Math.round(n)}MB`;return`${i} / ${o}`}function fe({state:t}){return t==="online"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"online"]}):t==="connecting"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),"connecting"]}):t==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-red-500 bg-red-500/10 border border-red-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"error"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-zinc-500 bg-zinc-500/10 border border-zinc-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-500"}),"offline"]})}function je({cap:t}){const i={filesystem:"text-blue-400 bg-blue-400/10 border-blue-400/30",shell:"text-yellow-400 bg-yellow-400/10 border-yellow-400/30",git:"text-orange-400 bg-orange-400/10 border-orange-400/30",browser:"text-purple-400 bg-purple-400/10 border-purple-400/30",network:"text-cyan-400 bg-cyan-400/10 border-cyan-400/30",packages:"text-green-400 bg-green-400/10 border-green-400/30",processes:"text-pink-400 bg-pink-400/10 border-pink-400/30",system:"text-indigo-400 bg-indigo-400/10 border-indigo-400/30"}[t]??"text-zinc-400 bg-zinc-400/10 border-zinc-400/30";return e.jsx("span",{className:`text-[10px] font-medium border rounded px-1.5 py-0.5 ${i}`,children:t})}function ye({status:t,entry:n,onPing:i,onEdit:o,onDelete:a}){const[l,h]=c.useState(!1),s=t.state==="online";return e.jsxs("div",{className:`rounded-lg border bg-white dark:bg-zinc-900 shadow-sm transition-all ${s?"border-emerald-500/40 dark:border-emerald-500/30":t.state==="error"?"border-red-500/40 dark:border-red-500/30":t.state==="connecting"?"border-amber-500/40 dark:border-amber-500/30":"border-azure-border dark:border-matrix-primary"}`,children:[e.jsxs("div",{className:"p-4 bg-white dark:bg-zinc-900 shadow-sm rounded-tl-lg rounded-tr-lg",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${s?"bg-emerald-500/10":"bg-zinc-100 dark:bg-zinc-900"}`,children:e.jsx(ie,{className:`w-4 h-4 ${s?"text-emerald-500":"text-zinc-400 dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-highlight truncate",children:t.name}),e.jsx(fe,{state:t.state}),n?.tls&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded px-1.5 py-0.5",children:[e.jsx(ne,{className:"w-2.5 h-2.5"}),"TLS"]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:[t.host,":",t.port]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>i(t.name),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Ping",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>o(n??{name:t.name,host:t.host,port:t.port,auth_token:"",tls:!1}),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Edit",children:e.jsx(le,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>a(t.name),className:"p-1.5 rounded border border-red-200 dark:border-red-800/50 text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-500 transition-colors",title:"Remove",children:e.jsx(de,{className:"w-3.5 h-3.5"})})]})]}),t.error&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded p-2",children:[e.jsx($,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{children:t.error})]}),s&&t.stats&&e.jsx("div",{className:"mt-3 space-y-2",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"OS"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:t.stats.os})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Hostname"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate max-w-[120px]",children:t.stats.hostname})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(oe,{className:"w-3 h-3"})," CPU"]}),e.jsxs("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:[t.stats.cpu_percent.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(ce,{className:"w-3 h-3"})," RAM"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:pe(t.stats.memory_used_mb,t.stats.memory_total_mb)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(me,{className:"w-3 h-3"})," Uptime"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:be(t.stats.uptime_seconds)})]}),t.config?.sandbox_dir&&e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:"Sandbox"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate text-right ml-2",children:t.config.sandbox_dir})]}),t.config&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Read-only"}),e.jsx("span",{className:`font-medium ${t.config.readonly_mode?"text-amber-500":"text-emerald-500"}`,children:t.config.readonly_mode?"yes":"no"})]})]})}),!s&&t.lastSeen&&e.jsxs("div",{className:"mt-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]}),t.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>h(!l),className:"w-full flex items-center justify-between px-4 py-2 border-t border-azure-border dark:border-matrix-primary/30 text-xs text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-secondary hover:bg-azure-surface/50 dark:hover:bg-zinc-900/50 transition-colors",children:[e.jsxs("span",{children:["Capabilities (",t.capabilities.length,")"]}),l?e.jsx(xe,{className:"w-3.5 h-3.5"}):e.jsx(he,{className:"w-3.5 h-3.5"})]}),l&&e.jsxs("div",{className:"px-4 pb-4 pt-3 border-t border-azure-border dark:border-matrix-primary/30 bg-azure-surface/30 dark:bg-zinc-900/30",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.capabilities.map(x=>e.jsx(je,{cap:x},x))}),t.lastSeen&&e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-3",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]})]})]})}function U({title:t,initial:n,isEdit:i,onSave:o,onClose:a,saving:l,error:h}){const[s,x]=c.useState(n),[j,p]=c.useState(null),f=()=>{if(!s.name.trim()){p("Name is required.");return}if(!s.host.trim()){p("Host is required.");return}if(!i&&!s.auth_token.trim()){p("Auth token is required.");return}p(null),o(s)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsxs("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(_,{className:"w-4 h-4"}),t]}),e.jsx("button",{onClick:a,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:e.jsx(ue,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[(j||h)&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded p-3",children:[e.jsx($,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsx("span",{children:j||h})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(C,{label:"Name",value:s.name,onChange:m=>x({...s,name:m.target.value}),disabled:i,helperText:i?"Name cannot be changed after creation.":"Unique identifier (lowercase, hyphens ok)."})}),e.jsx(C,{label:"Host",value:s.host,onChange:m=>x({...s,host:m.target.value}),placeholder:"localhost"}),e.jsx(w,{label:"Port",value:s.port,onChange:m=>x({...s,port:Number(m.target.value)}),min:1,max:65535}),e.jsx("div",{className:"col-span-2",children:e.jsx(C,{label:"Auth Token",value:s.auth_token,onChange:m=>x({...s,auth_token:m.target.value}),placeholder:i?"Leave blank to keep existing token":"Shared secret",helperText:i?"Leave blank to keep the current token.":void 0})})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",id:"smith-tls",checked:s.tls??!1,onChange:m=>x({...s,tls:m.target.checked}),className:"w-4 h-4 accent-azure-primary dark:accent-matrix-highlight"}),e.jsxs("label",{htmlFor:"smith-tls",className:"text-sm text-azure-text-secondary dark:text-matrix-secondary cursor-pointer",children:["Use TLS (",e.jsx("code",{className:"text-xs font-mono",children:"wss://"}),")"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 rounded text-sm text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:"Cancel"}),e.jsx("button",{onClick:f,disabled:l,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:l?"Saving…":i?"Update Smith":"Add Smith"})]})]})})}function Te(){const{data:t,mutate:n}=O("/api/smiths",b.getSmithsList,{refreshInterval:1e4}),{data:i,mutate:o}=O("/api/smiths/config",b.getSmithsConfig),[a,l]=c.useState(null),[h,s]=c.useState(!1),[x,j]=c.useState(!1),[p,f]=c.useState(!1),[m,z]=c.useState(null),[T,v]=c.useState(!1),[M,u]=c.useState(null),[N,A]=c.useState(null),[B,L]=c.useState(!1),[y,S]=c.useState(null);i&&!a&&l(i);const g=(r,d)=>{A({type:r,message:d}),setTimeout(()=>A(null),4e3)},G=async r=>{try{const d=await b.pingSmith(r);g("success",`Ping ${r}: ${d.latency_ms}ms`)}catch(d){g("error",`Ping failed: ${d.message}`)}},W=r=>{S(r)},K=async()=>{if(y)try{await b.removeSmith(y),n(),o(),l(null),g("success",`Smith "${y}" removed.`)}catch(r){g("error",`Failed to remove: ${r.message}`)}finally{S(null)}},Y=async r=>{if(a){if(a.entries.some(d=>d.name===r.name)){u(`Smith "${r.name}" already exists.`);return}v(!0),u(null);try{const d={...a,entries:[...a.entries,r]};await b.updateSmithsConfig(d),f(!1),l(null),n(),o(),g("success",`Smith "${r.name}" added.`)}catch(d){u(d.message)}finally{v(!1)}}},J=async r=>{if(a){v(!0),u(null);try{const d={...a,entries:a.entries.map(F=>F.name===r.name?r:F)};await b.updateSmithsConfig(d),z(null),l(null),n(),o(),g("success",`Smith "${r.name}" updated.`)}catch(d){u(d.message)}finally{v(!1)}}},X=async()=>{if(a){j(!0);try{await b.updateSmithsConfig(a),n(),o(),g("success","Settings saved."),s(!1)}catch(r){g("error",r.message)}finally{j(!1)}}},k=t?.smiths??[],P=k.filter(r=>r.state==="online").length,E=k.filter(r=>r.state==="offline"||r.state==="error").length,R=k.filter(r=>r.state==="connecting").length,D={};return(a??i)?.entries?.forEach(r=>{D[r.name]=r}),e.jsxs("div",{className:"space-y-6",children:[N&&e.jsxs("div",{className:`fixed top-4 right-4 z-50 flex items-center gap-2 px-4 py-3 rounded-lg shadow-xl text-sm border ${N.type==="success"?"bg-emerald-50 dark:bg-emerald-900/30 border-emerald-300 dark:border-emerald-500/50 text-emerald-700 dark:text-emerald-400":"bg-red-50 dark:bg-red-900/30 border-red-300 dark:border-red-500/50 text-red-700 dark:text-red-400"}`,children:[N.type==="success"?e.jsx(ee,{className:"w-4 h-4"}):e.jsx($,{className:"w-4 h-4"}),N.message]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(_,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Smiths"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Remote DevKit agents via WebSocket"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:async()=>{L(!0),await Promise.all([n(),o(),new Promise(r=>setTimeout(r,500))]),L(!1)},className:"p-2 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",title:"Refresh",children:e.jsx(te,{className:`w-4 h-4 transition-transform ${B?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{s(!h),!a&&i&&l(i)},className:`flex items-center gap-1.5 px-3 py-2 rounded border text-sm transition-colors ${h?"bg-azure-primary/10 border-azure-primary dark:bg-matrix-highlight/10 dark:border-matrix-highlight text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight"}`,children:[e.jsx(H,{className:"w-4 h-4"}),"Settings"]}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-1.5 px-3 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 text-sm font-medium transition-colors",children:[e.jsx(I,{className:"w-4 h-4"}),"Add Smith"]})]})]}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Total"}),e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-secondary",children:t.total})]}),P>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(re,{className:"w-3.5 h-3.5 text-emerald-500"}),e.jsxs("span",{className:"font-semibold text-emerald-500",children:[P," online"]})]}),R>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(q,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsxs("span",{className:"font-semibold text-amber-500",children:[R," connecting"]})]}),E>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(ae,{className:"w-3.5 h-3.5 text-zinc-400 dark:text-matrix-tertiary"}),e.jsxs("span",{className:"font-semibold text-zinc-500 dark:text-matrix-tertiary",children:[E," offline"]})]}),!t.enabled&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2.5 py-0.5",children:[e.jsx(se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Smiths subsystem disabled"})]})]}),h&&a&&e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-5 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-sm font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4"}),"Global Settings"]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx("div",{className:"sm:col-span-2",children:e.jsx(V,{label:"Enable Smiths",checked:a.enabled,onChange:r=>l({...a,enabled:r}),helperText:"Master switch — disabling stops all Smith connections."})}),e.jsx(Q,{label:"Execution Mode",value:a.execution_mode,onChange:r=>l({...a,execution_mode:r.target.value}),options:[{label:"Sync — inline result",value:"sync"},{label:"Async — background task",value:"async"}]}),e.jsx(w,{label:"Heartbeat Interval (s)",value:Math.round(a.heartbeat_interval_ms/1e3),onChange:r=>l({...a,heartbeat_interval_ms:Number(r.target.value)*1e3}),min:5}),e.jsx(w,{label:"Connection Timeout (s)",value:Math.round(a.connection_timeout_ms/1e3),onChange:r=>l({...a,connection_timeout_ms:Number(r.target.value)*1e3}),min:1}),e.jsx(w,{label:"Task Timeout (s)",value:Math.round(a.task_timeout_ms/1e3),onChange:r=>l({...a,task_timeout_ms:Number(r.target.value)*1e3}),min:5})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx("button",{onClick:X,disabled:x,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:x?"Saving…":"Save Settings"})})]}),k.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary flex items-center justify-center mb-4",children:e.jsx(_,{className:"w-7 h-7 text-azure-text-secondary dark:text-matrix-tertiary"})}),e.jsx("h3",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight mb-1",children:"No Smiths configured"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mb-4",children:"Add a remote agent to delegate DevKit tasks to isolated environments."}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-2 px-4 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black text-sm font-medium transition-colors",children:[e.jsx(I,{className:"w-4 h-4"}),"Add First Smith"]})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:k.map(r=>e.jsx(ye,{status:r,entry:D[r.name],onPing:G,onEdit:d=>{z({...d,auth_token:""}),u(null)},onDelete:W},r.name))}),p&&e.jsx(U,{title:"Add Smith",initial:ge,onSave:Y,onClose:()=>f(!1),saving:T,error:M}),m&&e.jsx(U,{title:"Edit Smith",initial:m,isEdit:!0,onSave:J,onClose:()=>z(null),saving:T,error:M}),e.jsx(Z,{isOpen:!!y,onClose:()=>S(null),onConfirm:K,title:"Remove Smith",description:`Are you sure you want to remove "${y}" from the registry? This action cannot be undone.`,confirmJson:"Remove",variant:"destructive"})]})}export{Te as SmithsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,m as l}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as S}from"./vendor-utils-BIYveU_1.js";import{t as m}from"./index-Db1XEN8v.js";import{P as B}from"./Pagination-D4ShqUKO.js";import{u as E}from"./agents-CN_AKX_I.js";import{f as D,Y as O,a0 as M,ad as K,r as W,s as _,t as X,g as U,X as V,a4 as Y}from"./vendor-icons-DE7PWdkN.js";const q={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},u={hidden:{opacity:0,y:8},show:{opacity:1,y:0}},G={pending:"Pending",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function F({status:r}){const t="inline-flex items-center gap-1 text-xs font-medium rounded-full px-2 py-0.5 border";return r==="completed"?e.jsxs("span",{className:`${t} text-emerald-600 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-900/20 border-emerald-200 dark:border-emerald-700/50`,children:[e.jsx(W,{className:"w-3 h-3"}),"Completed"]}):r==="failed"?e.jsxs("span",{className:`${t} text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-700/50`,children:[e.jsx(_,{className:"w-3 h-3"}),"Failed"]}):r==="running"?e.jsxs("span",{className:`${t} text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-700/50`,children:[e.jsx(X,{className:"w-3 h-3 animate-spin"}),"Running"]}):r==="cancelled"?e.jsxs("span",{className:`${t} text-zinc-500 dark:text-zinc-400 bg-zinc-100 dark:bg-zinc-900 border-zinc-200 dark:border-zinc-700`,children:[e.jsx(_,{className:"w-3 h-3"}),"Cancelled"]}):e.jsxs("span",{className:`${t} text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-700/50`,children:[e.jsx(U,{className:"w-3 h-3"}),"Pending"]})}function R({agent:r}){return e.jsx("span",{className:"inline-flex items-center text-[10px] font-medium font-mono rounded px-1.5 py-0.5 border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary uppercase",children:r})}function $({channel:r}){return e.jsx("span",{className:"inline-flex items-center text-[10px] font-medium rounded px-1.5 py-0.5 border border-zinc-200 dark:border-zinc-700 bg-zinc-100 dark:bg-zinc-900 text-zinc-500 dark:text-zinc-400 uppercase",children:r})}const P=r=>r?new Date(r).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"—",A=r=>r?new Date(r).toLocaleString():"—";function H({task:r,onClose:t,onCancel:o,onRetry:k}){const h=r.status==="pending"||r.status==="running",d=r.status==="failed";return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(D,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight",children:"Task Details"}),e.jsx(F,{status:r.status})]}),e.jsx("p",{className:"text-xs font-mono text-azure-text-secondary dark:text-matrix-tertiary mt-0.5 truncate",children:r.id})]})]}),e.jsx("button",{onClick:t,className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(V,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[e.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2 text-sm",children:[{label:"Agent",value:e.jsx(R,{agent:r.agent})},{label:"Channel",value:e.jsx($,{channel:r.origin_channel})},{label:"Attempts",value:`${r.attempt_count} / ${r.max_attempts}`},{label:"Session",value:e.jsx("span",{className:"font-mono text-xs",children:r.session_id})},{label:"Created",value:A(r.created_at)},{label:"Finished",value:A(r.finished_at)}].map(({label:p,value:c})=>e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:p}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary",children:c})]},p))}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Input"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-48 whitespace-pre-wrap leading-relaxed font-mono",children:r.input})]}),r.output&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Output"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-64 whitespace-pre-wrap leading-relaxed font-mono",children:r.output})]}),r.error&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-red-500 mb-2 flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"})," Error"]}),e.jsx("pre",{className:"rounded-lg bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-800/50 p-4 text-xs text-red-600 dark:text-red-400 overflow-auto max-h-48 whitespace-pre-wrap leading-relaxed font-mono",children:r.error})]})]}),(h||d)&&e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-azure-border dark:border-matrix-primary shrink-0",children:[h&&e.jsx("button",{onClick:o,className:"px-4 py-2 rounded text-sm border border-red-300 dark:border-red-700/60 text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:"Cancel Task"}),d&&e.jsx("button",{onClick:k,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors",children:"Retry Task"})]})]})]})}const J={Pending:"text-yellow-600 dark:text-yellow-400",Running:"text-blue-600 dark:text-blue-400",Completed:"text-emerald-600 dark:text-emerald-400",Failed:"text-red-600 dark:text-red-400",Cancelled:"text-zinc-500 dark:text-zinc-400",Total:"text-azure-text dark:text-matrix-highlight"};function n({label:r,value:t}){return e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:r}),e.jsx("p",{className:`text-2xl font-bold mt-0.5 ${J[r]??"text-azure-text dark:text-matrix-secondary"}`,children:t})]})}function de(){const[r,t]=s.useState(""),[o,k]=s.useState(""),{getSubagents:h}=E(),[d,p]=s.useState(""),[c,T]=s.useState(""),[b,g]=s.useState(null),[f,v]=s.useState(1),[w,I]=s.useState(20),z=s.useMemo(()=>({status:r||void 0,agent:o||void 0,origin_channel:d||void 0,session_id:c.trim()||void 0,page:f,per_page:w}),[r,o,d,c,f,w]),y=()=>v(1),{data:i}=S("/tasks/stats",()=>m.stats(),{refreshInterval:5e3}),{data:x,mutate:N}=S(["/tasks",z],()=>m.list(z),{refreshInterval:3e3}),C=x?.data??[],j="px-3 py-2 rounded border border-azure-border dark:border-matrix-primary bg-white dark:bg-black text-azure-text dark:text-matrix-secondary text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight";return e.jsxs(l.div,{variants:q,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(l.div,{variants:u,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(D,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Tasks"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Async tasks delegated by Oracle and processed by workers."})]})]}),e.jsxs(l.div,{variants:u,className:"grid grid-cols-3 md:grid-cols-6 gap-3",children:[e.jsx(n,{label:"Pending",value:i?.pending??0}),e.jsx(n,{label:"Running",value:i?.running??0}),e.jsx(n,{label:"Completed",value:i?.completed??0}),e.jsx(n,{label:"Failed",value:i?.failed??0}),e.jsx(n,{label:"Cancelled",value:i?.cancelled??0}),e.jsx(n,{label:"Total",value:i?.total??0})]}),e.jsxs(l.div,{variants:u,className:"rounded-lg border border-azure-border dark:border-matrix-primary p-4 bg-white dark:bg-black grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("select",{className:j,value:r,onChange:a=>{t(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All status"}),Object.entries(G).map(([a,L])=>e.jsx("option",{value:a,children:L},a))]}),e.jsxs("select",{className:j,value:o,onChange:a=>{k(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All agents"}),h().map(a=>e.jsx("option",{value:a.agentKey,children:a.label},a.agentKey))]}),e.jsxs("select",{className:j,value:d,onChange:a=>{p(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All channels"}),e.jsx("option",{value:"telegram",children:"Telegram"}),e.jsx("option",{value:"discord",children:"Discord"}),e.jsx("option",{value:"ui",children:"UI"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"webhook",children:"Webhook"}),e.jsx("option",{value:"cli",children:"CLI"})]}),e.jsx("input",{className:`${j} placeholder:text-azure-text-secondary/50 dark:placeholder:text-matrix-secondary/40`,value:c,onChange:a=>{T(a.target.value),y()},placeholder:"Filter by session ID"})]}),e.jsx(l.div,{variants:u,className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[820px]",children:[e.jsx("thead",{className:"bg-azure-surface dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary",children:e.jsx("tr",{children:[{label:"ID",cls:"w-24"},{label:"Status",cls:"w-32"},{label:"Agent",cls:"w-24"},{label:"Channel",cls:"w-24"},{label:"Session",cls:"w-28"},{label:"Attempts",cls:"w-20"},{label:"Created",cls:"w-36"},{label:"Finished",cls:"w-36"},{label:"",cls:"w-16"}].map(a=>e.jsx("th",{className:`text-left px-4 py-3 text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary ${a.cls}`,children:a.label},a.label))})}),e.jsx("tbody",{children:C.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:9,className:"px-4 py-12 text-center text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(O,{className:"w-5 h-5 mx-auto mb-2 opacity-40"}),"No tasks found."]})}):C.map(a=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 hover:bg-azure-surface/60 dark:hover:bg-zinc-900/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:a.id.slice(0,8)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(F,{status:a.status})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(R,{agent:a.agent})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx($,{channel:a.origin_channel})}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:a.session_id?a.session_id.slice(0,10):"—"}),e.jsxs("td",{className:"px-4 py-3 text-center text-azure-text-secondary dark:text-matrix-secondary text-xs",children:[a.attempt_count,"/",a.max_attempts]}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-secondary whitespace-nowrap",children:P(a.created_at)}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-secondary whitespace-nowrap",children:P(a.finished_at)}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>g(a),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(M,{className:"w-3.5 h-3.5"})}),(a.status==="pending"||a.status==="running")&&e.jsx("button",{onClick:async()=>{await m.cancel(a.id),N()},className:"p-1.5 rounded border border-red-200 dark:border-red-800/50 text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-500 transition-colors",title:"Cancel task",children:e.jsx(K,{className:"w-3.5 h-3.5"})})]})})]},a.id))})]})})}),x&&x.total_pages>1&&e.jsx(l.div,{variants:u,children:e.jsx("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black",children:e.jsx(B,{page:f,totalPages:x.total_pages,perPage:w,total:x.total,onPageChange:v,onPerPageChange:a=>{I(a),v(1)}})})}),b&&e.jsx(H,{task:b,onClose:()=>g(null),onCancel:async()=>{await m.cancel(b.id),g(null),N()},onRetry:async()=>{await m.retry(b.id),g(null),N()}})]})}export{de as TasksPage};
|
|
1
|
+
import{j as e,m as l}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as S}from"./vendor-utils-BIYveU_1.js";import{t as m}from"./index-B9ePr-vB.js";import{P as B}from"./Pagination-D4ShqUKO.js";import{u as E}from"./agents-DO69pNM1.js";import{f as D,Y as O,a0 as M,ad as K,r as W,s as _,t as X,g as U,X as V,a4 as Y}from"./vendor-icons-DE7PWdkN.js";const q={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},u={hidden:{opacity:0,y:8},show:{opacity:1,y:0}},G={pending:"Pending",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function F({status:r}){const t="inline-flex items-center gap-1 text-xs font-medium rounded-full px-2 py-0.5 border";return r==="completed"?e.jsxs("span",{className:`${t} text-emerald-600 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-900/20 border-emerald-200 dark:border-emerald-700/50`,children:[e.jsx(W,{className:"w-3 h-3"}),"Completed"]}):r==="failed"?e.jsxs("span",{className:`${t} text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-700/50`,children:[e.jsx(_,{className:"w-3 h-3"}),"Failed"]}):r==="running"?e.jsxs("span",{className:`${t} text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-700/50`,children:[e.jsx(X,{className:"w-3 h-3 animate-spin"}),"Running"]}):r==="cancelled"?e.jsxs("span",{className:`${t} text-zinc-500 dark:text-zinc-400 bg-zinc-100 dark:bg-zinc-900 border-zinc-200 dark:border-zinc-700`,children:[e.jsx(_,{className:"w-3 h-3"}),"Cancelled"]}):e.jsxs("span",{className:`${t} text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-700/50`,children:[e.jsx(U,{className:"w-3 h-3"}),"Pending"]})}function R({agent:r}){return e.jsx("span",{className:"inline-flex items-center text-[10px] font-medium font-mono rounded px-1.5 py-0.5 border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary uppercase",children:r})}function $({channel:r}){return e.jsx("span",{className:"inline-flex items-center text-[10px] font-medium rounded px-1.5 py-0.5 border border-zinc-200 dark:border-zinc-700 bg-zinc-100 dark:bg-zinc-900 text-zinc-500 dark:text-zinc-400 uppercase",children:r})}const P=r=>r?new Date(r).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"—",A=r=>r?new Date(r).toLocaleString():"—";function H({task:r,onClose:t,onCancel:o,onRetry:k}){const h=r.status==="pending"||r.status==="running",d=r.status==="failed";return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(D,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight",children:"Task Details"}),e.jsx(F,{status:r.status})]}),e.jsx("p",{className:"text-xs font-mono text-azure-text-secondary dark:text-matrix-tertiary mt-0.5 truncate",children:r.id})]})]}),e.jsx("button",{onClick:t,className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(V,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[e.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2 text-sm",children:[{label:"Agent",value:e.jsx(R,{agent:r.agent})},{label:"Channel",value:e.jsx($,{channel:r.origin_channel})},{label:"Attempts",value:`${r.attempt_count} / ${r.max_attempts}`},{label:"Session",value:e.jsx("span",{className:"font-mono text-xs",children:r.session_id})},{label:"Created",value:A(r.created_at)},{label:"Finished",value:A(r.finished_at)}].map(({label:p,value:c})=>e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:p}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary",children:c})]},p))}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Input"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-48 whitespace-pre-wrap leading-relaxed font-mono",children:r.input})]}),r.output&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Output"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-64 whitespace-pre-wrap leading-relaxed font-mono",children:r.output})]}),r.error&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-red-500 mb-2 flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"})," Error"]}),e.jsx("pre",{className:"rounded-lg bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-800/50 p-4 text-xs text-red-600 dark:text-red-400 overflow-auto max-h-48 whitespace-pre-wrap leading-relaxed font-mono",children:r.error})]})]}),(h||d)&&e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-azure-border dark:border-matrix-primary shrink-0",children:[h&&e.jsx("button",{onClick:o,className:"px-4 py-2 rounded text-sm border border-red-300 dark:border-red-700/60 text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:"Cancel Task"}),d&&e.jsx("button",{onClick:k,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors",children:"Retry Task"})]})]})]})}const J={Pending:"text-yellow-600 dark:text-yellow-400",Running:"text-blue-600 dark:text-blue-400",Completed:"text-emerald-600 dark:text-emerald-400",Failed:"text-red-600 dark:text-red-400",Cancelled:"text-zinc-500 dark:text-zinc-400",Total:"text-azure-text dark:text-matrix-highlight"};function n({label:r,value:t}){return e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:r}),e.jsx("p",{className:`text-2xl font-bold mt-0.5 ${J[r]??"text-azure-text dark:text-matrix-secondary"}`,children:t})]})}function de(){const[r,t]=s.useState(""),[o,k]=s.useState(""),{getSubagents:h}=E(),[d,p]=s.useState(""),[c,T]=s.useState(""),[b,g]=s.useState(null),[f,v]=s.useState(1),[w,I]=s.useState(20),z=s.useMemo(()=>({status:r||void 0,agent:o||void 0,origin_channel:d||void 0,session_id:c.trim()||void 0,page:f,per_page:w}),[r,o,d,c,f,w]),y=()=>v(1),{data:i}=S("/tasks/stats",()=>m.stats(),{refreshInterval:5e3}),{data:x,mutate:N}=S(["/tasks",z],()=>m.list(z),{refreshInterval:3e3}),C=x?.data??[],j="px-3 py-2 rounded border border-azure-border dark:border-matrix-primary bg-white dark:bg-black text-azure-text dark:text-matrix-secondary text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight";return e.jsxs(l.div,{variants:q,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(l.div,{variants:u,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(D,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Tasks"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Async tasks delegated by Oracle and processed by workers."})]})]}),e.jsxs(l.div,{variants:u,className:"grid grid-cols-3 md:grid-cols-6 gap-3",children:[e.jsx(n,{label:"Pending",value:i?.pending??0}),e.jsx(n,{label:"Running",value:i?.running??0}),e.jsx(n,{label:"Completed",value:i?.completed??0}),e.jsx(n,{label:"Failed",value:i?.failed??0}),e.jsx(n,{label:"Cancelled",value:i?.cancelled??0}),e.jsx(n,{label:"Total",value:i?.total??0})]}),e.jsxs(l.div,{variants:u,className:"rounded-lg border border-azure-border dark:border-matrix-primary p-4 bg-white dark:bg-black grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("select",{className:j,value:r,onChange:a=>{t(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All status"}),Object.entries(G).map(([a,L])=>e.jsx("option",{value:a,children:L},a))]}),e.jsxs("select",{className:j,value:o,onChange:a=>{k(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All agents"}),h().map(a=>e.jsx("option",{value:a.agentKey,children:a.label},a.agentKey))]}),e.jsxs("select",{className:j,value:d,onChange:a=>{p(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All channels"}),e.jsx("option",{value:"telegram",children:"Telegram"}),e.jsx("option",{value:"discord",children:"Discord"}),e.jsx("option",{value:"ui",children:"UI"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"webhook",children:"Webhook"}),e.jsx("option",{value:"cli",children:"CLI"})]}),e.jsx("input",{className:`${j} placeholder:text-azure-text-secondary/50 dark:placeholder:text-matrix-secondary/40`,value:c,onChange:a=>{T(a.target.value),y()},placeholder:"Filter by session ID"})]}),e.jsx(l.div,{variants:u,className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[820px]",children:[e.jsx("thead",{className:"bg-azure-surface dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary",children:e.jsx("tr",{children:[{label:"ID",cls:"w-24"},{label:"Status",cls:"w-32"},{label:"Agent",cls:"w-24"},{label:"Channel",cls:"w-24"},{label:"Session",cls:"w-28"},{label:"Attempts",cls:"w-20"},{label:"Created",cls:"w-36"},{label:"Finished",cls:"w-36"},{label:"",cls:"w-16"}].map(a=>e.jsx("th",{className:`text-left px-4 py-3 text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary ${a.cls}`,children:a.label},a.label))})}),e.jsx("tbody",{children:C.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:9,className:"px-4 py-12 text-center text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(O,{className:"w-5 h-5 mx-auto mb-2 opacity-40"}),"No tasks found."]})}):C.map(a=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 hover:bg-azure-surface/60 dark:hover:bg-zinc-900/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:a.id.slice(0,8)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(F,{status:a.status})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(R,{agent:a.agent})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx($,{channel:a.origin_channel})}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:a.session_id?a.session_id.slice(0,10):"—"}),e.jsxs("td",{className:"px-4 py-3 text-center text-azure-text-secondary dark:text-matrix-secondary text-xs",children:[a.attempt_count,"/",a.max_attempts]}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-secondary whitespace-nowrap",children:P(a.created_at)}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-secondary whitespace-nowrap",children:P(a.finished_at)}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>g(a),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(M,{className:"w-3.5 h-3.5"})}),(a.status==="pending"||a.status==="running")&&e.jsx("button",{onClick:async()=>{await m.cancel(a.id),N()},className:"p-1.5 rounded border border-red-200 dark:border-red-800/50 text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-500 transition-colors",title:"Cancel task",children:e.jsx(K,{className:"w-3.5 h-3.5"})})]})})]},a.id))})]})})}),x&&x.total_pages>1&&e.jsx(l.div,{variants:u,children:e.jsx("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black",children:e.jsx(B,{page:f,totalPages:x.total_pages,perPage:w,total:x.total,onPageChange:v,onPerPageChange:a=>{I(a),v(1)}})})}),b&&e.jsx(H,{task:b,onClose:()=>g(null),onCancel:async()=>{await m.cancel(b.id),g(null),N()},onRetry:async()=>{await m.retry(b.id),g(null),N()}})]})}export{de as TasksPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as l}from"./vendor-react-DikRIOlj.js";import{u as ne,m as C}from"./vendor-utils-BIYveU_1.js";import{h as u}from"./index-Db1XEN8v.js";import{C as oe}from"./ConfirmationModal-B3gHIVKY.js";import{D as S,a8 as de,ae as D,af as ce,h as B,Y as me,G as xe,K as he,q as pe,X as ue}from"./vendor-icons-DE7PWdkN.js";const T={postgresql:5432,mysql:3306,mongodb:27017,sqlite:0},H={name:"",type:"postgresql",host:"",port:"",database_name:"",username:"",password:"",connection_string:"",allow_read:!0,allow_insert:!1,allow_update:!1,allow_delete:!1,allow_ddl:!1},ge={postgresql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mysql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],sqlite:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mongodb:[{key:"allow_read",label:"find / aggregate",description:"Permite consultas e agregações"},{key:"allow_insert",label:"insertOne / insertMany",description:"Permite inserir documentos"},{key:"allow_update",label:"updateOne / updateMany",description:"Permite atualizar documentos"},{key:"allow_delete",label:"deleteOne / deleteMany",description:"Permite excluir documentos"},{key:"allow_ddl",label:"Schema changes",description:"createCollection / dropCollection / createIndex"}]};async function be(){return u.get("/trinity/databases")}function we(){const{data:v,error:R}=ne("/trinity/databases",be,{refreshInterval:3e4}),[W,h]=l.useState(!1),[o,P]=l.useState(null),[r,n]=l.useState(H),[L,w]=l.useState(!1),[z,g]=l.useState(null),[G,Q]=l.useState({}),[q,$]=l.useState(null),[J,M]=l.useState({}),[O,A]=l.useState(null),[Y,I]=l.useState(null),[f,_]=l.useState(null),[b,y]=l.useState(!1),K=()=>{P(null),n(H),y(!1),g(null),h(!0)},X=a=>{P(a),n({name:a.name,type:a.type,host:a.host||"",port:a.port?String(a.port):"",database_name:a.database_name||"",username:a.username||"",password:"",connection_string:"",allow_read:a.allow_read,allow_insert:a.allow_insert,allow_update:a.allow_update,allow_delete:a.allow_delete,allow_ddl:a.allow_ddl}),y(!!a.connection_string),g(null),h(!0)},V=async()=>{if(w(!0),g(null),!b&&!r.database_name.trim()){g(r.type==="sqlite"?"File path is required.":"Database name is required."),w(!1);return}try{const a={name:r.name,type:r.type,allow_read:r.allow_read,allow_insert:r.allow_insert,allow_update:r.allow_update,allow_delete:r.allow_delete,allow_ddl:r.allow_ddl};b?(!o||r.connection_string)&&(a.connection_string=r.connection_string||null):(a.host=r.host||null,a.port=r.port?parseInt(r.port):null,a.database_name=r.database_name||null,a.username=r.username||null,(!o||r.password)&&(a.password=r.password||null)),o?await u.put(`/trinity/databases/${o.id}`,a):await u.post("/trinity/databases",a),await C("/trinity/databases"),h(!1)}catch(a){g(a.message||"Failed to save database")}finally{w(!1)}},Z=a=>{_(a)},ee=async()=>{if(!f)return;const a=f.id;I(a);try{await u.delete(`/trinity/databases/${a}`),await C("/trinity/databases")}catch(t){alert(`Delete failed: ${t.message}`)}finally{I(null),_(null)}},ae=async a=>{$(a);try{const t=await u.post(`/trinity/databases/${a}/test`,{});M(i=>({...i,[a]:t.success}))}catch{M(t=>({...t,[a]:!1}))}finally{$(null)}},te=async a=>{A(a);try{await u.post(`/trinity/databases/${a}/refresh-schema`,{}),await C("/trinity/databases")}catch(t){alert(`Schema refresh failed: ${t.message}`)}finally{A(null)}},re=a=>{Q(t=>({...t,[a]:!t[a]}))},se=a=>{a!=="mongodb"&&y(!1),n(t=>({...t,type:a,port:T[a]?String(T[a]):""}))},ie=a=>{n(t=>({...t,[a]:!t[a]}))};if(R)return e.jsxs("div",{className:"p-8 text-red-500",children:["Failed to load databases: ",R.message]});const x="w-full px-3 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight",m="block text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",le=a=>[{key:"allow_read",badge:"R"},{key:"allow_insert",badge:"I"},{key:"allow_update",badge:"U"},{key:"allow_delete",badge:"D"},{key:"allow_ddl",badge:"DDL"}].filter(i=>a[i.key]).map(i=>i.badge);return e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Trinity Databases"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Register databases for Trinity to access and query."})]})]}),e.jsxs("button",{onClick:K,className:"flex items-center gap-2 px-4 py-2 bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors text-sm font-medium",children:[e.jsx(de,{className:"w-4 h-4"}),"Register Database"]})]}),v?v.length===0?e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded p-8 text-center text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(S,{className:"w-10 h-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"font-medium",children:"No databases registered"}),e.jsx("p",{className:"text-sm mt-1 opacity-70",children:'Click "Register Database" to add your first database.'})]}):e.jsx("div",{className:"space-y-4",children:v.map(a=>{const t=a.schema_json?JSON.parse(a.schema_json):null,i=!!t?.databases,c=i?t.databases.reduce((s,d)=>s+d.tables.length,0):t?.tables?.length??0,j=i?t.databases.length:0,k=a.type==="mongodb"?"collection":"table",p=a.type==="mongodb"?"collections":"tables",U=J[a.id],E=G[a.id],F=le(a);return e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-azure-surface dark:bg-black/50 px-4 py-3 flex items-center gap-3",children:[e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-bold text-azure-text-primary dark:text-matrix-highlight truncate",children:a.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary uppercase flex-shrink-0",children:a.type}),U===!0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-500",children:[e.jsx(D,{className:"w-3 h-3"})," Connected"]}),U===!1&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-red-500",children:[e.jsx(ce,{className:"w-3 h-3"})," Failed"]}),F.length>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3 h-3 text-azure-text-secondary dark:text-matrix-secondary opacity-60"}),F.map(s=>e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight font-mono",children:s},s))]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary truncate mt-0.5",children:[a.host?`${a.host}:${a.port}${a.database_name?`/${a.database_name}`:""}`:a.database_name||"connection string configured",i&&j>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",j," database",j!==1?"s":""," · ",c," ",c!==1?p:k]}),!i&&c>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",c," ",c!==1?p:k]}),a.schema_updated_at&&e.jsxs("span",{className:"ml-2 opacity-50",children:["· schema ",new Date(a.schema_updated_at).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>ae(a.id),disabled:q===a.id,title:"Test connection",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:q===a.id?e.jsx(D,{className:"w-4 h-4 animate-pulse"}):e.jsx(D,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>te(a.id),disabled:O===a.id,title:"Refresh schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:e.jsx(me,{className:`w-4 h-4 ${O===a.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>X(a),title:"Edit",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors text-xs font-medium px-2",children:"Edit"}),e.jsx("button",{onClick:()=>Z(a),disabled:Y===a.id,title:"Delete",className:"p-1.5 rounded hover:bg-red-50 dark:hover:bg-red-900/20 text-red-500 transition-colors",children:e.jsx(xe,{className:"w-4 h-4"})}),t&&e.jsx("button",{onClick:()=>re(a.id),title:E?"Hide schema":"Show schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:E?e.jsx(he,{className:"w-4 h-4"}):e.jsx(pe,{className:"w-4 h-4"})})]})]}),E&&t&&e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary px-4 py-3 bg-azure-bg dark:bg-black/20",children:[e.jsx("div",{className:"text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:i?`${j} database${j!==1?"s":""} — ${c} ${c!==1?p:k} total`:`Schema — ${c} ${c!==1?p:k}`}),e.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:i?t.databases?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"font-bold text-azure-primary dark:text-matrix-highlight",children:s.name}),e.jsxs("span",{className:"opacity-40 text-azure-text-secondary dark:text-matrix-secondary",children:["(",s.tables.length," ",s.tables.length!==1?p:k,")"]})]}),e.jsxs("div",{className:"pl-3 space-y-1.5 border-l border-azure-border dark:border-matrix-primary/40 ml-1",children:[s.tables.map(d=>e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-azure-text-primary dark:text-matrix-secondary mb-0.5",children:d.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:d.columns?.map(N=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{children:N.name}),e.jsx("span",{className:"opacity-50 ml-2",children:N.type}),N.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40",children:"NOT NULL"})]},N.name))})]},d.name)),s.tables.length===0&&e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary opacity-50 italic",children:["no ",p]})]})]},s.name)):t.tables?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsx("div",{className:"font-bold text-azure-primary dark:text-matrix-highlight mb-1",children:s.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:s.columns?.map(d=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{className:"text-azure-text-primary dark:text-matrix-secondary",children:d.name}),e.jsx("span",{className:"opacity-50 ml-2",children:d.type}),d.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40 text-xs",children:"NOT NULL"})]},d.name))})]},s.name))})]})]},a.id)})}):e.jsx("div",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:"Loading..."}),e.jsx(oe,{isOpen:!!f,onClose:()=>_(null),onConfirm:ee,title:"Delete database",description:`Remove "${f?.name}" from Trinity? The database itself won't be affected — only this registration will be deleted.`,confirmJson:"Delete",variant:"destructive"}),W&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>h(!1)}),e.jsxs("div",{className:"relative bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("h2",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight",children:o?"Edit Database":"Register Database"}),e.jsx("button",{onClick:()=>h(!1),className:"text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-text-primary dark:hover:text-matrix-highlight",children:e.jsx(ue,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Name *"}),e.jsx("input",{className:x,value:r.name,onChange:a=>n(t=>({...t,name:a.target.value})),placeholder:"My Production DB"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Type *"}),e.jsxs("select",{className:x,value:r.type,onChange:a=>se(a.target.value),children:[e.jsx("option",{value:"postgresql",children:"PostgreSQL"}),e.jsx("option",{value:"mysql",children:"MySQL / MariaDB"}),e.jsx("option",{value:"sqlite",children:"SQLite"}),e.jsx("option",{value:"mongodb",children:"MongoDB"})]})]}),r.type==="mongodb"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>y(!1),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary":"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight"}`,children:"Individual fields"}),e.jsx("button",{type:"button",onClick:()=>y(!0),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary"}`,children:"Connection string"})]}),r.type==="mongodb"&&b?e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Connection String ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.connection_string,onChange:a=>n(t=>({...t,connection_string:a.target.value})),placeholder:o?"unchanged":"mongodb://user:pass@host:27017/dbname"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]}):e.jsxs(e.Fragment,{children:[r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Host"}),e.jsx("input",{className:x,value:r.host,onChange:a=>n(t=>({...t,host:a.target.value})),placeholder:"localhost"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Port"}),e.jsx("input",{className:x,type:"number",value:r.port,onChange:a=>n(t=>({...t,port:a.target.value})),placeholder:String(T[r.type]||"")})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:[r.type==="sqlite"?"File Path":"Database Name"," *"]}),e.jsx("input",{className:`w-full px-3 py-2 bg-azure-surface dark:bg-black border rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none ${z&&!r.database_name.trim()?"border-red-500 dark:border-red-500":"border-azure-border dark:border-matrix-primary focus:border-azure-primary dark:focus:border-matrix-highlight"}`,value:r.database_name,onChange:a=>n(t=>({...t,database_name:a.target.value})),placeholder:r.type==="sqlite"?"/path/to/database.db":"mydb"})]}),r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Username"}),e.jsx("input",{className:x,value:r.username,onChange:a=>n(t=>({...t,username:a.target.value})),placeholder:"postgres"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Password ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.password,onChange:a=>n(t=>({...t,password:a.target.value})),placeholder:o?"unchanged":"••••••••"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]})]})]}),e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(B,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"}),e.jsx("span",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight",children:"Permissões"})]}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mb-3",children:"Defina quais operações Trinity pode executar neste banco. Operações não permitidas retornarão erro de permissão."}),e.jsx("div",{className:"space-y-2",children:ge[r.type]?.map(({key:a,label:t,description:i})=>e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsxs("div",{className:"relative mt-0.5 flex-shrink-0",children:[e.jsx("input",{type:"checkbox",checked:!!r[a],onChange:()=>ie(a),className:"sr-only"}),e.jsx("div",{className:`w-4 h-4 rounded border transition-colors flex items-center justify-center ${r[a]?"bg-azure-primary dark:bg-matrix-highlight border-azure-primary dark:border-matrix-highlight":"border-azure-border dark:border-matrix-primary bg-transparent"}`,children:r[a]&&e.jsx("svg",{className:"w-2.5 h-2.5 text-white dark:text-black",fill:"none",viewBox:"0 0 10 10",children:e.jsx("path",{d:"M1.5 5l2.5 2.5L8.5 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-azure-text-primary dark:text-matrix-secondary font-mono",children:t}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70",children:i})]})]},a))})]}),z&&e.jsx("div",{className:"text-sm text-red-500 border border-red-500/30 bg-red-500/10 rounded px-3 py-2",children:z})]}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:()=>h(!1),className:"px-4 py-2 text-sm text-azure-text-secondary dark:text-matrix-secondary border border-azure-border dark:border-matrix-primary rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:V,disabled:L||!r.name,className:"px-4 py-2 text-sm font-medium bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors disabled:opacity-50",children:L?"Saving...":o?"Update":"Register"})]})]})]})]})}export{we as TrinityDatabases};
|
|
1
|
+
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as l}from"./vendor-react-DikRIOlj.js";import{u as ne,m as C}from"./vendor-utils-BIYveU_1.js";import{h as u}from"./index-B9ePr-vB.js";import{C as oe}from"./ConfirmationModal-DU0AwhXD.js";import{D as S,a8 as de,ae as D,af as ce,h as B,Y as me,G as xe,K as he,q as pe,X as ue}from"./vendor-icons-DE7PWdkN.js";const T={postgresql:5432,mysql:3306,mongodb:27017,sqlite:0},H={name:"",type:"postgresql",host:"",port:"",database_name:"",username:"",password:"",connection_string:"",allow_read:!0,allow_insert:!1,allow_update:!1,allow_delete:!1,allow_ddl:!1},ge={postgresql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mysql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],sqlite:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mongodb:[{key:"allow_read",label:"find / aggregate",description:"Permite consultas e agregações"},{key:"allow_insert",label:"insertOne / insertMany",description:"Permite inserir documentos"},{key:"allow_update",label:"updateOne / updateMany",description:"Permite atualizar documentos"},{key:"allow_delete",label:"deleteOne / deleteMany",description:"Permite excluir documentos"},{key:"allow_ddl",label:"Schema changes",description:"createCollection / dropCollection / createIndex"}]};async function be(){return u.get("/trinity/databases")}function we(){const{data:v,error:R}=ne("/trinity/databases",be,{refreshInterval:3e4}),[W,h]=l.useState(!1),[o,P]=l.useState(null),[r,n]=l.useState(H),[L,w]=l.useState(!1),[z,g]=l.useState(null),[G,Q]=l.useState({}),[q,$]=l.useState(null),[J,M]=l.useState({}),[O,A]=l.useState(null),[Y,I]=l.useState(null),[f,_]=l.useState(null),[b,y]=l.useState(!1),K=()=>{P(null),n(H),y(!1),g(null),h(!0)},X=a=>{P(a),n({name:a.name,type:a.type,host:a.host||"",port:a.port?String(a.port):"",database_name:a.database_name||"",username:a.username||"",password:"",connection_string:"",allow_read:a.allow_read,allow_insert:a.allow_insert,allow_update:a.allow_update,allow_delete:a.allow_delete,allow_ddl:a.allow_ddl}),y(!!a.connection_string),g(null),h(!0)},V=async()=>{if(w(!0),g(null),!b&&!r.database_name.trim()){g(r.type==="sqlite"?"File path is required.":"Database name is required."),w(!1);return}try{const a={name:r.name,type:r.type,allow_read:r.allow_read,allow_insert:r.allow_insert,allow_update:r.allow_update,allow_delete:r.allow_delete,allow_ddl:r.allow_ddl};b?(!o||r.connection_string)&&(a.connection_string=r.connection_string||null):(a.host=r.host||null,a.port=r.port?parseInt(r.port):null,a.database_name=r.database_name||null,a.username=r.username||null,(!o||r.password)&&(a.password=r.password||null)),o?await u.put(`/trinity/databases/${o.id}`,a):await u.post("/trinity/databases",a),await C("/trinity/databases"),h(!1)}catch(a){g(a.message||"Failed to save database")}finally{w(!1)}},Z=a=>{_(a)},ee=async()=>{if(!f)return;const a=f.id;I(a);try{await u.delete(`/trinity/databases/${a}`),await C("/trinity/databases")}catch(t){alert(`Delete failed: ${t.message}`)}finally{I(null),_(null)}},ae=async a=>{$(a);try{const t=await u.post(`/trinity/databases/${a}/test`,{});M(i=>({...i,[a]:t.success}))}catch{M(t=>({...t,[a]:!1}))}finally{$(null)}},te=async a=>{A(a);try{await u.post(`/trinity/databases/${a}/refresh-schema`,{}),await C("/trinity/databases")}catch(t){alert(`Schema refresh failed: ${t.message}`)}finally{A(null)}},re=a=>{Q(t=>({...t,[a]:!t[a]}))},se=a=>{a!=="mongodb"&&y(!1),n(t=>({...t,type:a,port:T[a]?String(T[a]):""}))},ie=a=>{n(t=>({...t,[a]:!t[a]}))};if(R)return e.jsxs("div",{className:"p-8 text-red-500",children:["Failed to load databases: ",R.message]});const x="w-full px-3 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight",m="block text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",le=a=>[{key:"allow_read",badge:"R"},{key:"allow_insert",badge:"I"},{key:"allow_update",badge:"U"},{key:"allow_delete",badge:"D"},{key:"allow_ddl",badge:"DDL"}].filter(i=>a[i.key]).map(i=>i.badge);return e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Trinity Databases"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Register databases for Trinity to access and query."})]})]}),e.jsxs("button",{onClick:K,className:"flex items-center gap-2 px-4 py-2 bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors text-sm font-medium",children:[e.jsx(de,{className:"w-4 h-4"}),"Register Database"]})]}),v?v.length===0?e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded p-8 text-center text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(S,{className:"w-10 h-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"font-medium",children:"No databases registered"}),e.jsx("p",{className:"text-sm mt-1 opacity-70",children:'Click "Register Database" to add your first database.'})]}):e.jsx("div",{className:"space-y-4",children:v.map(a=>{const t=a.schema_json?JSON.parse(a.schema_json):null,i=!!t?.databases,c=i?t.databases.reduce((s,d)=>s+d.tables.length,0):t?.tables?.length??0,j=i?t.databases.length:0,k=a.type==="mongodb"?"collection":"table",p=a.type==="mongodb"?"collections":"tables",U=J[a.id],E=G[a.id],F=le(a);return e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-azure-surface dark:bg-black/50 px-4 py-3 flex items-center gap-3",children:[e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-bold text-azure-text-primary dark:text-matrix-highlight truncate",children:a.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary uppercase flex-shrink-0",children:a.type}),U===!0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-500",children:[e.jsx(D,{className:"w-3 h-3"})," Connected"]}),U===!1&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-red-500",children:[e.jsx(ce,{className:"w-3 h-3"})," Failed"]}),F.length>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3 h-3 text-azure-text-secondary dark:text-matrix-secondary opacity-60"}),F.map(s=>e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight font-mono",children:s},s))]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary truncate mt-0.5",children:[a.host?`${a.host}:${a.port}${a.database_name?`/${a.database_name}`:""}`:a.database_name||"connection string configured",i&&j>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",j," database",j!==1?"s":""," · ",c," ",c!==1?p:k]}),!i&&c>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",c," ",c!==1?p:k]}),a.schema_updated_at&&e.jsxs("span",{className:"ml-2 opacity-50",children:["· schema ",new Date(a.schema_updated_at).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>ae(a.id),disabled:q===a.id,title:"Test connection",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:q===a.id?e.jsx(D,{className:"w-4 h-4 animate-pulse"}):e.jsx(D,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>te(a.id),disabled:O===a.id,title:"Refresh schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:e.jsx(me,{className:`w-4 h-4 ${O===a.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>X(a),title:"Edit",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors text-xs font-medium px-2",children:"Edit"}),e.jsx("button",{onClick:()=>Z(a),disabled:Y===a.id,title:"Delete",className:"p-1.5 rounded hover:bg-red-50 dark:hover:bg-red-900/20 text-red-500 transition-colors",children:e.jsx(xe,{className:"w-4 h-4"})}),t&&e.jsx("button",{onClick:()=>re(a.id),title:E?"Hide schema":"Show schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:E?e.jsx(he,{className:"w-4 h-4"}):e.jsx(pe,{className:"w-4 h-4"})})]})]}),E&&t&&e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary px-4 py-3 bg-azure-bg dark:bg-black/20",children:[e.jsx("div",{className:"text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:i?`${j} database${j!==1?"s":""} — ${c} ${c!==1?p:k} total`:`Schema — ${c} ${c!==1?p:k}`}),e.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:i?t.databases?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"font-bold text-azure-primary dark:text-matrix-highlight",children:s.name}),e.jsxs("span",{className:"opacity-40 text-azure-text-secondary dark:text-matrix-secondary",children:["(",s.tables.length," ",s.tables.length!==1?p:k,")"]})]}),e.jsxs("div",{className:"pl-3 space-y-1.5 border-l border-azure-border dark:border-matrix-primary/40 ml-1",children:[s.tables.map(d=>e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-azure-text-primary dark:text-matrix-secondary mb-0.5",children:d.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:d.columns?.map(N=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{children:N.name}),e.jsx("span",{className:"opacity-50 ml-2",children:N.type}),N.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40",children:"NOT NULL"})]},N.name))})]},d.name)),s.tables.length===0&&e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary opacity-50 italic",children:["no ",p]})]})]},s.name)):t.tables?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsx("div",{className:"font-bold text-azure-primary dark:text-matrix-highlight mb-1",children:s.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:s.columns?.map(d=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{className:"text-azure-text-primary dark:text-matrix-secondary",children:d.name}),e.jsx("span",{className:"opacity-50 ml-2",children:d.type}),d.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40 text-xs",children:"NOT NULL"})]},d.name))})]},s.name))})]})]},a.id)})}):e.jsx("div",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:"Loading..."}),e.jsx(oe,{isOpen:!!f,onClose:()=>_(null),onConfirm:ee,title:"Delete database",description:`Remove "${f?.name}" from Trinity? The database itself won't be affected — only this registration will be deleted.`,confirmJson:"Delete",variant:"destructive"}),W&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>h(!1)}),e.jsxs("div",{className:"relative bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("h2",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight",children:o?"Edit Database":"Register Database"}),e.jsx("button",{onClick:()=>h(!1),className:"text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-text-primary dark:hover:text-matrix-highlight",children:e.jsx(ue,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Name *"}),e.jsx("input",{className:x,value:r.name,onChange:a=>n(t=>({...t,name:a.target.value})),placeholder:"My Production DB"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Type *"}),e.jsxs("select",{className:x,value:r.type,onChange:a=>se(a.target.value),children:[e.jsx("option",{value:"postgresql",children:"PostgreSQL"}),e.jsx("option",{value:"mysql",children:"MySQL / MariaDB"}),e.jsx("option",{value:"sqlite",children:"SQLite"}),e.jsx("option",{value:"mongodb",children:"MongoDB"})]})]}),r.type==="mongodb"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>y(!1),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary":"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight"}`,children:"Individual fields"}),e.jsx("button",{type:"button",onClick:()=>y(!0),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary"}`,children:"Connection string"})]}),r.type==="mongodb"&&b?e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Connection String ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.connection_string,onChange:a=>n(t=>({...t,connection_string:a.target.value})),placeholder:o?"unchanged":"mongodb://user:pass@host:27017/dbname"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]}):e.jsxs(e.Fragment,{children:[r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Host"}),e.jsx("input",{className:x,value:r.host,onChange:a=>n(t=>({...t,host:a.target.value})),placeholder:"localhost"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Port"}),e.jsx("input",{className:x,type:"number",value:r.port,onChange:a=>n(t=>({...t,port:a.target.value})),placeholder:String(T[r.type]||"")})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:[r.type==="sqlite"?"File Path":"Database Name"," *"]}),e.jsx("input",{className:`w-full px-3 py-2 bg-azure-surface dark:bg-black border rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none ${z&&!r.database_name.trim()?"border-red-500 dark:border-red-500":"border-azure-border dark:border-matrix-primary focus:border-azure-primary dark:focus:border-matrix-highlight"}`,value:r.database_name,onChange:a=>n(t=>({...t,database_name:a.target.value})),placeholder:r.type==="sqlite"?"/path/to/database.db":"mydb"})]}),r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Username"}),e.jsx("input",{className:x,value:r.username,onChange:a=>n(t=>({...t,username:a.target.value})),placeholder:"postgres"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Password ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.password,onChange:a=>n(t=>({...t,password:a.target.value})),placeholder:o?"unchanged":"••••••••"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]})]})]}),e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(B,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"}),e.jsx("span",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight",children:"Permissões"})]}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mb-3",children:"Defina quais operações Trinity pode executar neste banco. Operações não permitidas retornarão erro de permissão."}),e.jsx("div",{className:"space-y-2",children:ge[r.type]?.map(({key:a,label:t,description:i})=>e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsxs("div",{className:"relative mt-0.5 flex-shrink-0",children:[e.jsx("input",{type:"checkbox",checked:!!r[a],onChange:()=>ie(a),className:"sr-only"}),e.jsx("div",{className:`w-4 h-4 rounded border transition-colors flex items-center justify-center ${r[a]?"bg-azure-primary dark:bg-matrix-highlight border-azure-primary dark:border-matrix-highlight":"border-azure-border dark:border-matrix-primary bg-transparent"}`,children:r[a]&&e.jsx("svg",{className:"w-2.5 h-2.5 text-white dark:text-black",fill:"none",viewBox:"0 0 10 10",children:e.jsx("path",{d:"M1.5 5l2.5 2.5L8.5 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-azure-text-primary dark:text-matrix-secondary font-mono",children:t}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70",children:i})]})]},a))})]}),z&&e.jsx("div",{className:"text-sm text-red-500 border border-red-500/30 bg-red-500/10 rounded px-3 py-2",children:z})]}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:()=>h(!1),className:"px-4 py-2 text-sm text-azure-text-secondary dark:text-matrix-secondary border border-azure-border dark:border-matrix-primary rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:V,disabled:L||!r.name,className:"px-4 py-2 text-sm font-medium bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors disabled:opacity-50",children:L?"Saving...":o?"Update":"Register"})]})]})]})]})}export{we as TrinityDatabases};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,m as r}from"./vendor-motion-C3CZ8ZlO.js";import{r as d}from"./vendor-react-DikRIOlj.js";import{s as n}from"./stats-
|
|
1
|
+
import{j as e,m as r}from"./vendor-motion-C3CZ8ZlO.js";import{r as d}from"./vendor-react-DikRIOlj.js";import{s as n}from"./stats-KMbKDMJ-.js";import{k as b,c as k,D as j,i as N}from"./vendor-icons-DE7PWdkN.js";import"./index-B9ePr-vB.js";import"./vendor-utils-BIYveU_1.js";function w(){const[o,c]=d.useState(null),[i,x]=d.useState([]),[m,h]=d.useState(!0),[l,u]=d.useState("");if(d.useEffect(()=>{async function t(){try{const[s,p]=await Promise.all([n.fetchUsageStats(),n.fetchGroupedUsageStats()]);c(s),x(p)}catch(s){u("Failed to load usage statistics"),console.error(s)}finally{h(!1)}}t()},[]),m)return e.jsx("div",{className:"flex items-center justify-center h-64 text-azure-accent dark:text-matrix-highlight font-mono animate-pulse",children:"LOADING_DATA_STREAM..."});if(l)return e.jsxs("div",{className:"p-4 bg-red-900/20 border border-red-500/50 text-red-500 font-mono rounded",children:["ERROR_ACCESSING_DATABASE: ",l]});const g={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.1}}},a={hidden:{y:20,opacity:0},show:{y:0,opacity:1}};return e.jsxs(r.div,{variants:g,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(r.div,{variants:a,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(b,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Usage Stats"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Resource consumption tracking and cost metrics."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(r.div,{variants:a,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[e.jsx(k,{className:"w-5 h-5"}),e.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Total Input Tokens"})]}),e.jsx("p",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight font-mono",children:o?.totalInputTokens.toLocaleString()??0})]}),e.jsxs(r.div,{variants:a,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[e.jsx(j,{className:"w-5 h-5"}),e.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Total Output Tokens"})]}),e.jsx("p",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight font-mono",children:o?.totalOutputTokens.toLocaleString()??0})]}),e.jsxs(r.div,{variants:a,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[e.jsx(N,{className:"w-5 h-5"}),e.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Est. Total Cost"})]}),e.jsx("p",{className:"text-3xl font-bold text-green-600 dark:text-green-400 font-mono",children:o?.totalEstimatedCostUsd!=null?`$${o.totalEstimatedCostUsd.toFixed(4)}`:"—"})]})]}),e.jsxs(r.div,{variants:a,className:"bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden backdrop-blur-sm",children:[e.jsx("div",{className:"p-4 border-b border-azure-border dark:border-matrix-primary bg-azure-bg dark:bg-zinc-900/50",children:e.jsx("h3",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight font-mono uppercase",children:"Usage Breakdown by Model"})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left font-mono text-sm",children:[e.jsx("thead",{className:"bg-azure-bg dark:bg-zinc-900/50 text-azure-text-secondary dark:text-matrix-secondary border-b border-azure-border dark:border-matrix-primary",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-4",children:"Provider"}),e.jsx("th",{className:"p-4",children:"Model"}),e.jsx("th",{className:"p-4 text-right",children:"Messages"}),e.jsx("th",{className:"p-4 text-right",children:"Input Tokens"}),e.jsx("th",{className:"p-4 text-right",children:"Output Tokens"}),e.jsx("th",{className:"p-4 text-right",children:"Total Tokens"}),e.jsx("th",{className:"p-4 text-right",children:"Audio (s)"}),e.jsx("th",{className:"p-4 text-right",children:"Est. Cost (USD)"})]})}),e.jsx("tbody",{className:"divide-y divide-azure-border dark:divide-matrix-primary/30",children:i.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"p-8 text-center text-azure-text-muted dark:text-matrix-secondary italic",children:"NO_DATA_AVAILABLE"})}):i.map((t,s)=>e.jsxs("tr",{className:"hover:bg-azure-hover dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsx("td",{className:"p-4 font-bold text-azure-text-primary dark:text-matrix-highlight",children:t.provider}),e.jsx("td",{className:"p-4 text-azure-text-secondary dark:text-matrix-secondary",children:t.model}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.messageCount.toLocaleString()}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.totalInputTokens.toLocaleString()}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.totalOutputTokens.toLocaleString()}),e.jsx("td",{className:"p-4 text-right font-bold text-azure-text-primary dark:text-matrix-highlight",children:t.totalTokens.toLocaleString()}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.totalAudioSeconds>0?t.totalAudioSeconds.toLocaleString():"—"}),e.jsx("td",{className:"p-4 text-right font-bold text-green-600 dark:text-green-400",children:t.estimatedCostUsd!=null?`$${t.estimatedCostUsd.toFixed(4)}`:"—"})]},`${t.provider}-${t.model}-${s}`))})]})})]})]})}export{w as UsageStats};
|