@oodarun/cli 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard-dist/_redirects +1 -0
- package/dashboard-dist/assets/AdminApp-B0pStzVl.js +6 -0
- package/dashboard-dist/assets/App-C_nY6S8g.js +5 -0
- package/dashboard-dist/assets/InternalDashboard-CGGYXACm.js +1 -0
- package/dashboard-dist/assets/{index-DNhLzZDP.js → index-5I_ipmZc.js} +2 -2
- package/dashboard-dist/assets/index-lADDHY9o.css +1 -0
- package/dashboard-dist/index.html +2 -2
- package/dist/cli.js +59 -44
- package/package.json +1 -1
- package/dashboard-dist/assets/AdminApp-XtgMLudZ.js +0 -6
- package/dashboard-dist/assets/App-BD_pv1Jv.js +0 -5
- package/dashboard-dist/assets/InternalDashboard-BaxkB3eO.js +0 -1
- package/dashboard-dist/assets/index-CKu0aeQ4.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* /index.html 200
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{r as a,j as e}from"./index-5I_ipmZc.js";import{b as E,d as D,g as H,a as J,c as U,s as Y}from"./api-DbuItvnH.js";function q(){const n=new URLSearchParams(window.location.search).get("email");return window.location.pathname==="/signup"&&n?{mode:"invite",email:n}:{mode:"login",email:""}}function z({onLogin:s}){const[n]=a.useState(q),[r]=a.useState(n.mode),[o,j]=a.useState(n.email),[d,y]=a.useState(""),[h,f]=a.useState(""),[g,u]=a.useState(null),[c,i]=a.useState([]),[t,x]=a.useState(!1),p="https://api.ooda.run",k=async v=>{v.preventDefault(),u(null),i([]),x(!0);try{const A=await fetch(`${p}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o,password:d})});if(!A.ok){u("Invalid email or password");return}const w=await A.json();s(w.user,w.orgs,w.accessToken,w.refreshToken)}catch{u("Could not reach the server")}finally{x(!1)}},b=async v=>{v.preventDefault(),u(null),i([]),x(!0);try{const A=await fetch(`${p}/auth/signup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o,password:d,name:h})}),w=await A.json();if(!A.ok){u(w.error||"Signup failed"),i(w.errors||[]);return}const I=await fetch(`${p}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o,password:d})});if(!I.ok){u("Account created but login failed. Try logging in.");return}const P=await I.json();s(P.user,P.orgs,P.accessToken,P.refreshToken)}catch{u("Could not reach the server")}finally{x(!1)}};return e.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-sm p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("img",{src:"/logo.svg",alt:"ooda",className:"h-6 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-ink-muted",children:r==="invite"?"Accept your invite":"Sign in to your account"})]}),e.jsxs("form",{onSubmit:r==="invite"?b:k,className:"space-y-4",children:[r==="invite"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-ink-muted mb-1",children:"Name"}),e.jsx("input",{id:"name",type:"text",value:h,onChange:v=>f(v.target.value),required:!0,autoComplete:"name",autoFocus:!0,className:"w-full px-3 py-2 border border-border text-sm bg-white focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-ink-muted mb-1",children:"Email"}),e.jsx("input",{id:"email",type:"email",value:o,onChange:v=>j(v.target.value),required:!0,autoComplete:"email",autoFocus:r==="login",disabled:r==="invite",className:"w-full px-3 py-2 border border-border text-sm bg-white focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent disabled:bg-gray-50 disabled:text-ink-muted"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-ink-muted mb-1",children:r==="invite"?"Choose a password":"Password"}),e.jsx("input",{id:"password",type:"password",value:d,onChange:v=>y(v.target.value),required:!0,autoComplete:r==="invite"?"new-password":"current-password",className:"w-full px-3 py-2 border border-border text-sm bg-white focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"})]}),g&&e.jsxs("div",{className:"text-sm text-red-600",children:[e.jsx("p",{children:g}),c.length>0&&e.jsx("ul",{className:"mt-1 list-disc list-inside text-xs text-red-500",children:c.map(v=>e.jsx("li",{children:v},v))})]}),e.jsx("button",{type:"submit",disabled:t,className:"w-full px-4 py-2 bg-ink text-surface text-sm font-medium hover:bg-ink/80 transition-colors disabled:opacity-50",children:t?"...":r==="invite"?"Accept invite":"Sign in"})]})]})})}function V({orgId:s,role:n="admin"}){const[r,o]=a.useState([]),[j,d]=a.useState(!0),[y,h]=a.useState(null),f=n==="admin",g=async()=>{d(!0);try{const c=f?await E(s,"/users"):await D(s,"/members");if(!c.ok){h("Failed to load members");return}const i=await c.json();o(i.users||[])}catch{h("Could not reach the server")}finally{d(!1)}};a.useEffect(()=>{g()},[s]);const u=async c=>{if(!confirm(`Remove ${c} from this organization?`))return;(await E(s,`/users/${encodeURIComponent(c)}`,{method:"DELETE"})).ok&&o(t=>t.filter(x=>x.email!==c))};return j?e.jsx("p",{className:"text-sm text-ink-muted",children:"Loading members..."}):y?e.jsx("p",{className:"text-sm text-red-600",children:y}):e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-medium text-ink mb-4",children:["Members",e.jsx("span",{className:"text-ink-faint font-normal ml-2",children:r.length})]}),r.length===0?e.jsx("p",{className:"text-sm text-ink-muted",children:"No members yet."}):e.jsx("div",{className:"border border-border divide-y divide-border",children:r.map(c=>e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:c.name||c.email}),e.jsx("p",{className:"text-xs text-ink-faint",children:c.email})]}),c.role&&e.jsx("span",{className:`text-xs px-2 py-0.5 ${c.role==="admin"?"bg-ink text-surface":"bg-border text-ink-muted"}`,children:c.role})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-xs text-ink-faint",children:new Date(c.joinedAt).toLocaleDateString()}),f&&e.jsx("button",{onClick:()=>u(c.email),className:"text-xs text-red-500 hover:text-red-700 transition-colors",children:"Remove"})]})]},c.email))})]})}function R(s){return s.status==="pending"&&s.expiresAt&&new Date(s.expiresAt).getTime()<Date.now()?"expired":s.status}function G({orgId:s}){const[n,r]=a.useState([]),[o,j]=a.useState(!0),[d,y]=a.useState(null),[h,f]=a.useState(""),[g,u]=a.useState("member"),[c,i]=a.useState(!1),[t,x]=a.useState(null),p=async()=>{j(!0);try{const l=await E(s,"/invites");if(!l.ok){y("Failed to load invites");return}const C=await l.json();r(C.invites||[])}catch{y("Could not reach the server")}finally{j(!1)}};a.useEffect(()=>{p()},[s]);const k=async l=>{l.preventDefault(),x(null);const C=h.split(/[,\n]/).map(m=>m.trim()).filter(Boolean);if(C.length===0){x("Enter at least one email address");return}i(!0);try{const m=await E(s,"/invites",{method:"POST",body:JSON.stringify({emails:C,role:g})});if(!m.ok){const N=await m.json();x(N.error||"Failed to create invites");return}f(""),p()}catch{x("Could not reach the server")}finally{i(!1)}},b=async l=>{if(!confirm(`Revoke invite for ${l}?`))return;(await E(s,`/invites/${encodeURIComponent(l)}`,{method:"DELETE"})).ok&&p()},v=n.filter(l=>R(l)==="pending"),A=n.filter(l=>R(l)==="expired"),w=n.filter(l=>R(l)==="accepted"),I=n.filter(l=>R(l)==="revoked"),P=async l=>{i(!0);try{(await E(s,"/invites",{method:"POST",body:JSON.stringify({emails:[l],role:"member"})})).ok&&p()}catch{}finally{i(!1)}},$=l=>{switch(l){case"pending":return"bg-yellow-100 text-yellow-800";case"accepted":return"bg-green-100 text-green-800";case"revoked":return"bg-red-100 text-red-800";case"expired":return"bg-orange-100 text-orange-800";default:return"bg-border text-ink-muted"}};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium text-ink mb-4",children:"Invite people"}),e.jsxs("form",{onSubmit:k,className:"space-y-3",children:[e.jsx("div",{children:e.jsx("textarea",{value:h,onChange:l=>f(l.target.value),placeholder:"Email addresses (comma or newline separated)",rows:3,className:"w-full px-3 py-2 border border-border text-sm bg-white focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent resize-none font-mono"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("select",{value:g,onChange:l=>u(l.target.value),className:"px-3 py-2 border border-border text-sm bg-white focus:outline-none focus:ring-2 focus:ring-ink",children:[e.jsx("option",{value:"member",children:"Member"}),e.jsx("option",{value:"admin",children:"Admin"})]}),e.jsx("button",{type:"submit",disabled:c,className:"px-4 py-2 bg-ink text-surface text-sm font-medium hover:bg-ink/80 transition-colors disabled:opacity-50",children:c?"Sending...":"Send invites"})]}),t&&e.jsx("p",{className:"text-sm text-red-600",children:t})]})]}),o?e.jsx("p",{className:"text-sm text-ink-muted",children:"Loading invites..."}):d?e.jsx("p",{className:"text-sm text-red-600",children:d}):e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-medium text-ink mb-4",children:["Invites",e.jsx("span",{className:"text-ink-faint font-normal ml-2",children:n.length})]}),n.length===0?e.jsx("p",{className:"text-sm text-ink-muted",children:"No invites yet."}):e.jsx("div",{className:"border border-border divide-y divide-border",children:[...v,...A,...w,...I].map(l=>{const C=R(l);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:l.email}),e.jsx("p",{className:"text-xs text-ink-faint",children:new Date(l.createdAt).toLocaleDateString()})]}),e.jsx("span",{className:`text-xs px-2 py-0.5 ${$(C)}`,children:C}),e.jsx("span",{className:`text-xs px-2 py-0.5 ${l.role==="admin"?"bg-ink text-surface":"bg-border text-ink-muted"}`,children:l.role})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[C==="expired"&&e.jsx("button",{onClick:()=>P(l.email),disabled:c,className:"text-xs text-ink hover:text-ink/70 transition-colors disabled:opacity-50",children:"Re-send"}),C==="pending"&&e.jsx("button",{onClick:()=>b(l.email),className:"text-xs text-red-500 hover:text-red-700 transition-colors",children:"Revoke"})]})]},l.id)})})]})]})}function Q(s){const n=Math.max(0,Math.floor(Date.now()/1e3-s));return n<60?`${n}s ago`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function W(s){try{return atob(s.logTailBase64)}catch{return""}}function F(s){const n=W(s).trim();if(!n)return"";const r=n.split(`
|
|
2
|
+
`).filter(o=>o.trim());return r[r.length-1]||""}function _(s){const n=Date.now()-new Date(s).getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function X(s){const n=s.toLowerCase();return["running","started","ready"].includes(n)?"bg-green-100 text-green-800":["stopped","suspended"].includes(n)?"bg-red-100 text-red-800":n==="sleeping"?"bg-gray-100 text-gray-600":"bg-yellow-100 text-yellow-800"}function Z({orgId:s,role:n="admin"}){const[r,o]=a.useState([]),[j,d]=a.useState(!0),[y,h]=a.useState(null),f=n==="admin",g=f?E:D,u=async()=>{d(!0);try{const t=await g(s,"/projects");if(!t.ok){h("Failed to load projects");return}const x=await t.json();o(x.projects||[])}catch{h("Could not reach the server")}finally{d(!1)}};a.useEffect(()=>{u()},[s]);const c=async t=>{(await g(s,`/projects/${encodeURIComponent(t)}/stop`,{method:"POST"})).ok&&o(p=>p.map(k=>k.name===t?{...k,status:"stopped"}:k))},i=async t=>{if(!confirm(`Delete project "${t}"? This will destroy the running environment.`))return;(await g(s,`/projects/${encodeURIComponent(t)}`,{method:"DELETE"})).ok&&o(p=>p.filter(k=>k.name!==t))};return j?e.jsx("p",{className:"text-sm text-ink-muted",children:"Loading projects..."}):y?e.jsx("p",{className:"text-sm text-red-600",children:y}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-medium text-ink",children:["Projects",e.jsx("span",{className:"text-ink-faint font-normal ml-2",children:r.length})]}),e.jsx("button",{onClick:u,className:"text-xs text-ink-muted hover:text-ink transition-colors",children:"Refresh"})]}),r.length===0?e.jsxs("div",{className:"border border-border py-12 text-center",children:[e.jsx("p",{className:"text-sm text-ink-muted",children:"No projects created yet"}),e.jsx("p",{className:"text-xs text-ink-faint mt-1",children:"Projects will appear here when members deploy"})]}):e.jsx("div",{className:"border border-border divide-y divide-border",children:r.map(t=>{const x=f||t.isOwn,p=t.status&&["running","started","ready"].includes(t.status.toLowerCase());return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:t.name}),t.createdByName&&e.jsxs("p",{className:"text-xs text-ink-faint",children:[t.createdByName,t.isOwn&&!f&&e.jsx("span",{className:"text-ink-muted ml-1",children:"(you)"})]})]}),t.status&&e.jsx("span",{className:`text-xs px-2 py-0.5 ${X(t.status)}`,children:t.status}),t.devServerStatus&&e.jsx("span",{className:"text-xs px-2 py-0.5 bg-red-100 text-red-800 cursor-help",title:`Dev server auto-disabled ${Q(t.devServerStatus.disabledAt)} after ${t.devServerStatus.fails} rapid crashes.${F(t.devServerStatus)?`
|
|
3
|
+
|
|
4
|
+
Last error: ${F(t.devServerStatus).slice(0,300)}`:""}
|
|
5
|
+
|
|
6
|
+
The owner needs to reconnect with npx @oodarun/cli and run /start-server after fixing the underlying error.`,children:"dev server disabled"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[t.lastActiveAt?e.jsxs("span",{className:"text-xs text-ink-muted",title:`Last active: ${t.lastActiveAt}`,children:["active ",_(t.lastActiveAt)]}):e.jsxs("span",{className:"text-xs text-ink-faint",title:t.createdAt,children:["created ",_(t.createdAt)]}),x&&p&&e.jsx("button",{onClick:()=>c(t.name),className:"text-xs text-amber-600 hover:text-amber-800 transition-colors",children:"Stop"}),x&&e.jsx("button",{onClick:()=>i(t.name),className:"text-xs text-red-500 hover:text-red-700 transition-colors",children:"Delete"})]})]},t.name)})})]})}function ee(s){const n=Date.now()-new Date(s).getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function te({orgId:s,role:n="admin"}){const[r,o]=a.useState([]),[j,d]=a.useState(!0),[y,h]=a.useState(null),f=n==="admin",g=f?E:D,u=async()=>{d(!0);try{const i=await g(s,"/sites");if(!i.ok){h("Failed to load sites");return}const t=await i.json();o(t.sites||[])}catch{h("Could not reach the server")}finally{d(!1)}};a.useEffect(()=>{u()},[s]);const c=async i=>{if(!confirm(`Unpublish "${i}"? This will remove the site from ooda.run.`))return;(await g(s,`/sites/${encodeURIComponent(i)}`,{method:"DELETE"})).ok&&o(x=>x.filter(p=>p.slug!==i))};return j?e.jsx("p",{className:"text-sm text-ink-muted",children:"Loading sites..."}):y?e.jsx("p",{className:"text-sm text-red-600",children:y}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-medium text-ink",children:["Published Sites",e.jsx("span",{className:"text-ink-faint font-normal ml-2",children:r.length})]}),e.jsx("button",{onClick:u,className:"text-xs text-ink-muted hover:text-ink transition-colors",children:"Refresh"})]}),r.length===0?e.jsxs("div",{className:"border border-border py-12 text-center",children:[e.jsx("p",{className:"text-sm text-ink-muted",children:"No sites published yet"}),e.jsx("p",{className:"text-xs text-ink-faint mt-1",children:"Published sites will appear here"})]}):e.jsx("div",{className:"border border-border divide-y divide-border",children:r.map(i=>{const t=f||i.isOwn;return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:i.slug}),e.jsx("p",{className:"text-xs text-ink-faint",children:i.url}),i.publishedByName&&e.jsxs("p",{className:"text-xs text-ink-faint mt-0.5",children:["by ",i.publishedByName,i.isOwn&&!f&&e.jsx("span",{className:"text-ink-muted ml-1",children:"(you)"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-xs text-ink-faint",title:i.publishedAt,children:ee(i.publishedAt)}),e.jsx("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-ink-muted hover:text-ink border border-border px-2 py-1 transition-colors",children:"Open"}),t&&e.jsx("button",{onClick:()=>c(i.slug),className:"text-xs text-red-500 hover:text-red-700 transition-colors",children:"Unpublish"})]})]},i.slug)})})]})}function se({orgId:s}){const[n,r]=a.useState(null),[o,j]=a.useState(!0),[d,y]=a.useState(!1),[h,f]=a.useState(null),[g,u]=a.useState(null),[c,i]=a.useState(""),[t,x]=a.useState(""),[p,k]=a.useState(""),[b,v]=a.useState(60),[A,w]=a.useState([]),I=async()=>{var m,N;j(!0),f(null);try{const S=await E(s,"/settings");if(!S.ok){f("Failed to load settings");return}const L=await S.json();r(L);const T=L.claude;if(T){i(((m=T.env)==null?void 0:m.ANTHROPIC_API_KEY)||""),x(((N=T.env)==null?void 0:N.ANTHROPIC_BASE_URL)||""),k(T.apiKeyHelper||""),v(Math.round((T.apiKeyHelperTtlMs||36e5)/6e4));const O=new Set(["ANTHROPIC_API_KEY","ANTHROPIC_BASE_URL"]),B=Object.entries(T.env||{}).filter(([M])=>!O.has(M)).map(([M,K])=>({key:M,value:K}));w(B)}}catch{f("Could not reach the server")}finally{j(!1)}};a.useEffect(()=>{I()},[s]);const P=async()=>{y(!0),f(null),u(null);const m={};c&&(m.ANTHROPIC_API_KEY=c),t&&(m.ANTHROPIC_BASE_URL=t);for(const S of A)S.key.trim()&&(m[S.key.trim()]=S.value);const N={};Object.keys(m).length>0&&(N.env=m),p.trim()&&(N.apiKeyHelper=p.trim(),N.apiKeyHelperTtlMs=b*6e4);try{const S={claude:Object.keys(N).length>0?N:null};if(!(await E(s,"/settings",{method:"PUT",body:JSON.stringify(S)})).ok){f("Failed to save settings");return}u("Settings saved"),setTimeout(()=>u(null),3e3)}catch{f("Could not reach the server")}finally{y(!1)}},$=()=>{w(m=>[...m,{key:"",value:""}])},l=m=>{w(N=>N.filter((S,L)=>L!==m))},C=(m,N,S)=>{w(L=>L.map((T,O)=>O===m?{...T,[N]:S}:T))};return o?e.jsx("p",{className:"text-sm text-ink-muted",children:"Loading settings..."}):h&&!n?e.jsx("p",{className:"text-sm text-red-600",children:h}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-medium text-ink mb-1",children:"Claude Configuration"}),e.jsx("p",{className:"text-xs text-ink-faint mb-4",children:"Configure how Claude Code authenticates on cloud sandboxes in this organization."}),e.jsxs("div",{className:"border border-border divide-y divide-border",children:[e.jsxs("div",{className:"px-4 py-3",children:[e.jsx("label",{className:"block text-sm font-medium text-ink mb-1",children:"Anthropic API Key"}),e.jsx("p",{className:"text-xs text-ink-faint mb-2",children:"Encrypted at rest. Consider using an API key helper for automatic rotation."}),e.jsx("input",{type:"password",value:c,onChange:m=>i(m.target.value),placeholder:"sk-ant-api03-...",className:"w-full text-sm px-3 py-1.5 border border-border bg-surface text-ink placeholder:text-ink-faint focus:outline-none focus:border-ink"})]}),e.jsxs("div",{className:"px-4 py-3",children:[e.jsx("label",{className:"block text-sm font-medium text-ink mb-1",children:"Base URL"}),e.jsx("p",{className:"text-xs text-ink-faint mb-2",children:"Custom Anthropic API endpoint (leave blank for default)."}),e.jsx("input",{type:"text",value:t,onChange:m=>x(m.target.value),placeholder:"https://api.anthropic.com",className:"w-full text-sm px-3 py-1.5 border border-border bg-surface text-ink placeholder:text-ink-faint focus:outline-none focus:border-ink"})]}),e.jsxs("div",{className:"px-4 py-3",children:[e.jsx("label",{className:"block text-sm font-medium text-ink mb-1",children:"API Key Helper"}),e.jsx("p",{className:"text-xs text-ink-faint mb-2",children:"Path to a script that prints a valid API key to stdout. Used for token rotation."}),e.jsx("input",{type:"text",value:p,onChange:m=>k(m.target.value),placeholder:"/usr/local/bin/token-helper.sh",className:"w-full text-sm px-3 py-1.5 border border-border bg-surface text-ink placeholder:text-ink-faint focus:outline-none focus:border-ink"}),p&&e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"block text-xs text-ink-muted mb-1",children:"Refresh interval (minutes)"}),e.jsx("input",{type:"number",value:b,onChange:m=>v(parseInt(m.target.value,10)||60),min:1,className:"w-24 text-sm px-3 py-1.5 border border-border bg-surface text-ink focus:outline-none focus:border-ink"})]})]}),e.jsxs("div",{className:"px-4 py-3",children:[e.jsx("label",{className:"block text-sm font-medium text-ink mb-1",children:"Environment Variables"}),e.jsx("p",{className:"text-xs text-ink-faint mb-2",children:"Additional env vars injected into project sessions."}),A.map((m,N)=>e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{type:"text",value:m.key,onChange:S=>C(N,"key",S.target.value),placeholder:"KEY",className:"flex-1 text-sm px-3 py-1.5 border border-border bg-surface text-ink placeholder:text-ink-faint focus:outline-none focus:border-ink font-mono"}),e.jsx("input",{type:"text",value:m.value,onChange:S=>C(N,"value",S.target.value),placeholder:"value",className:"flex-[2] text-sm px-3 py-1.5 border border-border bg-surface text-ink placeholder:text-ink-faint focus:outline-none focus:border-ink font-mono"}),e.jsx("button",{onClick:()=>l(N),className:"text-xs text-red-500 hover:text-red-700 px-2",children:"Remove"})]},N)),e.jsx("button",{onClick:$,className:"text-xs text-ink-muted hover:text-ink transition-colors",children:"+ Add variable"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:P,disabled:d,className:"text-sm font-medium px-4 py-1.5 bg-ink text-surface hover:opacity-90 transition-opacity disabled:opacity-50",children:d?"Saving...":"Save changes"}),g&&e.jsx("span",{className:"text-xs text-green-600",children:g}),h&&e.jsx("span",{className:"text-xs text-red-600",children:h})]})]})}const ne=[["projects","Projects"],["sites","Published Sites"],["members","Members"],["invites","Invites"],["settings","Settings"]],ae=[["projects","Projects"],["sites","Published Sites"],["members","Members"]];function re({orgId:s,orgName:n,user:r,role:o,onLogout:j}){const[d,y]=a.useState("projects"),h=o==="admin",f=h?ne:ae;return e.jsxs("div",{className:"min-h-screen bg-surface",children:[e.jsxs("header",{className:"border-b border-border px-6 py-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/logo.svg",alt:"ooda",className:"h-5"}),e.jsx("span",{className:"text-ink-faint",children:"/"}),e.jsx("span",{className:"text-sm font-medium text-ink",children:n})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-xs text-ink-faint",children:r.email}),e.jsx("button",{onClick:j,className:"text-xs text-ink-muted hover:text-ink transition-colors",children:"Sign out"})]})]}),e.jsx("div",{className:"border-b border-border px-6",children:e.jsx("nav",{className:"flex gap-6",children:f.map(([g,u])=>e.jsx("button",{onClick:()=>y(g),className:`py-3 text-sm font-medium border-b-2 transition-colors ${d===g?"border-ink text-ink":"border-transparent text-ink-muted hover:text-ink"}`,children:u},g))})}),e.jsxs("main",{className:"max-w-4xl mx-auto px-6 py-8",children:[d==="projects"&&e.jsx(Z,{orgId:s,role:o}),d==="sites"&&e.jsx(te,{orgId:s,role:o}),d==="members"&&e.jsx(V,{orgId:s,role:o}),d==="invites"&&h&&e.jsx(G,{orgId:s}),d==="settings"&&h&&e.jsx(se,{orgId:s})]})]})}function le(){const[s,n]=a.useState(null),[r,o]=a.useState([]),[j,d]=a.useState(null),[y,h]=a.useState(!0);a.useEffect(()=>{(async()=>{if(!H()){h(!1);return}const t=await J();if(t){n(t.user);const x=localStorage.getItem("ooda-selected-org"),p=localStorage.getItem("ooda-selected-org-name"),k=t.orgs.find(b=>b.orgId===x);if(k)o(t.orgs.map(b=>({...b,orgName:b.orgId===x&&p||b.orgId}))),d({...k,orgName:p||k.orgId});else if(t.orgs.length>0){const b=t.orgs.map(v=>({...v,orgName:v.orgId}));o(b),d(b[0]),localStorage.setItem("ooda-selected-org",b[0].orgId),localStorage.setItem("ooda-selected-org-name",b[0].orgName)}}else U();h(!1)})()},[]);const f=(i,t,x,p)=>{Y(x,p),n(i),o(t);const b=t.find(v=>v.role==="admin")||t[0];b&&(d(b),localStorage.setItem("ooda-selected-org",b.orgId),localStorage.setItem("ooda-selected-org-name",b.orgName))},g=()=>{U(),localStorage.removeItem("ooda-selected-org"),localStorage.removeItem("ooda-selected-org-name"),n(null),o([]),d(null)};if(y)return e.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-ink-muted",children:"Loading..."})});if(!s||!j)return e.jsx(z,{onLogin:f});const u=r.find(i=>i.orgId===j.orgId),c=(u==null?void 0:u.role)||"member";return e.jsx(re,{orgId:j.orgId,orgName:j.orgName,user:s,role:c,onLogout:g})}export{le as AdminApp};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{r as s,j as e}from"./index-5I_ipmZc.js";function I({onOpen:b}){const[d,a]=s.useState([]),[N,i]=s.useState(!0),[k,l]=s.useState(null),[u,v]=s.useState({}),t=async()=>{i(!0);try{const j=(await(await fetch("/api/projects")).json()).projects||[];a(j);const m={};await Promise.all(j.map(async c=>{try{const g=await fetch(`https://ooda.run/api/publish/${c.name}`);g.ok&&(m[c.name]=await g.json())}catch{}})),v(m)}catch{a([])}finally{i(!1)}};s.useEffect(()=>{t()},[]);const y=async o=>{if(confirm(`Delete project "${o}"? This cannot be undone.`)){l(o);try{const p=await fetch(`/api/projects/${o}`,{method:"DELETE"});if(!p.ok){const j=await p.json().catch(()=>({error:"Unknown error"}));alert(`Failed to delete project: ${j.error||p.statusText}`);return}a(j=>j.filter(m=>m.name!==o))}finally{l(null)}}};return N?e.jsx("div",{className:"text-center py-12 text-sm text-ink-faint",children:"Loading projects..."}):d.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-ink-muted text-sm mb-1",children:"No projects yet"}),e.jsx("p",{className:"text-ink-faint text-xs",children:"Create a new project or deploy a local folder to get started."})]}):e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs font-semibold text-ink uppercase tracking-widest mb-4",children:"Projects"}),e.jsx("div",{className:"space-y-2",children:d.map(o=>{const p=o.isOwn!==!1;return e.jsxs("div",{className:"flex items-center justify-between p-4 border border-border hover:border-ink-faint transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${o.status==="running"?"bg-green-500":o.status==="stopped"?"bg-border":"bg-yellow-500"}`}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:o.name}),e.jsxs("p",{className:"text-xs text-ink-faint font-mono mt-0.5",children:[o.owner&&e.jsxs("span",{children:[o.owner,o.isOwn&&e.jsx("span",{className:"text-ink-muted ml-1",children:"(you)"}),o.url&&e.jsx("span",{className:"mx-1",children:"·"})]}),o.url&&o.url]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[u[o.name]&&e.jsx("a",{href:u[o.name].latestUrl,target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1.5 text-sm font-medium text-green-700 bg-green-50 hover:bg-green-100 transition-colors",children:"Published"}),p&&o.url&&e.jsx("button",{onClick:()=>b({name:o.name,url:o.url}),className:"px-3 py-1.5 text-sm font-medium text-ink-muted bg-border/50 hover:bg-border transition-colors",children:"Open"}),p&&e.jsx("button",{onClick:()=>y(o.name),disabled:k===o.name,className:"px-3 py-1.5 text-sm text-ink-faint hover:text-ink transition-colors disabled:opacity-50",children:k===o.name?"...":"Delete"})]})]},o.name)})})]})}function G({onCreate:b,deploying:d}){const[a,N]=s.useState([]),[i,k]=s.useState(""),[l,u]=s.useState(null);s.useEffect(()=>{fetch("/api/templates").then(t=>t.json()).then(t=>{var y;N(t.templates||[]),((y=t.templates)==null?void 0:y.length)>0&&u(t.templates[0].id)})},[]);const v=t=>{t.preventDefault(),!(!i.trim()||!l)&&b(i.trim(),l)};return e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs font-semibold text-ink uppercase tracking-widest mb-4",children:"Create new project"}),e.jsxs("form",{onSubmit:v,className:"max-w-lg space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-ink-muted mb-1.5",children:"Project name"}),e.jsx("input",{id:"project-name",type:"text",value:i,onChange:t=>k(t.target.value),placeholder:"my-project",className:"w-full px-3 py-2 border border-border text-sm focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-ink-muted mb-3",children:"Template"}),e.jsx("div",{className:"space-y-2",children:a.map(t=>e.jsxs("label",{className:`flex items-start gap-3 p-4 border cursor-pointer transition-colors ${l===t.id?"border-ink bg-surface":"border-border hover:border-border"}`,children:[e.jsx("input",{type:"radio",name:"template",value:t.id,checked:l===t.id,onChange:()=>u(t.id),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:t.name}),e.jsx("p",{className:"text-xs text-ink-muted mt-0.5",children:t.description})]})]},t.id))})]}),e.jsx("button",{type:"submit",disabled:!i.trim()||!l||d,className:"px-6 py-2 bg-ink text-surface text-sm font-medium hover:bg-ink/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:d?"Creating...":"Create project"})]})]})}function H({onDeploy:b,deploying:d}){const[a,N]=s.useState(null),[i,k]=s.useState(null),[l,u]=s.useState(!0),[v,t]=s.useState(!1),[y,o]=s.useState(""),[p,j]=s.useState(""),m=s.useCallback(async c=>{u(!0);try{const g=c?`?path=${encodeURIComponent(c)}`:"",D=await fetch(`/api/browse${g}`);if(!D.ok)throw new Error;const P=await D.json();N(P),k(null),t(!1)}catch{t(!0)}finally{u(!1)}},[]);return s.useEffect(()=>{m()},[m]),v?e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs font-semibold text-ink uppercase tracking-widest mb-4",children:"Deploy a folder"}),e.jsxs("div",{className:"max-w-lg space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"project-name-fallback",className:"block text-sm font-medium text-ink-muted mb-1.5",children:"Project name"}),e.jsx("input",{id:"project-name-fallback",type:"text",value:p,onChange:c=>j(c.target.value),placeholder:"Defaults to folder name",className:"w-full px-3 py-2 border border-border text-sm focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"folder-path",className:"block text-sm font-medium text-ink-muted mb-1.5",children:"Folder path"}),e.jsx("input",{id:"folder-path",type:"text",value:y,onChange:c=>o(c.target.value),placeholder:"Leave empty to deploy the current directory",className:"w-full px-3 py-2 border border-border text-sm focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"}),e.jsx("p",{className:"mt-1.5 text-xs text-ink-faint",children:"Absolute path to a project folder with a package.json."})]}),e.jsx("button",{onClick:()=>b(y.trim()||void 0,p.trim()||void 0),disabled:d,className:"px-6 py-2 bg-ink text-surface text-sm font-medium hover:bg-ink/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:d?"Deploying...":"Deploy"})]})]}):e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs font-semibold text-ink uppercase tracking-widest mb-4",children:"Deploy a folder"}),e.jsxs("div",{className:"max-w-lg space-y-3",children:[a&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-ink-muted",children:[a.parent&&e.jsx("button",{onClick:()=>m(a.parent),disabled:l,className:"px-2 py-0.5 font-medium text-ink-muted bg-border/50 border border-border hover:bg-border disabled:opacity-30 transition-colors",children:"←"}),e.jsx("span",{className:"font-mono truncate",children:a.current})]}),e.jsx("div",{className:"border border-border overflow-hidden",children:l&&!a?e.jsx("div",{className:"px-3 py-8 text-center text-sm text-ink-faint",children:"Loading..."}):e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[(a==null?void 0:a.entries.length)===0&&e.jsx("div",{className:"px-3 py-8 text-center text-sm text-ink-faint",children:"No subfolders"}),a==null?void 0:a.entries.map(c=>{const g=i===c.path;return e.jsxs("button",{type:"button",className:`w-full flex items-center gap-2.5 px-3 py-2 text-left border-b border-border/30 last:border-0 transition-colors ${g?"bg-ink text-surface":"hover:bg-border/30"}`,onClick:()=>k(g?null:c.path),onDoubleClick:()=>m(c.path),children:[e.jsx("span",{className:"text-sm flex-shrink-0",children:c.hasPackageJson?"📦":"📁"}),e.jsx("span",{className:`text-sm truncate ${g?"text-surface font-medium":"text-ink"}`,children:c.name}),c.hasPackageJson&&e.jsx("span",{className:`ml-auto text-[11px] flex-shrink-0 ${g?"text-ink-faint":"text-ink-muted"}`,children:"project"})]},c.path)})]})}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-ink-muted mb-1.5",children:"Project name"}),e.jsx("input",{id:"project-name",type:"text",value:p,onChange:c=>j(c.target.value),placeholder:"Defaults to folder name",className:"w-full px-3 py-2 border border-border text-sm focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsx("button",{onClick:()=>b(i||void 0,p.trim()||void 0),disabled:d||!i,className:"px-6 py-2 bg-ink text-surface text-sm font-medium hover:bg-ink/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:d?"Deploying...":"Deploy"}),e.jsx("span",{className:"text-xs text-ink-faint",children:i?e.jsx("span",{className:"font-mono text-ink-muted",children:i}):"Click to select, double-click to open"})]})]})]})}function M({onDeploy:b,deploying:d}){const[a,N]=s.useState(""),[i,k]=s.useState(""),[l,u]=s.useState([]),[v,t]=s.useState(null),[y,o]=s.useState(null),[p,j]=s.useState(!0),[m,c]=s.useState("");s.useEffect(()=>{fetch("/api/github-repos").then(n=>n.json()).then(n=>{u(n.repos),t(n.authenticated),o(n.username||null)}).catch(()=>t(!1)).finally(()=>j(!1))},[]);const g=()=>{const n=a.trim();n&&b(n,i.trim()||void 0)},D=n=>{N(n.fullName),k("")},P=m?l.filter(n=>n.fullName.toLowerCase().includes(m.toLowerCase())||n.description&&n.description.toLowerCase().includes(m.toLowerCase())):l;return e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xs font-semibold text-ink uppercase tracking-widest mb-4",children:["Clone from GitHub",y&&e.jsxs("span",{className:"text-ink-faint font-normal normal-case tracking-normal ml-2",children:["signed in as ",y]})]}),e.jsxs("div",{className:"max-w-lg space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"github-url",className:"block text-sm font-medium text-ink-muted mb-1.5",children:"GitHub URL"}),e.jsx("input",{id:"github-url",type:"text",value:a,onChange:n=>N(n.target.value),onKeyDown:n=>n.key==="Enter"&&g(),placeholder:"owner/repo or https://github.com/owner/repo",className:"w-full px-3 py-2 border border-border text-sm focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent font-mono"}),e.jsx("p",{className:"mt-1.5 text-xs text-ink-faint",children:"Paste a URL, or pick from your repos below. Add #branch for a specific branch."})]}),v===!1&&e.jsxs("p",{className:"text-xs text-ink-muted",children:["No GitHub token detected. Run ",e.jsx("span",{className:"font-mono font-medium",children:"gh auth login"})," to see your repos here."]}),v&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("label",{className:"block text-sm font-medium text-ink-muted",children:"Your repos"}),l.length>5&&e.jsx("input",{type:"text",value:m,onChange:n=>c(n.target.value),placeholder:"Filter...",className:"px-2 py-1 border border-border text-xs focus:outline-none focus:ring-1 focus:ring-ink w-40"})]}),e.jsx("div",{className:"border border-border overflow-hidden",children:p?e.jsx("div",{className:"px-3 py-8 text-center text-sm text-ink-faint",children:"Loading repos..."}):P.length===0?e.jsx("div",{className:"px-3 py-8 text-center text-sm text-ink-faint",children:m?"No matching repos":"No repos found"}):e.jsx("div",{className:"max-h-64 overflow-y-auto",children:P.map(n=>{const $=a===n.fullName;return e.jsxs("button",{type:"button",className:`w-full flex items-center gap-2.5 px-3 py-2 text-left border-b border-border/30 last:border-0 transition-colors ${$?"bg-ink text-surface":"hover:bg-border/30"}`,onClick:()=>D(n),children:[e.jsx("span",{className:"text-sm flex-shrink-0",children:n.isPrivate?"🔒":"📦"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`text-sm truncate block ${$?"text-surface font-medium":"text-ink"}`,children:n.fullName}),n.description&&e.jsx("span",{className:`text-xs truncate block ${$?"text-surface/60":"text-ink-faint"}`,children:n.description})]})]},n.fullName)})})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"gh-project-name",className:"block text-sm font-medium text-ink-muted mb-1.5",children:"Project name"}),e.jsx("input",{id:"gh-project-name",type:"text",value:i,onChange:n=>k(n.target.value),onKeyDown:n=>n.key==="Enter"&&g(),placeholder:"Defaults to repo name",className:"w-full px-3 py-2 border border-border text-sm focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"})]}),e.jsx("button",{onClick:g,disabled:d||!a.trim(),className:"px-6 py-2 bg-ink text-surface text-sm font-medium hover:bg-ink/80 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:d?"Deploying...":"Clone & Deploy"})]})]})}function _({onLogin:b,authenticated:d}){const[a,N]=s.useState(""),[i,k]=s.useState(null),l=u=>{if(u.preventDefault(),!a.trim()){k("Please enter your Claude API key or OAuth token");return}k(null),b("",a.trim())};return e.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("img",{src:"/logo.svg",alt:"ooda",className:"h-6 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-ink-muted",children:d?"Connect Claude to edit code on your cloud sandbox":"Sign in to manage cloud sandboxes"})]}),e.jsxs("form",{onSubmit:l,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"claude-token",className:"block text-sm font-medium text-ink-muted mb-1.5",children:"Claude API Key or OAuth Token"}),e.jsx("input",{id:"claude-token",type:"password",value:a,onChange:u=>N(u.target.value),placeholder:"sk-ant-... or oauth token",autoFocus:!0,className:"w-full px-3 py-2 border border-border text-sm focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"}),e.jsxs("p",{className:"mt-1.5 text-xs text-ink-faint",children:[e.jsx("strong",{children:"API key"}),": get from"," ",e.jsx("a",{href:"https://console.anthropic.com/settings/keys",target:"_blank",rel:"noopener noreferrer",className:"text-ink-muted underline hover:text-ink",children:"console.anthropic.com"}),e.jsx("br",{}),e.jsx("strong",{children:"OAuth token"}),": run"," ",e.jsx("code",{className:"bg-border/50 px-1 text-xs font-mono",children:"claude setup-token"})," ","in your terminal (for Claude Pro/Teams)"]})]}),i&&e.jsx("p",{className:"text-sm text-red-600",children:i}),e.jsx("button",{type:"submit",className:"w-full px-4 py-2 bg-ink text-surface text-sm font-medium hover:bg-ink/80 transition-colors",children:"Sign in"})]})]})})}function B(){const d=new URLSearchParams(window.location.search).get("view");return d==="new"||d==="deploy"||d==="github"?d:"projects"}function V(){const[b,d]=s.useState(null),[a,N]=s.useState(null),[i,k]=s.useState(B),[l,u]=s.useState(!1),[v,t]=s.useState(null);s.useEffect(()=>{Promise.all([fetch("/api/auth").then(r=>r.json()),fetch("/api/detect").then(r=>r.json())]).then(([r,f])=>{d({authenticated:r.authenticated,claudeAuthenticated:r.claudeAuthenticated}),N(f)})},[]);const y=async(r,f)=>{(await fetch("/api/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeToken:f})})).ok&&d({authenticated:!0,claudeAuthenticated:!0})},o=async r=>{if(r.projectName&&r.projectUrl)try{await fetch("/api/project-opened",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:r.projectName,projectUrl:r.projectUrl,projectRoot:r.projectRoot||`/home/user/${r.projectName}`})})}catch{}},[p,j]=s.useState(null),[m,c]=s.useState([]),g=async(r,f)=>{u(!0),t(null),j(null),c([]);try{const x=await fetch("/api/deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,name:f})});if(!x.ok||!x.body){const C=await x.json();t(C.error||"Deploy failed");return}const w=x.body.getReader(),A=new TextDecoder;let S="";for(;;){const{done:C,value:F}=await w.read();if(C)break;S+=A.decode(F,{stream:!0});const U=S.split(`
|
|
2
|
+
|
|
3
|
+
`);S=U.pop()||"";for(const T of U){const O=T.match(/^event: (.+)$/m),E=T.match(/^data: (.+)$/m);if(!O||!E)continue;const L=O[1],h=JSON.parse(E[1]);if(L==="progress"){const R=h.detail?`${h.step} (${h.detail})`:h.step;c(J=>[...J,R])}else L==="done"&&(h.success&&h.projectUrl?j({projectName:h.projectName,projectUrl:h.projectUrl}):t(h.error||"Deploy failed"))}}}catch(x){t(x instanceof Error?x.message:"Deploy failed")}finally{u(!1)}},D=async(r,f)=>{u(!0),t(null),j(null),c([]);try{const x=await fetch("/api/deploy-github",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:r,name:f})});if(!x.ok||!x.body){const C=await x.json();t(C.error||"Deploy failed");return}const w=x.body.getReader(),A=new TextDecoder;let S="";for(;;){const{done:C,value:F}=await w.read();if(C)break;S+=A.decode(F,{stream:!0});const U=S.split(`
|
|
4
|
+
|
|
5
|
+
`);S=U.pop()||"";for(const T of U){const O=T.match(/^event: (.+)$/m),E=T.match(/^data: (.+)$/m);if(!O||!E)continue;const L=O[1],h=JSON.parse(E[1]);if(L==="progress"){const R=h.detail?`${h.step} (${h.detail})`:h.step;c(J=>[...J,R])}else L==="done"&&(h.success&&h.projectUrl?j({projectName:h.projectName,projectUrl:h.projectUrl}):t(h.error||"Deploy failed"))}}}catch(x){t(x instanceof Error?x.message:"Deploy failed")}finally{u(!1)}},P=async(r,f)=>{u(!0),t(null);try{const w=await(await fetch("/api/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r,templateId:f})})).json();w.success&&w.projectUrl?window.location.href=w.projectUrl:t(w.error||"Create failed")}catch(x){t(x instanceof Error?x.message:"Create failed")}finally{u(!1)}},n=async r=>{await o({projectName:r.name,projectUrl:r.url,projectRoot:`/home/user/${r.name}`}),window.location.href=r.url};if(b===null)return e.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:e.jsx("div",{className:"text-ink-faint text-sm",children:"Loading..."})});if(!b.authenticated||!b.claudeAuthenticated)return e.jsx(_,{onLogin:y,authenticated:b.authenticated});const $=[["projects","Browse projects"],["deploy","Pick a folder"],["github","Deploy from GitHub"],["new","Start from scratch"]];return e.jsxs("div",{className:"min-h-screen bg-surface text-ink antialiased",children:[e.jsx("header",{className:"fixed top-0 left-0 right-0 z-10 px-6 bg-surface/95 backdrop-blur-sm border-b border-border",children:e.jsxs("div",{className:"flex items-center justify-between h-12",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/logo.svg",alt:"ooda",className:"h-5"}),e.jsx("span",{className:"text-ink-faint",children:"/"}),e.jsx("span",{className:"text-sm font-medium text-ink",children:"Deploy tool"})]}),e.jsxs("nav",{className:"flex items-center gap-6 h-full",children:[$.map(([r,f])=>e.jsx("button",{onClick:()=>k(r),className:`h-full text-sm font-medium border-b-2 transition-colors ${i===r?"border-ink text-ink":"border-transparent text-ink-muted hover:text-ink"}`,children:f},r)),e.jsx("a",{href:"https://app.ooda.run",target:"_blank",rel:"noopener noreferrer",className:"ml-2 px-3 py-1 text-sm font-medium text-ink-muted bg-border/50 hover:bg-border transition-colors",children:"Go to app"})]})]})}),e.jsxs("main",{className:"max-w-4xl mx-auto px-6 pt-20 pb-8",children:[(a==null?void 0:a.isProject)&&i==="deploy"&&e.jsxs("div",{className:"mb-6 p-4 border border-border flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-ink",children:["Detected project: ",a.name]}),e.jsx("p",{className:"text-xs text-ink-muted font-mono mt-0.5",children:a.path})]}),e.jsx("button",{onClick:()=>g(),disabled:l,className:"px-4 py-2 bg-ink text-surface text-sm font-medium hover:bg-ink/80 disabled:opacity-50 transition-colors",children:l?"Deploying...":"Deploy this project"})]}),p&&e.jsxs("div",{className:"mb-6 p-4 border border-border",children:[e.jsxs("p",{className:"text-sm font-medium text-ink",children:["Deployed to ",p.projectName]}),e.jsx("p",{className:"text-sm text-ink-muted mt-1",children:"Switch to your terminal — Claude is connecting and will start the dev server."}),e.jsx("a",{href:p.projectUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-block mt-2 text-xs text-ink-muted underline hover:text-ink",children:p.projectUrl})]}),v&&e.jsxs("div",{className:"mb-6 p-4 border border-border",children:[e.jsx("p",{className:"text-sm font-medium text-ink mb-1",children:"Something went wrong"}),e.jsx("pre",{className:"text-xs text-ink-muted whitespace-pre-wrap break-all font-mono",children:v}),e.jsx("button",{onClick:()=>t(null),className:"mt-2 text-xs text-ink-muted underline hover:text-ink",children:"Dismiss"})]}),i==="projects"&&e.jsx(I,{onOpen:n}),i==="github"&&e.jsxs(e.Fragment,{children:[e.jsx(M,{onDeploy:D,deploying:l}),m.length>0&&e.jsx("div",{className:"mt-6 max-w-lg",children:e.jsxs("div",{className:"border border-border bg-ink p-4 font-mono text-xs text-ink-faint max-h-60 overflow-y-auto",children:[m.map((r,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-green-400 flex-shrink-0",children:f===m.length-1&&l?"▸":"✓"}),e.jsx("span",{children:r})]},f)),l&&e.jsx("div",{className:"text-ink-muted mt-1 animate-pulse",children:"Working..."})]})})]}),i==="new"&&e.jsx(G,{onCreate:P,deploying:l}),i==="deploy"&&e.jsxs(e.Fragment,{children:[e.jsx(H,{onDeploy:g,deploying:l}),m.length>0&&e.jsx("div",{className:"mt-6 max-w-lg",children:e.jsxs("div",{className:"border border-border bg-ink p-4 font-mono text-xs text-ink-faint max-h-60 overflow-y-auto",children:[m.map((r,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-green-400 flex-shrink-0",children:f===m.length-1&&l?"▸":"✓"}),e.jsx("span",{children:r})]},f)),l&&e.jsx("div",{className:"text-ink-muted mt-1 animate-pulse",children:"Working..."})]})})]})]})]})}export{V as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,j as e}from"./index-5I_ipmZc.js";import{g as A,a as E,c as y,i as j}from"./api-DbuItvnH.js";function g(l){const m=Date.now()-new Date(l).getTime(),n=Math.floor(m/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const c=Math.floor(n/60);return c<24?`${c}h ago`:`${Math.floor(c/24)}d ago`}function O({onCreated:l,onCancel:m}){const[n,c]=r.useState(""),[o,x]=r.useState(""),[d,t]=r.useState(""),[i,a]=r.useState([]),[u,h]=r.useState(null),[p,b]=r.useState(!1),[N,w]=r.useState(null),k=()=>{const s=d.trim().toLowerCase();!s||!s.includes("@")||i.includes(s)||(a([...i,s]),t(""))},C=s=>{a(i.filter(f=>f!==s))},S=async s=>{if(s.preventDefault(),i.length===0){h("Add at least one admin email");return}h(null),b(!0);try{const f=await j("/orgs",{method:"POST",body:JSON.stringify({orgId:n,orgName:o||n,adminEmails:i})}),v=await f.json();if(!f.ok){h(v.error||"Failed to create org");return}w(v)}catch{h("Could not reach the server")}finally{b(!1)}};return N?e.jsxs("div",{className:"border border-border p-6 mb-6 bg-white",children:[e.jsx("h3",{className:"text-sm font-medium text-ink mb-4",children:"Organisation created"}),e.jsxs("p",{className:"text-sm text-ink-muted mb-3",children:[e.jsx("span",{className:"font-medium text-ink",children:o||n})," ",e.jsxs("span",{className:"text-ink-faint",children:["(",n,")"]})]}),e.jsx("div",{className:"space-y-1 mb-4",children:N.invites.map(s=>e.jsxs("p",{className:"text-sm text-ink-muted",children:[s.email," — ",s.emailSent?"invite sent":"invite created (email not sent)"]},s.email))}),e.jsx("button",{onClick:l,className:"px-4 py-2 bg-ink text-surface text-sm font-medium hover:bg-ink/80 transition-colors",children:"Done"})]}):e.jsxs("form",{onSubmit:S,className:"border border-border p-6 mb-6 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-medium text-ink",children:"Create organisation"}),e.jsx("button",{type:"button",onClick:m,className:"text-xs text-ink-muted hover:text-ink transition-colors",children:"Cancel"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"orgId",className:"block text-xs font-medium text-ink-muted mb-1",children:"Org ID (slug)"}),e.jsx("input",{id:"orgId",type:"text",value:n,onChange:s=>c(s.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),required:!0,placeholder:"wise-workshop",className:"w-full px-3 py-2 border border-border text-sm bg-white focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"orgName",className:"block text-xs font-medium text-ink-muted mb-1",children:"Display name"}),e.jsx("input",{id:"orgName",type:"text",value:o,onChange:s=>x(s.target.value),placeholder:n||"Wise Workshop",className:"w-full px-3 py-2 border border-border text-sm bg-white focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-xs font-medium text-ink-muted mb-1",children:"Admin emails"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"email",value:d,onChange:s=>t(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),k())},placeholder:"admin@example.com",className:"flex-1 px-3 py-2 border border-border text-sm bg-white focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent"}),e.jsx("button",{type:"button",onClick:k,className:"px-3 py-2 border border-border text-sm text-ink-muted hover:text-ink hover:border-ink transition-colors",children:"Add"})]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:i.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-surface-alt text-sm text-ink",children:[s,e.jsx("button",{type:"button",onClick:()=>C(s),className:"text-ink-faint hover:text-ink ml-1",children:"×"})]},s))})]}),u&&e.jsx("p",{className:"text-sm text-red-600 mb-4",children:u}),e.jsx("button",{type:"submit",disabled:p||!n||i.length===0,className:"px-4 py-2 bg-ink text-surface text-sm font-medium hover:bg-ink/80 transition-colors disabled:opacity-50",children:p?"Creating...":"Create organisation"})]})}function I(){const[l,m]=r.useState([]),[n,c]=r.useState(!0),[o,x]=r.useState(null),[d,t]=r.useState(!1),i=async()=>{c(!0);try{const a=await j("/orgs");if(!a.ok){x(a.status===401?"Not authorized (requires internal admin)":"Failed to load orgs");return}const u=await a.json();m(u.orgs||[])}catch{x("Could not reach the server")}finally{c(!1)}};return r.useEffect(()=>{i()},[]),n?e.jsx("p",{className:"text-sm text-ink-muted",children:"Loading orgs..."}):o?e.jsx("p",{className:"text-sm text-red-600",children:o}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-medium text-ink",children:["Organisations",e.jsx("span",{className:"text-ink-faint font-normal ml-2",children:l.length})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>t(!0),className:"px-3 py-1.5 bg-ink text-surface text-xs font-medium hover:bg-ink/80 transition-colors",children:"Create org"}),e.jsx("button",{onClick:i,className:"text-xs text-ink-muted hover:text-ink transition-colors",children:"Refresh"})]})]}),d&&e.jsx(O,{onCreated:()=>{t(!1),i()},onCancel:()=>t(!1)}),l.length===0?e.jsx("div",{className:"border border-border py-12 text-center",children:e.jsx("p",{className:"text-sm text-ink-muted",children:"No organisations yet"})}):e.jsxs("div",{className:"border border-border divide-y divide-border",children:[e.jsxs("div",{className:"grid grid-cols-6 gap-4 px-4 py-2 text-xs font-medium text-ink-muted bg-surface-alt",children:[e.jsx("span",{className:"col-span-2",children:"Name"}),e.jsx("span",{children:"Projects"}),e.jsx("span",{children:"Members"}),e.jsx("span",{children:"Limit"}),e.jsx("span",{children:"Created"})]}),l.map(a=>e.jsxs("div",{className:"grid grid-cols-6 gap-4 px-4 py-3 items-center",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:a.name}),e.jsx("p",{className:"text-xs text-ink-faint",children:a.id})]}),e.jsx("span",{className:"text-sm text-ink",children:a.projectCount}),e.jsx("span",{className:"text-sm text-ink",children:a.memberCount}),e.jsx("span",{className:"text-sm text-ink-muted",children:a.maxProjects}),e.jsx("span",{className:"text-xs text-ink-faint",title:a.createdAt,children:g(a.createdAt)})]},a.id))]})]})}function L(){const[l,m]=r.useState([]),[n,c]=r.useState(!0),[o,x]=r.useState(null),d=async()=>{c(!0);try{const t=await j("/projects");if(!t.ok){x(t.status===401?"Not authorized (requires internal admin)":"Failed to load projects");return}const i=await t.json();m(i.projects||[])}catch{x("Could not reach the server")}finally{c(!1)}};return r.useEffect(()=>{d()},[]),n?e.jsx("p",{className:"text-sm text-ink-muted",children:"Loading projects..."}):o?e.jsx("p",{className:"text-sm text-red-600",children:o}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-medium text-ink",children:["All Projects",e.jsx("span",{className:"text-ink-faint font-normal ml-2",children:l.length})]}),e.jsx("button",{onClick:d,className:"text-xs text-ink-muted hover:text-ink transition-colors",children:"Refresh"})]}),l.length===0?e.jsx("div",{className:"border border-border py-12 text-center",children:e.jsx("p",{className:"text-sm text-ink-muted",children:"No projects across any org"})}):e.jsxs("div",{className:"border border-border divide-y divide-border",children:[e.jsxs("div",{className:"grid grid-cols-5 gap-4 px-4 py-2 text-xs font-medium text-ink-muted bg-surface-alt",children:[e.jsx("span",{children:"Project"}),e.jsx("span",{children:"Org"}),e.jsx("span",{children:"Owner"}),e.jsx("span",{children:"Last Active"}),e.jsx("span",{children:"Created"})]}),l.map(t=>e.jsxs("div",{className:"grid grid-cols-5 gap-4 px-4 py-3 items-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:t.name}),t.previewUrl&&e.jsx("a",{href:t.previewUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-blue-600 hover:underline truncate block",children:"preview"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-ink",children:t.orgName||t.orgId}),t.orgName&&e.jsx("p",{className:"text-xs text-ink-faint",children:t.orgId})]}),e.jsx("span",{className:"text-sm text-ink-muted truncate",children:t.ownerEmail||"—"}),e.jsx("span",{className:"text-xs text-ink-muted",title:t.lastActiveAt||"",children:t.lastActiveAt?g(t.lastActiveAt):"—"}),e.jsx("span",{className:"text-xs text-ink-faint",title:t.createdAt,children:g(t.createdAt)})]},`${t.orgId}/${t.name}`))]})]})}const D=[["orgs","Organisations"],["projects","All Projects"]];function F(){const[l,m]=r.useState(null),[n,c]=r.useState(!1),[o,x]=r.useState(!0),[d,t]=r.useState("orgs"),i=async()=>(await j("/orgs")).ok;r.useEffect(()=>{(async()=>{if(!A()){x(!1);return}const h=await E();h?(m(h.user),c(await i())):y(),x(!1)})()},[]);const a=()=>{y(),m(null)};return o?e.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-ink-muted",children:"Loading..."})}):!l||!n?e.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-ink-muted",children:"404 — Not found"})}):e.jsxs("div",{className:"min-h-screen bg-surface",children:[e.jsxs("header",{className:"border-b border-border px-6 py-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/logo.svg",alt:"ooda",className:"h-5"}),e.jsx("span",{className:"text-ink-faint",children:"/"}),e.jsx("span",{className:"text-sm font-medium text-ink",children:"Internal"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-xs text-ink-faint",children:l.email}),e.jsx("button",{onClick:a,className:"text-xs text-ink-muted hover:text-ink transition-colors",children:"Sign out"})]})]}),e.jsx("div",{className:"border-b border-border px-6",children:e.jsx("nav",{className:"flex gap-6",children:D.map(([u,h])=>e.jsx("button",{onClick:()=>t(u),className:`py-3 text-sm font-medium border-b-2 transition-colors ${d===u?"border-ink text-ink":"border-transparent text-ink-muted hover:text-ink"}`,children:h},u))})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-6 py-8",children:[d==="orgs"&&e.jsx(I,{}),d==="projects"&&e.jsx(L,{})]})]})}export{F as InternalDashboard};
|