@baochunli/flakes 0.0.2 → 0.0.4
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/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +133 -13
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/host.js +1 -0
- package/dist/commands/host.js.map +1 -1
- package/dist/commands/tasks.js +3 -0
- package/dist/commands/tasks.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +175 -22
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@flakes/auth/package.json +1 -1
- package/dist/node_modules/@flakes/console/.output/nitro.json +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/DocumentationPage-DM-ZYPgQ.js +1 -0
- package/dist/node_modules/@flakes/console/.output/public/assets/{RunPage-BC3sGoPN.js → RunPage-i03UqHYF.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{RunsPage-LkYGVvbL.js → RunsPage-u8qbeAoV.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{SandboxesPage-CwWMogj6.js → SandboxesPage-D8D_5kXP.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{TranscriptPage-CTMgJgHp.js → TranscriptPage-ChoFjiPI.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{_-DRcA_CG9.js → _-C4ecJpHe.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{_runId-CO1ozt9P.js → _runId-BZXYFY32.js} +2 -2
- package/dist/node_modules/@flakes/console/.output/public/assets/{_taskId-CcIypX6M.js → _taskId-C28oHEU_.js} +2 -2
- package/dist/node_modules/@flakes/console/.output/public/assets/{account-DKgjbb-C.js → account-B4wDEC7t.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{account-forms-DrHA3zEd.js → account-forms-BLo66Mqa.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{auth-layout-INHonQMf.js → auth-layout-DiUSgtaY.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{device-DOGZUNMB.js → device-NrLWypMd.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{documentation-Dr9Bdqxh.js → documentation-NRDmcDud.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{forgot-password-C7qvwcpm.js → forgot-password--3Mujc8s.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{main-RzjfJZwD.js → main-KBvz0mSQ.js} +21 -87
- package/dist/node_modules/@flakes/console/.output/public/assets/{otp-verification-Cqa6lopR.js → otp-verification-BSXwS5bo.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{reset-password-tImCgEn0.js → reset-password-C7SbNx2J.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{runs-Cuk0VOVi.js → runs-xD4ynllK.js} +2 -2
- package/dist/node_modules/@flakes/console/.output/public/assets/{sandboxes-BBIIbVN8.js → sandboxes-Cfr1Y2Dn.js} +2 -2
- package/dist/node_modules/@flakes/console/.output/public/assets/{security-D3N68cBT.js → security-CCThSJae.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{signin-DylILjyG.js → signin-CYeR3TaY.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{signin-form-DWaa_uwj.js → signin-form-Bp22jPob.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/{signup-KmFQL_1g.js → signup-DHhPfohX.js} +1 -1
- package/dist/node_modules/@flakes/console/.output/server/{_-8ZDVkA1O.mjs → _-C-u135Pp.mjs} +3 -3
- package/dist/node_modules/@flakes/console/.output/server/{_-CjpSIsvB.mjs → _-DwPiGKLE.mjs} +3 -3
- package/dist/node_modules/@flakes/console/.output/server/_chunks/router.mjs +5 -5
- package/dist/node_modules/@flakes/console/.output/server/_ssr/{DocumentationPage-D85Budiq.mjs → DocumentationPage-CtBAQbzy.mjs} +4 -4
- package/dist/node_modules/@flakes/console/.output/server/_ssr/{documentation-Do_Mr_e4.mjs → documentation-Bf0VPrnt.mjs} +4 -4
- package/dist/node_modules/@flakes/console/.output/server/_ssr/{documentation-4BCES--X.mjs → documentation-PC93pMWl.mjs} +3 -3
- package/dist/node_modules/@flakes/console/.output/server/_ssr/{router-B3vKkNtv.mjs → router-elhBqT5k.mjs} +4 -4
- package/dist/node_modules/@flakes/console/.output/server/_ssr/ssr.mjs +2 -2
- package/dist/node_modules/@flakes/console/.output/server/{_tanstack-start-manifest_v-llXRWxjT.mjs → _tanstack-start-manifest_v-CR_hZXXv.mjs} +31 -31
- package/dist/node_modules/@flakes/console/package.json +1 -1
- package/dist/node_modules/@flakes/control-plane/package.json +1 -1
- package/dist/node_modules/@flakes/core/package.json +1 -1
- package/dist/node_modules/@flakes/harness-agent/package.json +1 -1
- package/dist/node_modules/@flakes/harness-sdk/package.json +1 -1
- package/dist/node_modules/@flakes/pi-agent/package.json +1 -1
- package/dist/node_modules/@flakes/protocol/package.json +1 -1
- package/dist/node_modules/@flakes/sandbox-runtime/package.json +1 -1
- package/dist/node_modules/@flakes/store/package.json +1 -1
- package/package.json +1 -1
- package/dist/node_modules/@flakes/console/.output/public/assets/DocumentationPage-DrqDulyL.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{t as r}from"./link-BsixJinJ.js";import{r as i,t as a}from"./utils-CEE0-YEp.js";import{n as o,r as s,t as c}from"./lib-DtfURcG3.js";import{t as l}from"./save-1uf5fQff.js";import{t as u}from"./x-fKvnmCoQ.js";import{$ as d,J as f,K as p,Q as m,X as ee,Y as h,Z as te,et as g,k as _}from"./main-RzjfJZwD.js";import{a as v,d as y,f as b,l as x,o as ne,r as S,t as re}from"./bits-Cv0Te4iz.js";var ie=i(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),C=i(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),w=i(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),T=i(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),E=i(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),D=i(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),O=n(t(),1),k=e();function A(e){let t=M(e.outbound??[],e.session);if(e.session===null&&t.length===0)return(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.running?`Waiting for Pi session...`:`No Pi session.`});let n=e.session===null?[]:j(e.session.transcript);return n.length===0&&t.length===0?(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.running?`Waiting for Pi session...`:`Pi session has no transcript messages.`}):(0,k.jsxs)(`div`,{className:`grid gap-2.5`,children:[n.map(e=>e.kind===`message`?(0,k.jsx)(F,{text:e.text},e.key):e.kind===`user`?(0,k.jsx)(P,{text:e.text},e.key):e.kind===`tool`?(0,k.jsx)(L,{name:e.name,args:e.args,output:e.output,status:e.status},e.key):e.kind===`thinking`?(0,k.jsx)(R,{text:e.text},e.key):(0,k.jsx)(ae,{level:e.level,text:e.text},e.key)),t.map(e=>(0,k.jsx)(P,{text:e.text,label:`${e.mode===`steer`?`Steer`:`Follow up`} · ${N(e.status)}`,muted:e.status!==`accepted`},e.id)),e.running?(0,k.jsx)(`span`,{className:`caret-blink inline-block h-3.5 w-2 bg-primary`}):null]})}function j(e){let t=[];for(let n of e)switch(n.kind){case`user_message`:t.push({kind:`user`,key:n.id,text:n.text});break;case`assistant_message`:t.push({kind:`message`,key:n.id,text:n.text});break;case`assistant_thinking`:t.push({kind:`thinking`,key:n.id,text:n.text});break;case`tool`:t.push({kind:`tool`,key:n.id,name:n.name,args:n.argsText??(n.args===void 0?void 0:JSON.stringify(n.args)),output:n.resultText,status:n.status===`unknown`?`running`:n.status});break;case`system_notice`:t.push({kind:`system`,key:n.id,level:n.level,text:n.text});break}return t}function M(e,t){return t===null?e:e.filter(e=>!t.transcript.some(t=>t.kind===`user_message`&&t.text===e.text))}function N(e){switch(e){case`sending`:return`sending`;case`accepted`:return`sent to agent`;case`failed`:return`failed`}}function P(e){return(0,k.jsxs)(`div`,{className:a(`ml-auto max-w-[92%] rounded-md px-3.5 py-2.5 text-sm leading-relaxed`,e.muted?`border bg-card/60 text-foreground`:`bg-primary text-primary-foreground`),children:[e.label===void 0?null:(0,k.jsx)(`div`,{className:a(`mb-1 font-mono text-[10px] uppercase tracking-[0.08em]`,e.muted?`text-muted-foreground`:`text-primary-foreground/70`),children:e.label}),(0,k.jsx)(`pre`,{className:`max-h-[24rem] overflow-auto font-sans break-words whitespace-pre-wrap`,children:e.text})]})}function F(e){return(0,k.jsx)(`div`,{className:`rounded-md border bg-card/40 px-3.5 py-2.5 text-sm leading-relaxed`,children:(0,k.jsx)(`div`,{className:`transcript-md`,children:(0,k.jsx)(o,{remarkPlugins:[c],components:se,children:e.text})})})}var I={running:`bg-status-running`,ok:`bg-status-succeeded`,error:`bg-status-failed`};function L(e){return(0,k.jsxs)(`details`,{className:`group rounded-md border bg-muted/30`,children:[(0,k.jsxs)(`summary`,{className:`flex w-full cursor-pointer list-none items-center gap-2 px-3 py-1.5 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-[3px] focus-visible:ring-ring/40 [&::-webkit-details-marker]:hidden`,children:[(0,k.jsx)(s,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-open:rotate-90`}),(0,k.jsx)(`span`,{className:a(`size-1.5 shrink-0 rounded-full`,I[e.status],e.status===`running`&&`animate-pulse`)}),(0,k.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:`used`}),(0,k.jsx)(`span`,{className:`font-mono text-xs font-medium text-foreground`,children:e.name})]}),e.args===void 0?null:(0,k.jsx)(`pre`,{className:`overflow-x-auto border-t px-3 py-2 font-mono text-[11px] break-all whitespace-pre-wrap text-muted-foreground`,children:e.args}),e.output===void 0?null:(0,k.jsx)(`pre`,{className:`max-h-64 overflow-auto border-t bg-background/40 px-3 py-2 font-mono text-[11px] break-words whitespace-pre-wrap text-foreground/80`,children:e.output})]})}function R(e){return(0,k.jsxs)(`details`,{className:`group rounded-md border border-dashed bg-muted/20`,children:[(0,k.jsxs)(`summary`,{className:`flex w-full cursor-pointer list-none items-center gap-2 px-3 py-1.5 text-left outline-none transition-colors hover:bg-muted/35 focus-visible:ring-[3px] focus-visible:ring-ring/40 [&::-webkit-details-marker]:hidden`,children:[(0,k.jsx)(s,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-open:rotate-90`}),(0,k.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:`thinking`})]}),(0,k.jsx)(`pre`,{className:`max-h-64 overflow-auto border-t px-3 py-2 font-mono text-[11px] break-words whitespace-pre-wrap text-foreground/75`,children:e.text})]})}function ae(e){return(0,k.jsx)(`div`,{className:a(`px-1 font-mono text-[11px]`,e.level===`error`?`text-status-failed`:e.level===`warn`?`text-status-warn`:`text-muted-foreground/70`),children:e.text})}var oe=/^(https?:|mailto:)/i,se={a({href:e,children:t}){return e===void 0||!oe.test(e)?(0,k.jsx)(`span`,{children:t}):(0,k.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:t})},img({alt:e}){return(0,k.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground`,children:[`image blocked`,e?`: ${e}`:``]})}},ce=new Set([`SUCCEEDED`,`FAILED`,`CANCELLED`]);function le(e){let t=p(e.runId),[n,i]=(0,O.useState)([]),o=(0,O.useRef)(null),[s,c]=(0,O.useState)(!0),l=t.data?.tasks??[],u=ne(l),f=[...l].sort((e,t)=>(u.get(e.taskId)??0)-(u.get(t.taskId)??0)),h=f.findIndex(t=>t.taskId===e.taskId),g=h>=0?f[h]:void 0,C=h>0?f[h-1]:void 0,w=h>=0&&h<f.length-1?f[h+1]:void 0,T=g?.status===`RUNNING`,E=g!==void 0&&ce.has(g.status),D=e.transcriptMode,A=te(g===void 0?null:e.taskId,T),j=m(g===void 0?null:e.taskId,D===`raw`,T),M=d(g===void 0?null:e.taskId,T),N=ee(g===void 0?null:e.taskId,T);x(T?1e3:3e4);let P=g===void 0?void 0:v(g),F=h>=0?h+1:void 0,I=A.data??null;(0,O.useEffect)(()=>{e.taskId.length>0&&(c(!0),i([]))},[e.taskId]),(0,O.useEffect)(()=>{if(!s)return;let e=requestAnimationFrame(()=>{let e=o.current;e&&(e.scrollTop=e.scrollHeight)});return()=>cancelAnimationFrame(e)});function L(){let e=o.current;e&&c(we(e))}function R(){let e=o.current;e&&(e.scrollTop=e.scrollHeight,c(!0))}return t.isError?(0,k.jsxs)(`p`,{className:`text-sm text-status-failed`,children:[`Cannot load this run: `,String(t.error)]}):g===void 0&&!t.isPending?(0,k.jsxs)(`div`,{className:`grid gap-3`,children:[(0,k.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No task `,(0,k.jsx)(`span`,{className:`font-mono`,children:e.taskId}),` in this run.`]}),(0,k.jsx)(r,{to:`/runs/$runId`,params:{runId:e.runId},className:`font-mono text-xs text-primary hover:underline`,children:`← back to run`})]}):(0,k.jsxs)(`section`,{className:`flex h-[calc(100dvh-3.5rem-3rem)] min-h-[32rem] flex-col gap-4`,children:[(0,k.jsxs)(`div`,{className:`grid shrink-0 gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[F===void 0?null:(0,k.jsxs)(`span`,{className:`font-mono text-sm text-muted-foreground`,"data-num":!0,children:[`#`,F]}),(0,k.jsx)(`h1`,{className:a(`text-lg font-semibold tracking-tight`,P===void 0&&`font-mono text-base`),children:P??e.taskId}),g===void 0?null:(0,k.jsx)(re,{state:g.status,id:g.taskId}),(0,k.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[F===void 0?null:(0,k.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,"data-num":!0,children:[F,` / `,l.length]}),(0,k.jsx)(Z,{dir:`prev`,runId:e.runId,task:C}),(0,k.jsx)(Z,{dir:`next`,runId:e.runId,task:w})]})]}),g===void 0?(0,k.jsx)(y,{className:`h-12 w-full max-w-xl`}):(0,k.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-1.5 sm:grid-cols-3`,children:[(0,k.jsx)(Q,{label:`sandbox`,value:g.assignedSandboxId??g.lastSandboxId??`—`}),(0,k.jsx)(Q,{label:`attempt`,value:String(g.currentAttemptNumber??g.attemptCount??`—`),num:!0}),(0,k.jsx)(Q,{label:`agent`,value:g.agentId}),(0,k.jsx)(Q,{label:`accepted`,value:S(g.assignmentAcceptedAt),num:!0}),(0,k.jsx)(Te,{heartbeatAt:g.assignmentHeartbeatAt,running:g.status===`RUNNING`}),(0,k.jsx)(Q,{label:`finished`,value:S(g.lastFinishedAt),num:!0})]}),g!==void 0&&g.dependsOn.length>0?(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,k.jsx)(`span`,{className:`console-callout`,children:`depends on`}),g.dependsOn.map(t=>(0,k.jsx)(r,{to:`/runs/$runId/t/$taskId`,params:{runId:e.runId,taskId:t},title:t,children:(0,k.jsxs)(b,{variant:`secondary`,className:`font-mono text-[11px] transition-colors hover:bg-secondary/70`,children:[`#`,u.get(t)??`?`]})},t))]}):null]}),(0,k.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(22rem,0.86fr)]`,children:[(0,k.jsx)(`section`,{className:`min-h-0 overflow-y-auto pr-2`,"aria-label":`Task and workpad`,children:(0,k.jsxs)(`div`,{className:`grid gap-3 pb-4`,children:[(0,k.jsx)(de,{task:g}),(0,k.jsx)(V,{taskId:g===void 0?null:e.taskId,workpad:M.data??null,pending:g===void 0||M.isPending,error:M.isError?String(M.error):null},g?.taskId??e.taskId),(0,k.jsx)(fe,{activity:N.data?.activity??[],pending:N.isPending,error:N.isError?String(N.error):null})]})}),(0,k.jsxs)(`section`,{className:`flex min-h-[28rem] min-w-0 flex-col rounded-md border bg-card/35`,"aria-label":`Agent transcript`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b px-3 py-2`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(`h2`,{className:`console-callout`,children:`Agent transcript`}),T?(0,k.jsx)(b,{variant:`secondary`,className:`font-mono text-[11px]`,children:`live`}):null,I===null?null:(0,k.jsxs)(`span`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:[I.session.lineCount,` lines ·`,` `,Se(I.session.sizeBytes),I.session.threadId?` · thread ${I.session.threadId}`:``]})]}),(0,k.jsxs)(`div`,{className:`ml-auto flex rounded-md border bg-background p-0.5`,children:[(0,k.jsx)(G,{active:D===`parsed`,onClick:()=>e.onTranscriptModeChange(`parsed`),children:`Parsed`}),(0,k.jsx)(G,{active:D===`raw`,onClick:()=>e.onTranscriptModeChange(`raw`),children:`Raw`})]})]}),(0,k.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,k.jsx)(`div`,{ref:o,onScroll:L,className:`h-full overflow-y-auto p-3`,children:D===`raw`?(0,k.jsx)(_e,{raw:j.data??null,pending:j.isPending,error:j.isError?String(j.error):null,running:T,terminal:E,expectsSession:g!==void 0&&K(g)}):(0,k.jsx)(ge,{session:I,error:I===null&&A.isError?String(A.error):null,pending:I===null&&A.isPending,running:T,terminal:E,expectsSession:g!==void 0&&K(g),outbound:n})}),s?null:(0,k.jsxs)(_,{type:`button`,size:`xs`,variant:`secondary`,className:`absolute right-3 bottom-3 shadow-md`,onClick:R,children:[(0,k.jsx)(ie,{className:`size-3`}),`Jump to latest`]})]}),(0,k.jsx)(`div`,{className:`shrink-0 border-t bg-background/95 p-3`,children:(0,k.jsx)(ue,{taskId:g===void 0?null:e.taskId,running:T,supported:g!==void 0,onMessageQueued:e=>{i(t=>[...t,e])},onMessageStatus:(e,t)=>{i(n=>n.map(n=>n.id===e?{...n,status:t}:n))}},g?.taskId??e.taskId)})]})]})]})}function ue(e){let[t,n]=(0,O.useState)(`follow_up`),[r,i]=(0,O.useState)(``),a=h(e.taskId),o=e.supported&&e.running&&e.taskId!==null&&r.trim().length>0&&!a.isPending;async function s(){let n=r.trim();if(!o||n.length===0)return;let s=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;e.onMessageQueued({id:s,mode:t,text:n,status:`sending`}),i(``);try{await a.mutateAsync({mode:t,message:n}),e.onMessageStatus(s,`accepted`)}catch{e.onMessageStatus(s,`failed`),i(n)}}return(0,k.jsxs)(`section`,{className:`grid gap-2 rounded-md border bg-card/35 p-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsxs)(_,{type:`button`,variant:t===`follow_up`?`secondary`:`ghost`,size:`xs`,onClick:()=>n(`follow_up`),children:[(0,k.jsx)(w,{className:`size-3.5`}),`Follow up`]}),(0,k.jsxs)(_,{type:`button`,variant:t===`steer`?`secondary`:`ghost`,size:`xs`,onClick:()=>n(`steer`),children:[(0,k.jsx)(E,{className:`size-3.5`}),`Steer`]})]}),(0,k.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,k.jsx)(`textarea`,{value:r,onChange:e=>i(e.currentTarget.value),placeholder:e.supported?e.running?t===`follow_up`?`Add a follow-up message…`:`Steer the agent…`:`Task is no longer running.`:`No task selected.`,disabled:!e.supported||!e.running,"aria-label":t===`follow_up`?`Follow-up message`:`Steer message`,rows:2,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),s())},className:`min-h-16 flex-1 resize-y rounded-md border bg-background px-3 py-2 text-sm leading-relaxed outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50`}),(0,k.jsx)(_,{type:`button`,size:`icon-sm`,disabled:!o,onClick:()=>void s(),"aria-label":`Send agent message`,title:e.supported?e.running?`Send to running agent`:`Task is not running.`:`No task selected.`,children:(0,k.jsx)(D,{className:`size-4`})})]}),a.isError?(0,k.jsx)(`p`,{className:`text-xs text-destructive`,children:String(a.error)}):null]})}function de(e){if(e.task===void 0)return(0,k.jsx)(y,{className:`h-24 w-full`});let t=ye(e.task),n=ve(e.task),r=xe(e.task.input),i=t.bodyMarkdown;return(0,k.jsxs)(`section`,{className:`rounded-md border bg-card/45 p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`h2`,{className:`console-callout`,children:`Task`}),t.title===void 0?null:(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:t.title})]}),i===void 0?(0,k.jsx)(`p`,{className:`mb-3 rounded-md border border-dashed bg-background/40 p-3 text-sm text-muted-foreground`,children:`No task description was provided for this task.`}):(0,k.jsx)(`div`,{className:`mb-3 rounded-md border bg-background/60 p-3`,children:(0,k.jsx)(U,{markdown:i})}),t.acceptanceCriteria.length>0?(0,k.jsxs)(`div`,{className:`mb-3`,children:[(0,k.jsx)(`h3`,{className:`console-callout mb-1.5`,children:`Acceptance criteria`}),(0,k.jsx)(`ul`,{className:`grid gap-1 text-sm`,children:Ce(t.acceptanceCriteria).map(e=>(0,k.jsxs)(`li`,{className:`flex gap-2`,children:[(0,k.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-muted-foreground/60`}),(0,k.jsx)(`span`,{children:e.text})]},e.key))})]}):null,(0,k.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-2 sm:grid-cols-2`,children:[n===void 0?null:(0,k.jsx)(W,{label:`adapter`,value:n}),e.task.live?.state?.liveStatus===void 0?null:(0,k.jsx)(W,{label:`live state`,value:e.task.live.state.liveStatus}),e.task.live?.latestRoundKey===void 0?null:(0,k.jsx)(W,{label:`latest round`,value:e.task.live.latestRoundKey}),e.task.live?.idleTimeout===void 0?null:(0,k.jsx)(W,{label:`idle timeout`,value:B(e.task)}),t.workspaceKey===void 0?null:(0,k.jsx)(W,{label:`project key`,value:t.workspaceKey}),t.externalSource?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(W,{label:`source`,value:be(t.externalSource)}),(0,k.jsx)(W,{label:`source url`,value:t.externalSource.url??`—`,href:X(t.externalSource.url)})]}):null]}),(0,k.jsx)(z,{task:e.task}),r===void 0?null:(0,k.jsxs)(`details`,{className:`mt-3 rounded-md border bg-background/60`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer px-3 py-2 font-mono text-[11px] uppercase tracking-[0.12em] text-muted-foreground`,children:`Adapter input`}),(0,k.jsx)(`pre`,{className:`max-h-48 overflow-auto border-t px-3 py-2 text-xs whitespace-pre-wrap`,children:r})]})]})}function z(e){let t=e.task.live?.rounds??[];if(t.length===0)return null;let n=[...t].sort((e,t)=>e.sequence-t.sequence);return(0,k.jsxs)(`div`,{className:`mt-3`,children:[(0,k.jsx)(`h3`,{className:`console-callout mb-1.5`,children:`Round history`}),(0,k.jsx)(`ol`,{className:`grid gap-2`,children:n.map(e=>(0,k.jsxs)(`li`,{className:`rounded-md border bg-background/60 p-2`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`#`,e.sequence]}),(0,k.jsx)(`span`,{className:`font-mono text-xs font-medium`,children:e.roundKey}),(0,k.jsx)(b,{variant:`outline`,className:`font-mono text-[10px] uppercase tracking-[0.08em]`,children:e.status}),e.completedAt===void 0?(0,k.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:S(e.promptedAt)}):(0,k.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:S(e.completedAt)})]}),e.summary!==void 0||e.terminalReason!==void 0?(0,k.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.summary,e.terminalReason].filter(e=>!!e).join(` · `)}):null,e.outputs!==void 0&&e.outputs.length>0?(0,k.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.outputs.map(t=>(0,k.jsxs)(`a`,{href:t.href,className:`inline-flex items-center gap-1 rounded-sm border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground transition-colors hover:bg-secondary/60 hover:text-foreground`,title:`${t.kind} output ${t.outputKey}`,children:[t.outputKey,(0,k.jsx)(`span`,{className:`text-[10px] uppercase`,children:t.kind})]},`${e.roundKey}:${t.outputKey}`))}):null]},`${e.sequence}:${e.roundKey}`))})]})}function B(e){let t=e.live?.idleTimeout;if(!t)return`—`;let n=t.graceExpiresAt??t.expiresAt;return[t.action,n?S(n):void 0].filter(e=>!!e).join(` · `)}function V(e){let t=f(e.taskId),[n,r]=(0,O.useState)(!1),[i,a]=(0,O.useState)(``),[o,s]=(0,O.useState)(null),c=e.workpad?.bodyMarkdown??``;(0,O.useEffect)(()=>{n||a(c)},[c,n]);async function d(){if(e.taskId!==null)try{await t.mutateAsync({bodyMarkdown:i,baseVersion:o?.version??e.workpad?.version??0}),r(!1),s(null)}catch{}}let p=e.taskId!==null&&e.workpad!==null&&!e.pending&&e.error===null,m=p&&o!==null&&i!==o.body&&!t.isPending;return(0,k.jsxs)(`section`,{className:`rounded-md border bg-card/45 p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`h2`,{className:`console-callout`,children:`Workpad`}),e.workpad?(0,k.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,"data-num":!0,children:[`v`,e.workpad.version,` · updated`,` `,S(e.workpad.updatedAt)]}):null,(0,k.jsx)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:n?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(_,{type:`button`,size:`xs`,variant:`ghost`,disabled:t.isPending,onClick:()=>{a(c),s(null),r(!1)},children:[(0,k.jsx)(u,{className:`size-3`}),`Cancel`]}),(0,k.jsxs)(_,{type:`button`,size:`xs`,disabled:!m,onClick:()=>void d(),children:[(0,k.jsx)(l,{className:`size-3`}),t.isPending?`Saving`:`Save`]})]}):(0,k.jsxs)(_,{type:`button`,size:`xs`,variant:`outline`,disabled:!p,onClick:()=>{a(c),s({body:c,version:e.workpad?.version??0}),r(!0)},children:[(0,k.jsx)(T,{className:`size-3`}),e.workpad===null?`Write`:`Edit`]})})]}),e.error===null?e.pending?(0,k.jsx)($,{}):n?(0,k.jsx)(`textarea`,{value:i,onChange:e=>a(e.currentTarget.value),rows:10,className:`min-h-56 w-full resize-y rounded-md border bg-background px-3 py-2 font-mono text-sm leading-relaxed outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/40`,placeholder:`Write the task workpad…`}):e.workpad===null?(0,k.jsx)(`p`,{className:`rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive`,children:`Workpad missing for this task.`}):(0,k.jsx)(U,{markdown:e.workpad.bodyMarkdown}):(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:e.error}),t.isError?(0,k.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:he(t.error)}):null]})}function fe(e){return(0,k.jsxs)(`section`,{className:`rounded-md border bg-card/45 p-3`,children:[(0,k.jsx)(`div`,{className:`mb-2 flex items-center gap-2`,children:(0,k.jsx)(`h2`,{className:`console-callout`,children:`Activity`})}),e.error===null?e.pending?(0,k.jsx)($,{}):e.activity.length===0?(0,k.jsx)(`p`,{className:`rounded-md border border-dashed bg-background/40 p-3 text-sm text-muted-foreground`,children:`No task activity yet.`}):(0,k.jsx)(`ol`,{className:`grid gap-2`,children:e.activity.map(e=>(0,k.jsxs)(`li`,{className:`rounded-md border bg-background/50 p-2`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,k.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:S(e.createdAt)}),(0,k.jsx)(`span`,{className:`font-mono text-xs font-medium`,children:pe(e)}),(0,k.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[e.actorKind,e.actorId?` · ${e.actorId}`:``]})]}),H(e)?(0,k.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:H(e)}):null]},e.activityId))}):(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:e.error})]})}function pe(e){switch(e.type){case`workpad.updated`:return`updated workpad`;case`human_input.queued`:return e.data?.mode===`steer`?`queued steer`:`queued follow-up`;case`live_round.prompted`:return`round prompt`;case`live_round.steer_queued`:return`round steer`;case`live_round.completed`:return`round completed`;case`live_round.failed`:return`round failed`;case`live_round.cancelled`:return`round cancelled`;case`live_round.finish_requested`:return`finish requested`;default:return e.type}}function H(e){if(e.type===`workpad.updated`){let t=e.data?.version;return typeof t==`number`?`workpad v${t}`:void 0}if(e.type===`human_input.queued`){let t=e.data?.messagePreview;return typeof t==`string`?t:void 0}if(e.type.startsWith(`live_round.`))return me(e)}function me(e){let t=[],n=e.data?.roundKey;typeof n==`string`&&t.push(n);let r=e.data?.childKey;typeof r==`string`&&t.push(r);let i=e.data?.summary;typeof i==`string`&&t.push(i);let a=e.data?.terminalReason;typeof a==`string`&&t.push(a);let o=e.data?.messagePreview;typeof o==`string`&&t.push(o);let s=e.data?.outputKeys;return Array.isArray(s)&&s.length>0&&t.push(`outputs ${s.join(`, `)}`),t.length>0?t.join(` · `):void 0}function he(e){return e instanceof g&&e.status===409?`Workpad changed since you started editing. Cancel and reopen to review the latest version before saving.`:String(e)}function U(e){let t=e.markdown.replace(/^<!--\s*flakes:task-workpad:v1\s*-->\s*/,``);return(0,k.jsx)(`div`,{className:`space-y-3 text-sm leading-relaxed`,children:(0,k.jsx)(o,{remarkPlugins:[c],components:{h1:({children:e})=>(0,k.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:e}),h2:({children:e})=>(0,k.jsx)(`h2`,{className:`mt-4 border-b pb-1 text-base font-semibold first:mt-0`,children:e}),h3:({children:e})=>(0,k.jsx)(`h3`,{className:`mt-3 text-sm font-semibold`,children:e}),p:({children:e})=>(0,k.jsx)(`p`,{children:e}),ul:({children:e})=>(0,k.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:e}),ol:({children:e})=>(0,k.jsx)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:e}),li:({children:e})=>(0,k.jsx)(`li`,{children:e}),code:({children:e})=>(0,k.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-[0.9em]`,children:e}),pre:({children:e})=>(0,k.jsx)(`pre`,{className:`overflow-auto rounded-md bg-muted p-3 text-xs`,children:e}),a:({children:e,href:t})=>{let n=X(t);return n?(0,k.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`text-primary underline underline-offset-2`,children:e}):e},img:({alt:e})=>(0,k.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground`,children:[`image blocked`,e?`: ${e}`:``]}),blockquote:({children:e})=>(0,k.jsx)(`blockquote`,{className:`border-l-2 pl-3 text-muted-foreground`,children:e})},children:t})})}function W(e){return(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`dt`,{className:`console-callout`,children:e.label}),(0,k.jsx)(`dd`,{className:`truncate font-mono text-xs text-foreground`,children:e.href?(0,k.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`text-primary hover:underline`,children:e.value}):e.value})]})}function ge(e){return e.error===null?e.pending&&e.outbound.length===0?(0,k.jsx)($,{}):e.session===null&&e.terminal&&e.expectsSession?(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:`Pi session missing after task finished.`}):(0,k.jsx)(A,{session:e.session,running:e.running,outbound:e.outbound}):(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:e.error})}function _e(e){return e.error===null?e.pending?(0,k.jsx)($,{}):e.raw===null?e.terminal&&e.expectsSession?(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:`Raw Pi session missing after task finished.`}):(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.running?`Waiting for raw Pi session...`:`No raw Pi session.`}):(0,k.jsx)(`pre`,{className:`min-h-full overflow-auto rounded-md bg-background/70 p-3 font-mono text-[11px] break-words whitespace-pre-wrap text-foreground/80`,children:e.raw}):(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:e.error})}function G(e){return(0,k.jsx)(`button`,{type:`button`,className:a(`rounded px-2 py-1 font-mono text-[11px] transition-colors`,e.active?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),onClick:e.onClick,children:e.children})}function ve(e){return e.target?.adapter}function K(e){return e.target?.adapter===`pi`}function ye(e){let t=e.metadata??{},n=q(t.externalSource);return{title:J(t.title),bodyMarkdown:J(t.bodyMarkdown),acceptanceCriteria:Y(t.acceptanceCriteria),externalSource:n?{kind:J(n.kind),provider:J(n.provider),externalId:J(n.externalId),identifier:J(n.identifier),url:J(n.url)}:void 0,workspaceKey:J(t.workspaceKey)}}function be(e){return[e.provider,e.identifier??e.externalId,e.kind&&!e.provider?e.kind:void 0].filter(Boolean).join(` · `)||`—`}function xe(e){if(e==null)return;let t=q(e),n=t?J(t.prompt):void 0;return n===void 0?JSON.stringify(e,null,2):n}function q(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function J(e){return typeof e==`string`&&e.length>0?e:void 0}function Y(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.length>0):[]}function Se(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function Ce(e){let t=new Map;return e.map(e=>{let n=t.get(e)??0;return t.set(e,n+1),{text:e,key:n===0?e:`${e}#${n+1}`}})}function X(e){if(e)try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.toString():void 0}catch{return}}function we(e){return e.scrollHeight-e.scrollTop-e.clientHeight<72}function Z(e){let t=e.dir===`prev`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(C,{className:`size-3.5`}),` Prev`]}):(0,k.jsxs)(k.Fragment,{children:[`Next `,(0,k.jsx)(s,{className:`size-3.5`})]});return e.task===void 0?(0,k.jsx)(`span`,{className:`flex items-center gap-1 rounded-md border border-transparent px-2 py-1 font-mono text-[11px] uppercase tracking-[0.08em] text-muted-foreground/30`,children:t}):(0,k.jsx)(r,{to:`/runs/$runId/t/$taskId`,params:{runId:e.runId,taskId:e.task.taskId},title:v(e.task)??e.task.taskId,className:`flex items-center gap-1 rounded-md border px-2 py-1 font-mono text-[11px] uppercase tracking-[0.08em] text-muted-foreground transition-colors hover:bg-secondary/60 hover:text-foreground`,children:t})}function Q(e){return(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`dt`,{className:`console-callout`,children:e.label}),(0,k.jsx)(`dd`,{className:`truncate font-mono text-xs text-foreground`,"data-num":e.num?``:void 0,children:e.value})]})}function Te(e){x(1e3);let t=e.heartbeatAt!==void 0&&Date.now()-Date.parse(e.heartbeatAt)>1e4;return(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`dt`,{className:`console-callout`,children:`heartbeat`}),(0,k.jsxs)(`dd`,{className:`flex min-w-0 items-center gap-1.5 font-mono text-xs text-foreground`,children:[e.running&&e.heartbeatAt!==void 0?(0,k.jsxs)(`span`,{className:`relative size-1.5 shrink-0`,children:[(0,k.jsx)(`span`,{className:a(`absolute inset-0 rounded-full`,t?`bg-status-warn`:`bg-status-running`)}),t?null:(0,k.jsx)(`span`,{className:`blip absolute inset-0 rounded-full border border-status-running`},e.heartbeatAt)]}):null,(0,k.jsx)(`span`,{className:a(`truncate`,e.running&&t&&`text-status-warn`),"data-num":!0,children:S(e.heartbeatAt)})]})]})}function $(){return(0,k.jsxs)(`div`,{className:`grid gap-1 rounded-md bg-muted p-3`,children:[(0,k.jsx)(y,{className:`h-3 w-3/4 bg-foreground/10`}),(0,k.jsx)(y,{className:`h-3 w-full bg-foreground/10`}),(0,k.jsx)(y,{className:`h-3 w-5/6 bg-foreground/10`}),(0,k.jsx)(y,{className:`h-3 w-1/2 bg-foreground/10`}),(0,k.jsx)(y,{className:`h-3 w-11/12 bg-foreground/10`})]})}export{le as TranscriptPage};
|
|
1
|
+
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{t as r}from"./link-BsixJinJ.js";import{r as i,t as a}from"./utils-CEE0-YEp.js";import{n as o,r as s,t as c}from"./lib-DtfURcG3.js";import{t as l}from"./save-1uf5fQff.js";import{t as u}from"./x-fKvnmCoQ.js";import{$ as d,J as f,K as p,Q as m,X as ee,Y as h,Z as te,et as g,k as _}from"./main-KBvz0mSQ.js";import{a as v,d as y,f as b,l as x,o as ne,r as S,t as re}from"./bits-Cv0Te4iz.js";var ie=i(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),C=i(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),w=i(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),T=i(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),E=i(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),D=i(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),O=n(t(),1),k=e();function A(e){let t=M(e.outbound??[],e.session);if(e.session===null&&t.length===0)return(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.running?`Waiting for Pi session...`:`No Pi session.`});let n=e.session===null?[]:j(e.session.transcript);return n.length===0&&t.length===0?(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.running?`Waiting for Pi session...`:`Pi session has no transcript messages.`}):(0,k.jsxs)(`div`,{className:`grid gap-2.5`,children:[n.map(e=>e.kind===`message`?(0,k.jsx)(F,{text:e.text},e.key):e.kind===`user`?(0,k.jsx)(P,{text:e.text},e.key):e.kind===`tool`?(0,k.jsx)(L,{name:e.name,args:e.args,output:e.output,status:e.status},e.key):e.kind===`thinking`?(0,k.jsx)(R,{text:e.text},e.key):(0,k.jsx)(ae,{level:e.level,text:e.text},e.key)),t.map(e=>(0,k.jsx)(P,{text:e.text,label:`${e.mode===`steer`?`Steer`:`Follow up`} · ${N(e.status)}`,muted:e.status!==`accepted`},e.id)),e.running?(0,k.jsx)(`span`,{className:`caret-blink inline-block h-3.5 w-2 bg-primary`}):null]})}function j(e){let t=[];for(let n of e)switch(n.kind){case`user_message`:t.push({kind:`user`,key:n.id,text:n.text});break;case`assistant_message`:t.push({kind:`message`,key:n.id,text:n.text});break;case`assistant_thinking`:t.push({kind:`thinking`,key:n.id,text:n.text});break;case`tool`:t.push({kind:`tool`,key:n.id,name:n.name,args:n.argsText??(n.args===void 0?void 0:JSON.stringify(n.args)),output:n.resultText,status:n.status===`unknown`?`running`:n.status});break;case`system_notice`:t.push({kind:`system`,key:n.id,level:n.level,text:n.text});break}return t}function M(e,t){return t===null?e:e.filter(e=>!t.transcript.some(t=>t.kind===`user_message`&&t.text===e.text))}function N(e){switch(e){case`sending`:return`sending`;case`accepted`:return`sent to agent`;case`failed`:return`failed`}}function P(e){return(0,k.jsxs)(`div`,{className:a(`ml-auto max-w-[92%] rounded-md px-3.5 py-2.5 text-sm leading-relaxed`,e.muted?`border bg-card/60 text-foreground`:`bg-primary text-primary-foreground`),children:[e.label===void 0?null:(0,k.jsx)(`div`,{className:a(`mb-1 font-mono text-[10px] uppercase tracking-[0.08em]`,e.muted?`text-muted-foreground`:`text-primary-foreground/70`),children:e.label}),(0,k.jsx)(`pre`,{className:`max-h-[24rem] overflow-auto font-sans break-words whitespace-pre-wrap`,children:e.text})]})}function F(e){return(0,k.jsx)(`div`,{className:`rounded-md border bg-card/40 px-3.5 py-2.5 text-sm leading-relaxed`,children:(0,k.jsx)(`div`,{className:`transcript-md`,children:(0,k.jsx)(o,{remarkPlugins:[c],components:se,children:e.text})})})}var I={running:`bg-status-running`,ok:`bg-status-succeeded`,error:`bg-status-failed`};function L(e){return(0,k.jsxs)(`details`,{className:`group rounded-md border bg-muted/30`,children:[(0,k.jsxs)(`summary`,{className:`flex w-full cursor-pointer list-none items-center gap-2 px-3 py-1.5 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-[3px] focus-visible:ring-ring/40 [&::-webkit-details-marker]:hidden`,children:[(0,k.jsx)(s,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-open:rotate-90`}),(0,k.jsx)(`span`,{className:a(`size-1.5 shrink-0 rounded-full`,I[e.status],e.status===`running`&&`animate-pulse`)}),(0,k.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:`used`}),(0,k.jsx)(`span`,{className:`font-mono text-xs font-medium text-foreground`,children:e.name})]}),e.args===void 0?null:(0,k.jsx)(`pre`,{className:`overflow-x-auto border-t px-3 py-2 font-mono text-[11px] break-all whitespace-pre-wrap text-muted-foreground`,children:e.args}),e.output===void 0?null:(0,k.jsx)(`pre`,{className:`max-h-64 overflow-auto border-t bg-background/40 px-3 py-2 font-mono text-[11px] break-words whitespace-pre-wrap text-foreground/80`,children:e.output})]})}function R(e){return(0,k.jsxs)(`details`,{className:`group rounded-md border border-dashed bg-muted/20`,children:[(0,k.jsxs)(`summary`,{className:`flex w-full cursor-pointer list-none items-center gap-2 px-3 py-1.5 text-left outline-none transition-colors hover:bg-muted/35 focus-visible:ring-[3px] focus-visible:ring-ring/40 [&::-webkit-details-marker]:hidden`,children:[(0,k.jsx)(s,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-open:rotate-90`}),(0,k.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:`thinking`})]}),(0,k.jsx)(`pre`,{className:`max-h-64 overflow-auto border-t px-3 py-2 font-mono text-[11px] break-words whitespace-pre-wrap text-foreground/75`,children:e.text})]})}function ae(e){return(0,k.jsx)(`div`,{className:a(`px-1 font-mono text-[11px]`,e.level===`error`?`text-status-failed`:e.level===`warn`?`text-status-warn`:`text-muted-foreground/70`),children:e.text})}var oe=/^(https?:|mailto:)/i,se={a({href:e,children:t}){return e===void 0||!oe.test(e)?(0,k.jsx)(`span`,{children:t}):(0,k.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:t})},img({alt:e}){return(0,k.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground`,children:[`image blocked`,e?`: ${e}`:``]})}},ce=new Set([`SUCCEEDED`,`FAILED`,`CANCELLED`]);function le(e){let t=p(e.runId),[n,i]=(0,O.useState)([]),o=(0,O.useRef)(null),[s,c]=(0,O.useState)(!0),l=t.data?.tasks??[],u=ne(l),f=[...l].sort((e,t)=>(u.get(e.taskId)??0)-(u.get(t.taskId)??0)),h=f.findIndex(t=>t.taskId===e.taskId),g=h>=0?f[h]:void 0,C=h>0?f[h-1]:void 0,w=h>=0&&h<f.length-1?f[h+1]:void 0,T=g?.status===`RUNNING`,E=g!==void 0&&ce.has(g.status),D=e.transcriptMode,A=te(g===void 0?null:e.taskId,T),j=m(g===void 0?null:e.taskId,D===`raw`,T),M=d(g===void 0?null:e.taskId,T),N=ee(g===void 0?null:e.taskId,T);x(T?1e3:3e4);let P=g===void 0?void 0:v(g),F=h>=0?h+1:void 0,I=A.data??null;(0,O.useEffect)(()=>{e.taskId.length>0&&(c(!0),i([]))},[e.taskId]),(0,O.useEffect)(()=>{if(!s)return;let e=requestAnimationFrame(()=>{let e=o.current;e&&(e.scrollTop=e.scrollHeight)});return()=>cancelAnimationFrame(e)});function L(){let e=o.current;e&&c(we(e))}function R(){let e=o.current;e&&(e.scrollTop=e.scrollHeight,c(!0))}return t.isError?(0,k.jsxs)(`p`,{className:`text-sm text-status-failed`,children:[`Cannot load this run: `,String(t.error)]}):g===void 0&&!t.isPending?(0,k.jsxs)(`div`,{className:`grid gap-3`,children:[(0,k.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No task `,(0,k.jsx)(`span`,{className:`font-mono`,children:e.taskId}),` in this run.`]}),(0,k.jsx)(r,{to:`/runs/$runId`,params:{runId:e.runId},className:`font-mono text-xs text-primary hover:underline`,children:`← back to run`})]}):(0,k.jsxs)(`section`,{className:`flex h-[calc(100dvh-3.5rem-3rem)] min-h-[32rem] flex-col gap-4`,children:[(0,k.jsxs)(`div`,{className:`grid shrink-0 gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[F===void 0?null:(0,k.jsxs)(`span`,{className:`font-mono text-sm text-muted-foreground`,"data-num":!0,children:[`#`,F]}),(0,k.jsx)(`h1`,{className:a(`text-lg font-semibold tracking-tight`,P===void 0&&`font-mono text-base`),children:P??e.taskId}),g===void 0?null:(0,k.jsx)(re,{state:g.status,id:g.taskId}),(0,k.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[F===void 0?null:(0,k.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,"data-num":!0,children:[F,` / `,l.length]}),(0,k.jsx)(Z,{dir:`prev`,runId:e.runId,task:C}),(0,k.jsx)(Z,{dir:`next`,runId:e.runId,task:w})]})]}),g===void 0?(0,k.jsx)(y,{className:`h-12 w-full max-w-xl`}):(0,k.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-1.5 sm:grid-cols-3`,children:[(0,k.jsx)(Q,{label:`sandbox`,value:g.assignedSandboxId??g.lastSandboxId??`—`}),(0,k.jsx)(Q,{label:`attempt`,value:String(g.currentAttemptNumber??g.attemptCount??`—`),num:!0}),(0,k.jsx)(Q,{label:`agent`,value:g.agentId}),(0,k.jsx)(Q,{label:`accepted`,value:S(g.assignmentAcceptedAt),num:!0}),(0,k.jsx)(Te,{heartbeatAt:g.assignmentHeartbeatAt,running:g.status===`RUNNING`}),(0,k.jsx)(Q,{label:`finished`,value:S(g.lastFinishedAt),num:!0})]}),g!==void 0&&g.dependsOn.length>0?(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,k.jsx)(`span`,{className:`console-callout`,children:`depends on`}),g.dependsOn.map(t=>(0,k.jsx)(r,{to:`/runs/$runId/t/$taskId`,params:{runId:e.runId,taskId:t},title:t,children:(0,k.jsxs)(b,{variant:`secondary`,className:`font-mono text-[11px] transition-colors hover:bg-secondary/70`,children:[`#`,u.get(t)??`?`]})},t))]}):null]}),(0,k.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(22rem,0.86fr)]`,children:[(0,k.jsx)(`section`,{className:`min-h-0 overflow-y-auto pr-2`,"aria-label":`Task and workpad`,children:(0,k.jsxs)(`div`,{className:`grid gap-3 pb-4`,children:[(0,k.jsx)(de,{task:g}),(0,k.jsx)(V,{taskId:g===void 0?null:e.taskId,workpad:M.data??null,pending:g===void 0||M.isPending,error:M.isError?String(M.error):null},g?.taskId??e.taskId),(0,k.jsx)(fe,{activity:N.data?.activity??[],pending:N.isPending,error:N.isError?String(N.error):null})]})}),(0,k.jsxs)(`section`,{className:`flex min-h-[28rem] min-w-0 flex-col rounded-md border bg-card/35`,"aria-label":`Agent transcript`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b px-3 py-2`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(`h2`,{className:`console-callout`,children:`Agent transcript`}),T?(0,k.jsx)(b,{variant:`secondary`,className:`font-mono text-[11px]`,children:`live`}):null,I===null?null:(0,k.jsxs)(`span`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:[I.session.lineCount,` lines ·`,` `,Se(I.session.sizeBytes),I.session.threadId?` · thread ${I.session.threadId}`:``]})]}),(0,k.jsxs)(`div`,{className:`ml-auto flex rounded-md border bg-background p-0.5`,children:[(0,k.jsx)(G,{active:D===`parsed`,onClick:()=>e.onTranscriptModeChange(`parsed`),children:`Parsed`}),(0,k.jsx)(G,{active:D===`raw`,onClick:()=>e.onTranscriptModeChange(`raw`),children:`Raw`})]})]}),(0,k.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,k.jsx)(`div`,{ref:o,onScroll:L,className:`h-full overflow-y-auto p-3`,children:D===`raw`?(0,k.jsx)(_e,{raw:j.data??null,pending:j.isPending,error:j.isError?String(j.error):null,running:T,terminal:E,expectsSession:g!==void 0&&K(g)}):(0,k.jsx)(ge,{session:I,error:I===null&&A.isError?String(A.error):null,pending:I===null&&A.isPending,running:T,terminal:E,expectsSession:g!==void 0&&K(g),outbound:n})}),s?null:(0,k.jsxs)(_,{type:`button`,size:`xs`,variant:`secondary`,className:`absolute right-3 bottom-3 shadow-md`,onClick:R,children:[(0,k.jsx)(ie,{className:`size-3`}),`Jump to latest`]})]}),(0,k.jsx)(`div`,{className:`shrink-0 border-t bg-background/95 p-3`,children:(0,k.jsx)(ue,{taskId:g===void 0?null:e.taskId,running:T,supported:g!==void 0,onMessageQueued:e=>{i(t=>[...t,e])},onMessageStatus:(e,t)=>{i(n=>n.map(n=>n.id===e?{...n,status:t}:n))}},g?.taskId??e.taskId)})]})]})]})}function ue(e){let[t,n]=(0,O.useState)(`follow_up`),[r,i]=(0,O.useState)(``),a=h(e.taskId),o=e.supported&&e.running&&e.taskId!==null&&r.trim().length>0&&!a.isPending;async function s(){let n=r.trim();if(!o||n.length===0)return;let s=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;e.onMessageQueued({id:s,mode:t,text:n,status:`sending`}),i(``);try{await a.mutateAsync({mode:t,message:n}),e.onMessageStatus(s,`accepted`)}catch{e.onMessageStatus(s,`failed`),i(n)}}return(0,k.jsxs)(`section`,{className:`grid gap-2 rounded-md border bg-card/35 p-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsxs)(_,{type:`button`,variant:t===`follow_up`?`secondary`:`ghost`,size:`xs`,onClick:()=>n(`follow_up`),children:[(0,k.jsx)(w,{className:`size-3.5`}),`Follow up`]}),(0,k.jsxs)(_,{type:`button`,variant:t===`steer`?`secondary`:`ghost`,size:`xs`,onClick:()=>n(`steer`),children:[(0,k.jsx)(E,{className:`size-3.5`}),`Steer`]})]}),(0,k.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,k.jsx)(`textarea`,{value:r,onChange:e=>i(e.currentTarget.value),placeholder:e.supported?e.running?t===`follow_up`?`Add a follow-up message…`:`Steer the agent…`:`Task is no longer running.`:`No task selected.`,disabled:!e.supported||!e.running,"aria-label":t===`follow_up`?`Follow-up message`:`Steer message`,rows:2,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),s())},className:`min-h-16 flex-1 resize-y rounded-md border bg-background px-3 py-2 text-sm leading-relaxed outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50`}),(0,k.jsx)(_,{type:`button`,size:`icon-sm`,disabled:!o,onClick:()=>void s(),"aria-label":`Send agent message`,title:e.supported?e.running?`Send to running agent`:`Task is not running.`:`No task selected.`,children:(0,k.jsx)(D,{className:`size-4`})})]}),a.isError?(0,k.jsx)(`p`,{className:`text-xs text-destructive`,children:String(a.error)}):null]})}function de(e){if(e.task===void 0)return(0,k.jsx)(y,{className:`h-24 w-full`});let t=ye(e.task),n=ve(e.task),r=xe(e.task.input),i=t.bodyMarkdown;return(0,k.jsxs)(`section`,{className:`rounded-md border bg-card/45 p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`h2`,{className:`console-callout`,children:`Task`}),t.title===void 0?null:(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:t.title})]}),i===void 0?(0,k.jsx)(`p`,{className:`mb-3 rounded-md border border-dashed bg-background/40 p-3 text-sm text-muted-foreground`,children:`No task description was provided for this task.`}):(0,k.jsx)(`div`,{className:`mb-3 rounded-md border bg-background/60 p-3`,children:(0,k.jsx)(U,{markdown:i})}),t.acceptanceCriteria.length>0?(0,k.jsxs)(`div`,{className:`mb-3`,children:[(0,k.jsx)(`h3`,{className:`console-callout mb-1.5`,children:`Acceptance criteria`}),(0,k.jsx)(`ul`,{className:`grid gap-1 text-sm`,children:Ce(t.acceptanceCriteria).map(e=>(0,k.jsxs)(`li`,{className:`flex gap-2`,children:[(0,k.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-muted-foreground/60`}),(0,k.jsx)(`span`,{children:e.text})]},e.key))})]}):null,(0,k.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-2 sm:grid-cols-2`,children:[n===void 0?null:(0,k.jsx)(W,{label:`adapter`,value:n}),e.task.live?.state?.liveStatus===void 0?null:(0,k.jsx)(W,{label:`live state`,value:e.task.live.state.liveStatus}),e.task.live?.latestRoundKey===void 0?null:(0,k.jsx)(W,{label:`latest round`,value:e.task.live.latestRoundKey}),e.task.live?.idleTimeout===void 0?null:(0,k.jsx)(W,{label:`idle timeout`,value:B(e.task)}),t.workspaceKey===void 0?null:(0,k.jsx)(W,{label:`project key`,value:t.workspaceKey}),t.externalSource?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(W,{label:`source`,value:be(t.externalSource)}),(0,k.jsx)(W,{label:`source url`,value:t.externalSource.url??`—`,href:X(t.externalSource.url)})]}):null]}),(0,k.jsx)(z,{task:e.task}),r===void 0?null:(0,k.jsxs)(`details`,{className:`mt-3 rounded-md border bg-background/60`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer px-3 py-2 font-mono text-[11px] uppercase tracking-[0.12em] text-muted-foreground`,children:`Adapter input`}),(0,k.jsx)(`pre`,{className:`max-h-48 overflow-auto border-t px-3 py-2 text-xs whitespace-pre-wrap`,children:r})]})]})}function z(e){let t=e.task.live?.rounds??[];if(t.length===0)return null;let n=[...t].sort((e,t)=>e.sequence-t.sequence);return(0,k.jsxs)(`div`,{className:`mt-3`,children:[(0,k.jsx)(`h3`,{className:`console-callout mb-1.5`,children:`Round history`}),(0,k.jsx)(`ol`,{className:`grid gap-2`,children:n.map(e=>(0,k.jsxs)(`li`,{className:`rounded-md border bg-background/60 p-2`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`#`,e.sequence]}),(0,k.jsx)(`span`,{className:`font-mono text-xs font-medium`,children:e.roundKey}),(0,k.jsx)(b,{variant:`outline`,className:`font-mono text-[10px] uppercase tracking-[0.08em]`,children:e.status}),e.completedAt===void 0?(0,k.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:S(e.promptedAt)}):(0,k.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:S(e.completedAt)})]}),e.summary!==void 0||e.terminalReason!==void 0?(0,k.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.summary,e.terminalReason].filter(e=>!!e).join(` · `)}):null,e.outputs!==void 0&&e.outputs.length>0?(0,k.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.outputs.map(t=>(0,k.jsxs)(`a`,{href:t.href,className:`inline-flex items-center gap-1 rounded-sm border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground transition-colors hover:bg-secondary/60 hover:text-foreground`,title:`${t.kind} output ${t.outputKey}`,children:[t.outputKey,(0,k.jsx)(`span`,{className:`text-[10px] uppercase`,children:t.kind})]},`${e.roundKey}:${t.outputKey}`))}):null]},`${e.sequence}:${e.roundKey}`))})]})}function B(e){let t=e.live?.idleTimeout;if(!t)return`—`;let n=t.graceExpiresAt??t.expiresAt;return[t.action,n?S(n):void 0].filter(e=>!!e).join(` · `)}function V(e){let t=f(e.taskId),[n,r]=(0,O.useState)(!1),[i,a]=(0,O.useState)(``),[o,s]=(0,O.useState)(null),c=e.workpad?.bodyMarkdown??``;(0,O.useEffect)(()=>{n||a(c)},[c,n]);async function d(){if(e.taskId!==null)try{await t.mutateAsync({bodyMarkdown:i,baseVersion:o?.version??e.workpad?.version??0}),r(!1),s(null)}catch{}}let p=e.taskId!==null&&e.workpad!==null&&!e.pending&&e.error===null,m=p&&o!==null&&i!==o.body&&!t.isPending;return(0,k.jsxs)(`section`,{className:`rounded-md border bg-card/45 p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`h2`,{className:`console-callout`,children:`Workpad`}),e.workpad?(0,k.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,"data-num":!0,children:[`v`,e.workpad.version,` · updated`,` `,S(e.workpad.updatedAt)]}):null,(0,k.jsx)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:n?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(_,{type:`button`,size:`xs`,variant:`ghost`,disabled:t.isPending,onClick:()=>{a(c),s(null),r(!1)},children:[(0,k.jsx)(u,{className:`size-3`}),`Cancel`]}),(0,k.jsxs)(_,{type:`button`,size:`xs`,disabled:!m,onClick:()=>void d(),children:[(0,k.jsx)(l,{className:`size-3`}),t.isPending?`Saving`:`Save`]})]}):(0,k.jsxs)(_,{type:`button`,size:`xs`,variant:`outline`,disabled:!p,onClick:()=>{a(c),s({body:c,version:e.workpad?.version??0}),r(!0)},children:[(0,k.jsx)(T,{className:`size-3`}),e.workpad===null?`Write`:`Edit`]})})]}),e.error===null?e.pending?(0,k.jsx)($,{}):n?(0,k.jsx)(`textarea`,{value:i,onChange:e=>a(e.currentTarget.value),rows:10,className:`min-h-56 w-full resize-y rounded-md border bg-background px-3 py-2 font-mono text-sm leading-relaxed outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/40`,placeholder:`Write the task workpad…`}):e.workpad===null?(0,k.jsx)(`p`,{className:`rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive`,children:`Workpad missing for this task.`}):(0,k.jsx)(U,{markdown:e.workpad.bodyMarkdown}):(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:e.error}),t.isError?(0,k.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:he(t.error)}):null]})}function fe(e){return(0,k.jsxs)(`section`,{className:`rounded-md border bg-card/45 p-3`,children:[(0,k.jsx)(`div`,{className:`mb-2 flex items-center gap-2`,children:(0,k.jsx)(`h2`,{className:`console-callout`,children:`Activity`})}),e.error===null?e.pending?(0,k.jsx)($,{}):e.activity.length===0?(0,k.jsx)(`p`,{className:`rounded-md border border-dashed bg-background/40 p-3 text-sm text-muted-foreground`,children:`No task activity yet.`}):(0,k.jsx)(`ol`,{className:`grid gap-2`,children:e.activity.map(e=>(0,k.jsxs)(`li`,{className:`rounded-md border bg-background/50 p-2`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,k.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:S(e.createdAt)}),(0,k.jsx)(`span`,{className:`font-mono text-xs font-medium`,children:pe(e)}),(0,k.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[e.actorKind,e.actorId?` · ${e.actorId}`:``]})]}),H(e)?(0,k.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:H(e)}):null]},e.activityId))}):(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:e.error})]})}function pe(e){switch(e.type){case`workpad.updated`:return`updated workpad`;case`human_input.queued`:return e.data?.mode===`steer`?`queued steer`:`queued follow-up`;case`live_round.prompted`:return`round prompt`;case`live_round.steer_queued`:return`round steer`;case`live_round.completed`:return`round completed`;case`live_round.failed`:return`round failed`;case`live_round.cancelled`:return`round cancelled`;case`live_round.finish_requested`:return`finish requested`;default:return e.type}}function H(e){if(e.type===`workpad.updated`){let t=e.data?.version;return typeof t==`number`?`workpad v${t}`:void 0}if(e.type===`human_input.queued`){let t=e.data?.messagePreview;return typeof t==`string`?t:void 0}if(e.type.startsWith(`live_round.`))return me(e)}function me(e){let t=[],n=e.data?.roundKey;typeof n==`string`&&t.push(n);let r=e.data?.childKey;typeof r==`string`&&t.push(r);let i=e.data?.summary;typeof i==`string`&&t.push(i);let a=e.data?.terminalReason;typeof a==`string`&&t.push(a);let o=e.data?.messagePreview;typeof o==`string`&&t.push(o);let s=e.data?.outputKeys;return Array.isArray(s)&&s.length>0&&t.push(`outputs ${s.join(`, `)}`),t.length>0?t.join(` · `):void 0}function he(e){return e instanceof g&&e.status===409?`Workpad changed since you started editing. Cancel and reopen to review the latest version before saving.`:String(e)}function U(e){let t=e.markdown.replace(/^<!--\s*flakes:task-workpad:v1\s*-->\s*/,``);return(0,k.jsx)(`div`,{className:`space-y-3 text-sm leading-relaxed`,children:(0,k.jsx)(o,{remarkPlugins:[c],components:{h1:({children:e})=>(0,k.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:e}),h2:({children:e})=>(0,k.jsx)(`h2`,{className:`mt-4 border-b pb-1 text-base font-semibold first:mt-0`,children:e}),h3:({children:e})=>(0,k.jsx)(`h3`,{className:`mt-3 text-sm font-semibold`,children:e}),p:({children:e})=>(0,k.jsx)(`p`,{children:e}),ul:({children:e})=>(0,k.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:e}),ol:({children:e})=>(0,k.jsx)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:e}),li:({children:e})=>(0,k.jsx)(`li`,{children:e}),code:({children:e})=>(0,k.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-[0.9em]`,children:e}),pre:({children:e})=>(0,k.jsx)(`pre`,{className:`overflow-auto rounded-md bg-muted p-3 text-xs`,children:e}),a:({children:e,href:t})=>{let n=X(t);return n?(0,k.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`text-primary underline underline-offset-2`,children:e}):e},img:({alt:e})=>(0,k.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground`,children:[`image blocked`,e?`: ${e}`:``]}),blockquote:({children:e})=>(0,k.jsx)(`blockquote`,{className:`border-l-2 pl-3 text-muted-foreground`,children:e})},children:t})})}function W(e){return(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`dt`,{className:`console-callout`,children:e.label}),(0,k.jsx)(`dd`,{className:`truncate font-mono text-xs text-foreground`,children:e.href?(0,k.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`text-primary hover:underline`,children:e.value}):e.value})]})}function ge(e){return e.error===null?e.pending&&e.outbound.length===0?(0,k.jsx)($,{}):e.session===null&&e.terminal&&e.expectsSession?(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:`Pi session missing after task finished.`}):(0,k.jsx)(A,{session:e.session,running:e.running,outbound:e.outbound}):(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:e.error})}function _e(e){return e.error===null?e.pending?(0,k.jsx)($,{}):e.raw===null?e.terminal&&e.expectsSession?(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:`Raw Pi session missing after task finished.`}):(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.running?`Waiting for raw Pi session...`:`No raw Pi session.`}):(0,k.jsx)(`pre`,{className:`min-h-full overflow-auto rounded-md bg-background/70 p-3 font-mono text-[11px] break-words whitespace-pre-wrap text-foreground/80`,children:e.raw}):(0,k.jsx)(`p`,{className:`text-sm text-destructive`,children:e.error})}function G(e){return(0,k.jsx)(`button`,{type:`button`,className:a(`rounded px-2 py-1 font-mono text-[11px] transition-colors`,e.active?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),onClick:e.onClick,children:e.children})}function ve(e){return e.target?.adapter}function K(e){return e.target?.adapter===`pi`}function ye(e){let t=e.metadata??{},n=q(t.externalSource);return{title:J(t.title),bodyMarkdown:J(t.bodyMarkdown),acceptanceCriteria:Y(t.acceptanceCriteria),externalSource:n?{kind:J(n.kind),provider:J(n.provider),externalId:J(n.externalId),identifier:J(n.identifier),url:J(n.url)}:void 0,workspaceKey:J(t.workspaceKey)}}function be(e){return[e.provider,e.identifier??e.externalId,e.kind&&!e.provider?e.kind:void 0].filter(Boolean).join(` · `)||`—`}function xe(e){if(e==null)return;let t=q(e),n=t?J(t.prompt):void 0;return n===void 0?JSON.stringify(e,null,2):n}function q(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function J(e){return typeof e==`string`&&e.length>0?e:void 0}function Y(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.length>0):[]}function Se(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function Ce(e){let t=new Map;return e.map(e=>{let n=t.get(e)??0;return t.set(e,n+1),{text:e,key:n===0?e:`${e}#${n+1}`}})}function X(e){if(e)try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.toString():void 0}catch{return}}function we(e){return e.scrollHeight-e.scrollTop-e.clientHeight<72}function Z(e){let t=e.dir===`prev`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(C,{className:`size-3.5`}),` Prev`]}):(0,k.jsxs)(k.Fragment,{children:[`Next `,(0,k.jsx)(s,{className:`size-3.5`})]});return e.task===void 0?(0,k.jsx)(`span`,{className:`flex items-center gap-1 rounded-md border border-transparent px-2 py-1 font-mono text-[11px] uppercase tracking-[0.08em] text-muted-foreground/30`,children:t}):(0,k.jsx)(r,{to:`/runs/$runId/t/$taskId`,params:{runId:e.runId,taskId:e.task.taskId},title:v(e.task)??e.task.taskId,className:`flex items-center gap-1 rounded-md border px-2 py-1 font-mono text-[11px] uppercase tracking-[0.08em] text-muted-foreground transition-colors hover:bg-secondary/60 hover:text-foreground`,children:t})}function Q(e){return(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`dt`,{className:`console-callout`,children:e.label}),(0,k.jsx)(`dd`,{className:`truncate font-mono text-xs text-foreground`,"data-num":e.num?``:void 0,children:e.value})]})}function Te(e){x(1e3);let t=e.heartbeatAt!==void 0&&Date.now()-Date.parse(e.heartbeatAt)>1e4;return(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`dt`,{className:`console-callout`,children:`heartbeat`}),(0,k.jsxs)(`dd`,{className:`flex min-w-0 items-center gap-1.5 font-mono text-xs text-foreground`,children:[e.running&&e.heartbeatAt!==void 0?(0,k.jsxs)(`span`,{className:`relative size-1.5 shrink-0`,children:[(0,k.jsx)(`span`,{className:a(`absolute inset-0 rounded-full`,t?`bg-status-warn`:`bg-status-running`)}),t?null:(0,k.jsx)(`span`,{className:`blip absolute inset-0 rounded-full border border-status-running`},e.heartbeatAt)]}):null,(0,k.jsx)(`span`,{className:a(`truncate`,e.running&&t&&`text-status-warn`),"data-num":!0,children:S(e.heartbeatAt)})]})]})}function $(){return(0,k.jsxs)(`div`,{className:`grid gap-1 rounded-md bg-muted p-3`,children:[(0,k.jsx)(y,{className:`h-3 w-3/4 bg-foreground/10`}),(0,k.jsx)(y,{className:`h-3 w-full bg-foreground/10`}),(0,k.jsx)(y,{className:`h-3 w-5/6 bg-foreground/10`}),(0,k.jsx)(y,{className:`h-3 w-1/2 bg-foreground/10`}),(0,k.jsx)(y,{className:`h-3 w-11/12 bg-foreground/10`})]})}export{le as TranscriptPage};
|
package/dist/node_modules/@flakes/console/.output/public/assets/{_-DRcA_CG9.js → _-C4ecJpHe.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e}from"./react-DtOYBmep.js";import{t}from"./DocumentationPage-
|
|
1
|
+
import{h as e}from"./react-DtOYBmep.js";import{t}from"./DocumentationPage-DM-ZYPgQ.js";import{n}from"./main-KBvz0mSQ.js";var r=e();function i(){let{path:e}=n.useLoaderData();return(0,r.jsx)(t,{selectedPath:e})}export{i as component};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RunPage-
|
|
2
|
-
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{ct as r,ot as i,r as a,st as o,w as s}from"./main-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RunPage-i03UqHYF.js","assets/react-DtOYBmep.js","assets/main-KBvz0mSQ.js","assets/dist-BtPw3IIV.js","assets/utils-CEE0-YEp.js","assets/link-BsixJinJ.js","assets/react-dom-DrIU40PY.js","assets/matchContext-tJ0VTv5m.js","assets/redirect-BEm0VK76.js","assets/qss-4JXuaDtg.js","assets/file-text-DMdy8OfN.js","assets/lock-D4OhqEPW.js","assets/x-fKvnmCoQ.js","assets/bits-Cv0Te4iz.js","assets/card-DSG3_teC.js","assets/table-DptQuuuq.js","assets/SandboxesLens-BUQQWmH6.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{ct as r,ot as i,r as a,st as o,w as s}from"./main-KBvz0mSQ.js";var c=n(t()),l=e(),u=(0,c.lazy)(()=>s(()=>import(`./RunPage-i03UqHYF.js`).then(e=>({default:e.RunPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])));function d(){let{runId:e}=a.useParams(),{tab:t,view:n}=a.useSearch(),s=i(),c=r();return f(s.pathname)===`/runs/${encodeURIComponent(e)}`?(0,l.jsx)(u,{runId:e,tab:t??`overview`,onTabChange:t=>c({to:`/runs/$runId`,params:{runId:e},search:e=>({...e,tab:t===`overview`?void 0:t}),replace:!0}),view:n??`map`,onViewChange:t=>c({to:`/runs/$runId`,params:{runId:e},search:e=>({...e,view:t===`map`?void 0:t}),replace:!0})}):(0,l.jsx)(o,{})}function f(e){return e===`/`?e:e.replace(/\/$/,``)}export{d as component};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TranscriptPage-
|
|
2
|
-
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{ct as r,t as i,w as a}from"./main-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TranscriptPage-ChoFjiPI.js","assets/react-DtOYBmep.js","assets/main-KBvz0mSQ.js","assets/dist-BtPw3IIV.js","assets/utils-CEE0-YEp.js","assets/link-BsixJinJ.js","assets/react-dom-DrIU40PY.js","assets/matchContext-tJ0VTv5m.js","assets/redirect-BEm0VK76.js","assets/qss-4JXuaDtg.js","assets/lib-DtfURcG3.js","assets/save-1uf5fQff.js","assets/x-fKvnmCoQ.js","assets/bits-Cv0Te4iz.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{ct as r,t as i,w as a}from"./main-KBvz0mSQ.js";var o=n(t()),s=e(),c=(0,o.lazy)(()=>a(()=>import(`./TranscriptPage-ChoFjiPI.js`).then(e=>({default:e.TranscriptPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])));function l(){let{runId:e,taskId:t}=i.useParams(),{transcript:n}=i.useSearch(),a=r();return(0,s.jsx)(c,{runId:e,taskId:t,transcriptMode:n??`parsed`,onTranscriptModeChange:n=>a({to:`/runs/$runId/t/$taskId`,params:{runId:e,taskId:t},search:n===`raw`?{transcript:`raw`}:{},replace:!0})})}export{l as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{D as r,T as i,f as a}from"./main-
|
|
1
|
+
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{D as r,T as i,f as a}from"./main-KBvz0mSQ.js";import{t as o}from"./account-forms-BLo66Mqa.js";import{a as s,i as c,n as l,r as u,t as d}from"./card-DSG3_teC.js";var f=n(t()),p=e();function m(){let{user:e,refreshSession:t}=i(),[n,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(null),[_,v]=(0,f.useState)(null);async function y(e){m(!0),g(null),v(null);let n=await r.updateUser({name:e.name});return m(!1),n.error?(g(a(n.error,`Could not update profile.`)),!1):(await t(),v(`Profile updated.`),!0)}let b=e.name??``,x=e.email??`No email recorded`;return(0,p.jsxs)(`section`,{className:`grid max-w-3xl gap-6`,children:[(0,p.jsxs)(`header`,{className:`grid gap-1`,children:[(0,p.jsx)(`p`,{className:`font-mono text-xs uppercase tracking-[0.14em] text-muted-foreground`,children:`Account`}),(0,p.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Profile`}),(0,p.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Manage the identity shown on your Flakes account.`})]}),(0,p.jsxs)(d,{className:`rounded-md`,children:[(0,p.jsxs)(c,{children:[(0,p.jsx)(s,{children:`Account details`}),(0,p.jsx)(u,{children:`Your email address is managed by the authentication provider.`})]}),(0,p.jsx)(l,{children:(0,p.jsx)(o,{name:b,email:x,pending:n,error:h,success:_,onSubmit:y})})]})]})}export{m as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{n as r,t as i}from"./signin-form-
|
|
1
|
+
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{n as r,t as i}from"./signin-form-Bp22jPob.js";import{t as a}from"./circle-check-B0gtb8OH.js";import{t as o}from"./lock-D4OhqEPW.js";import{t as s}from"./save-1uf5fQff.js";import{t as c}from"./user-DK27uFod.js";import{g as l,h as u,it as d,k as f,rt as p}from"./main-KBvz0mSQ.js";var m=n(t(),1),h=e();function g(e){let t=(0,m.useId)(),[n,r]=(0,m.useState)({name:e.name}),[a,o]=(0,m.useState)({});(0,m.useEffect)(()=>{r({name:e.name})},[e.name]);async function l(t){if(t.preventDefault(),e.pending)return;let r=u(n);if(!r.ok){o(r.errors);return}o({}),await e.onSubmit(r.data)}return(0,h.jsxs)(`form`,{className:`grid gap-4`,onSubmit:l,noValidate:!0,children:[(0,h.jsx)(i,{id:t,icon:c,label:`Name`,type:`text`,autoComplete:`name`,value:n.name,error:a.name,onChange:e=>r({name:e})}),(0,h.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,h.jsx)(`span`,{className:`console-callout`,children:`Email`}),(0,h.jsx)(`div`,{className:`rounded-md border bg-muted/25 px-3 py-2 font-mono text-sm text-muted-foreground`,children:e.email})]}),(0,h.jsx)(v,{error:e.error,success:e.success}),(0,h.jsx)(f,{type:`submit`,disabled:e.pending,className:`w-fit font-mono`,children:e.pending?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(d,{className:`size-4 animate-spin`}),` Saving`]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s,{className:`size-4`}),` Save profile`]})})]})}function _(e){let t=(0,m.useId)(),n=(0,m.useId)(),r=(0,m.useId)(),[a,s]=(0,m.useState)({currentPassword:``,newPassword:``,confirmPassword:``}),[c,u]=(0,m.useState)({});async function g(t){if(t.preventDefault(),e.pending)return;let n=l(a);if(!n.ok){u(n.errors);return}u({}),await e.onSubmit(n.data)&&s({currentPassword:``,newPassword:``,confirmPassword:``})}return(0,h.jsxs)(`form`,{className:`grid gap-4`,onSubmit:g,noValidate:!0,children:[(0,h.jsx)(i,{id:t,icon:o,label:`Current password`,type:`password`,autoComplete:`current-password`,value:a.currentPassword,error:c.currentPassword,onChange:e=>s(t=>({...t,currentPassword:e}))}),(0,h.jsx)(i,{id:n,icon:p,label:`New password`,type:`password`,autoComplete:`new-password`,value:a.newPassword,error:c.newPassword,onChange:e=>s(t=>({...t,newPassword:e}))}),(0,h.jsx)(i,{id:r,icon:p,label:`Confirm password`,type:`password`,autoComplete:`new-password`,value:a.confirmPassword,error:c.confirmPassword,onChange:e=>s(t=>({...t,confirmPassword:e}))}),(0,h.jsx)(v,{error:e.error,success:e.success}),(0,h.jsx)(f,{type:`submit`,disabled:e.pending,className:`w-fit font-mono`,children:e.pending?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(d,{className:`size-4 animate-spin`}),` Updating`]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(p,{className:`size-4`}),` Change password`]})})]})}function v(e){return e.error===null?(0,h.jsx)(`p`,{className:`flex min-h-5 items-start gap-1.5 text-sm text-primary`,children:e.success?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(a,{className:`mt-0.5 size-4 shrink-0`}),(0,h.jsx)(`span`,{children:e.success})]}):null}):(0,h.jsx)(r,{message:e.error})}export{_ as n,g as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e}from"./react-DtOYBmep.js";import{B as t,O as n}from"./main-
|
|
1
|
+
import{h as e}from"./react-DtOYBmep.js";import{B as t,O as n}from"./main-KBvz0mSQ.js";import{a as r,i,n as a,r as o,t as s}from"./card-DSG3_teC.js";var c=e();function l(e){return(0,c.jsxs)(`main`,{className:`relative flex min-h-screen items-center justify-center bg-muted/40 p-4 sm:p-6`,style:{backgroundImage:`radial-gradient(var(--border) 1px, transparent 1px)`,backgroundSize:`24px 24px`},children:[(0,c.jsx)(`div`,{className:`absolute right-4 top-4 sm:right-6 sm:top-6`,children:(0,c.jsx)(n,{})}),(0,c.jsxs)(s,{className:`w-full max-w-sm gap-4 rounded-md py-5 shadow-sm`,children:[(0,c.jsxs)(i,{className:`gap-3 px-5`,children:[(0,c.jsx)(r,{className:`text-base`,children:(0,c.jsx)(t,{})}),(0,c.jsxs)(`div`,{className:`grid gap-1`,children:[(0,c.jsx)(`h1`,{className:`text-xl font-semibold leading-tight tracking-tight`,children:e.title}),(0,c.jsx)(o,{children:e.description})]})]}),(0,c.jsx)(a,{className:`px-5`,children:e.children}),e.footer?(0,c.jsx)(`div`,{className:`border-t px-5 pt-4 text-sm text-muted-foreground`,children:e.footer}):null]})]})}export{l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{t as r}from"./link-BsixJinJ.js";import{r as i,t as a}from"./utils-CEE0-YEp.js";import{t as o}from"./arrow-right-BMW8fJP5.js";import{r as s}from"./signin-form-DWaa_uwj.js";import{t as c}from"./circle-check-B0gtb8OH.js";import{t as ee}from"./otp-verification-Cqa6lopR.js";import{t as l}from"./user-DK27uFod.js";import{D as u,E as d,ct as f,f as p,i as m,it as h,k as g,p as te,rt as _}from"./main-RzjfJZwD.js";import{t as v}from"./auth-layout-INHonQMf.js";var y=i(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),b=i(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),x=n(t(),1);function S(e){return(e??``).trim().replace(/[\s-]+/g,``).toUpperCase()}function C(e){return S(E(e)??e)}function w(e){let t=e??``,n=(t.includes(`user_code=`)?C(t):void 0)??t.toUpperCase(),r=[];for(let e of n){if(r.length>=8)break;if(e===`-`)continue;if(e.trim()===``){r.push(` `);continue}let t=C(e);t.length>0&&r.push(t[0]??` `)}return r.concat(Array(8).fill(` `)).slice(0,8)}function T(e){let t=S(e);return t.length<=4?t:`${t.slice(0,4)}-${t.slice(4)}`}function E(e){let t=e?.trim();if(t?.includes(`user_code=`))try{return new URL(t,`http://console.invalid`).searchParams.get(`user_code`)??void 0}catch{return}}function D(e){let t=S(e);return t.length===0?`/device`:`/device?user_code=${encodeURIComponent(t)}`}async function ne(e,t){let n=S(t);if(n.length===0)return M(n,{title:`Device code missing`,message:`Start login again from the Flakes CLI.`});let r=await e.verify(n);if(r.error)return j(n,r.error);switch(r.data?.status){case`pending`:return{state:`ready`,userCode:n,displayUserCode:T(n)};case`approved`:return k(n);case`denied`:return A(n);default:return M(n,{title:`Device code not found`,message:`Start login again from the Flakes CLI.`})}}async function O(e,t,n){let r=S(n);if(r.length===0)return M(r,{title:`Device code missing`,message:`Start login again from the Flakes CLI.`});let i=t===`approve`?await e.approve(r):await e.deny(r);return i.error?j(r,i.error):t===`approve`?k(r):A(r)}function k(e){return{state:`approved`,userCode:e,displayUserCode:T(e),title:`CLI session authorized`,message:`Open the console to continue.`}}function A(e){return{state:`denied`,userCode:e,displayUserCode:T(e),title:`CLI session denied`,message:`The waiting login request has been rejected.`}}function j(e,t){switch(N(t)){case`expired_token`:return M(e,{title:`Device code expired`,message:`Start login again from the Flakes CLI.`});case`device_code_already_processed`:return M(e,{title:`Device code already used`,message:`This login request has already been completed.`});case`unauthorized`:return M(e,{title:`Sign-in required`,message:`Sign in again before authorizing the CLI.`});case`access_denied`:return M(e,{title:`Device code belongs to another user`,message:`Use the same account that opened the device request.`});default:return M(e,{title:`Device code not found`,message:`Start login again from the Flakes CLI.`})}}function M(e,t){return{state:`invalid`,userCode:e,displayUserCode:T(e),...t}}function N(e){if(typeof e!=`object`||!e)return``;let t=e;for(let e of[`code`,`error`,`status`,`statusText`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n.toLowerCase()}return``}var P=e(),F=[`device-code-slot-1`,`device-code-slot-2`,`device-code-slot-3`,`device-code-slot-4`,`device-code-slot-5`,`device-code-slot-6`,`device-code-slot-7`,`device-code-slot-8`];function I(e){let t=(0,x.useRef)([]),n=(0,x.useRef)(void 0),r=w(e.value);(0,x.useEffect)(()=>{if(!e.error){n.current=void 0;return}if(n.current!==e.errorPulse){n.current=e.errorPulse;for(let e of t.current)e&&(e.classList.remove(`device-code-slot-error`),e.offsetWidth,e.classList.add(`device-code-slot-error`))}},[e.error,e.errorPulse]);function i(n,r){e.onChange(n.slice(0,8).join(``)),r!==void 0&&requestAnimationFrame(()=>{t.current[L(r)]?.focus()})}function a(e,t){let n=C(t.currentTarget.value);if(n.length===0){let t=r.slice();t[e]=` `,i(t);return}let a=r.slice();for(let t=0;t<n.length;t+=1){let r=e+t;if(r>=8)break;a[r]=n[t]??` `}i(a,e+n.length)}function o(e,t){t.preventDefault();let n=C(t.clipboardData.getData(`text`));if(n.length===0)return;let a=r.slice();for(let t=0;t<n.length;t+=1){let r=e+t;if(r>=8)break;a[r]=n[t]??` `}i(a,e+n.length)}function s(e,n){if(n.key===`Backspace`){n.preventDefault();let t=r.slice();if(r[e]!==` `){t[e]=` `,i(t,e);return}e>0&&(t[e-1]=` `,i(t,e-1));return}if(n.key===`Delete`){n.preventDefault();let t=r.slice();t[e]=` `,i(t,e);return}if(n.key===`ArrowLeft`&&e>0){n.preventDefault(),t.current[e-1]?.focus();return}n.key===`ArrowRight`&&e<7&&(n.preventDefault(),t.current[e+1]?.focus())}return(0,P.jsxs)(`fieldset`,{className:`grid gap-2`,"aria-describedby":`${e.id}-error`,children:[(0,P.jsx)(`legend`,{className:`console-callout pb-2`,children:e.label}),(0,P.jsx)(`div`,{className:`flex items-center gap-1.5`,children:F.map((n,i)=>(0,P.jsx)(R,{ref:e=>{t.current[i]=e},id:i===0?e.id:void 0,value:r[i]?.trim()??``,error:e.error!==void 0,index:i,onChange:e=>a(i,e),onPaste:e=>o(i,e),onKeyDown:e=>s(i,e)},n))}),(0,P.jsx)(`p`,{id:`${e.id}-error`,className:`min-h-4 text-xs text-destructive`,children:e.error??``})]})}function L(e){return Math.max(0,Math.min(e,7))}function R(e){return(0,P.jsxs)(P.Fragment,{children:[e.index===4?(0,P.jsx)(`span`,{className:`px-0.5 font-mono text-sm text-muted-foreground`,children:`-`}):null,(0,P.jsx)(`input`,{ref:e.ref,id:e.id,value:e.value,"aria-label":`Device code character ${e.index+1}`,inputMode:`text`,autoComplete:e.index===0?`one-time-code`:`off`,autoCapitalize:`characters`,maxLength:8,onChange:e.onChange,onPaste:e.onPaste,onKeyDown:e.onKeyDown,className:a(`h-11 w-8 rounded-md border bg-background text-center font-mono text-lg font-semibold outline-none transition-colors sm:w-9`,`focus:border-primary focus:ring-[3px] focus:ring-ring/30`,e.error&&`device-code-slot-error focus:border-destructive focus:ring-destructive/20`)})]})}function z(){let{user_code:e}=m.useSearch(),t=f(),n=u.useSession(),i=S(e),a=(0,x.useMemo)(Y,[]),[o,c]=(0,x.useState)(()=>J(i)),[l,h]=(0,x.useState)(()=>T(i)),[g,_]=(0,x.useState)(),[y,b]=(0,x.useState)(0),[w,E]=(0,x.useState)(!1),[k,A]=(0,x.useState)(null),[j,M]=(0,x.useState)(`signin`),[N,F]=(0,x.useState)(``),[I,L]=(0,x.useState)(``),[R,z]=(0,x.useState)(null);(0,x.useEffect)(()=>{h(T(i)),_(void 0),b(0),M(`signin`),A(null)},[i]),(0,x.useEffect)(()=>{if(n.isPending||i.length===0||n.data===null)return;let e=!0;return c(J(i)),ne(a,i).then(t=>{e&&c(t)}),()=>{e=!1}},[a,n.data,n.isPending,i]);function X(e){e.preventDefault();let n=C(l);if(n.length!==8){_(`Enter the 8-character code shown in your terminal.`),b(e=>e+1);return}if(o.state===`invalid`&&n===i){_(o.title),b(e=>e+1);return}_(void 0),t({to:`/device`,search:{user_code:n},replace:!0})}function Z(e){h(e),_(void 0)}async function Q(e){R||(z(e),c(await O(a,e,i)),z(null))}async function re(e){E(!0),A(null),F(e.email),L(e.password);let t=await u.signIn.email({email:e.email,password:e.password});if(t.error){if(te(t.error)){let t=await u.emailOtp.sendVerificationOtp({email:e.email,type:`email-verification`});if(E(!1),t.error){A(p(t.error,`Could not send verification code.`));return}M(`verify`);return}E(!1),A(p(t.error));return}E(!1),window.location.assign(d(D(i)))}async function ie(e){if(E(!0),A(null),(await u.emailOtp.verifyEmail({email:N,otp:e})).error){E(!1),A(`Verification failed: the six-digit code is incorrect.`);return}let t=await u.signIn.email({email:N,password:I});if(E(!1),t.error){A(`Verification succeeded, but failed to sign in: ${p(t.error)}`),M(`signin`);return}window.location.assign(d(D(i)))}if(n.isPending)return(0,P.jsx)(v,{title:`Authorize CLI session`,description:`Flakes is checking your account session.`,children:(0,P.jsx)(K,{displayUserCode:T(i)})});if(i.length===0)return(0,P.jsx)(v,{title:`Authorize CLI session`,description:`Enter the code shown by the Flakes CLI.`,footer:n.data?(0,P.jsx)(U,{userLabel:G(n.data.user)}):(0,P.jsx)(`p`,{children:`Sign in after entering a code to authorize the CLI session.`}),children:(0,P.jsx)(V,{value:l,error:g,errorPulse:y,onChange:Z,onSubmit:X})});let ae=n.data?.user.email??n.data?.user.name??`Signed-in account`;if(n.data===null)return(0,P.jsx)(v,{title:`Authorize CLI session`,description:`Sign in to authorize this CLI login.`,footer:(0,P.jsxs)(`p`,{children:[`Need access?`,` `,(0,P.jsx)(r,{to:`/signup`,search:{redirect:D(i)},className:`text-foreground underline-offset-4 hover:underline`,children:`Create an account`})]}),children:(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsx)(H,{displayUserCode:T(i)}),j===`signin`?(0,P.jsx)(s,{error:k,pending:w,redirectTarget:D(i),onSubmit:re}):(0,P.jsx)(ee,{email:N,error:k,pending:w,onVerify:ie,onBack:()=>{A(null),M(`signin`)}})]})});if(o.state===`invalid`){let e=C(l)===i?o.title:void 0;return(0,P.jsx)(v,{title:`Authorize CLI session`,description:`Enter the code shown by the Flakes CLI.`,footer:(0,P.jsxs)(`p`,{children:[`Wrong account?`,` `,(0,P.jsx)(r,{to:`/signin`,search:{redirect:D(i)},className:`text-foreground underline-offset-4 hover:underline`,children:`Sign in again`})]}),children:(0,P.jsx)(V,{value:l,error:g??e,errorPulse:y,onChange:Z,onSubmit:X})})}let $=B(o);return(0,P.jsx)(v,{title:$.title,description:$.description,footer:(0,P.jsxs)(`p`,{children:[`Wrong account?`,` `,(0,P.jsx)(r,{to:`/signin`,search:{redirect:D(i)},className:`text-foreground underline-offset-4 hover:underline`,children:`Sign in again`})]}),children:(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsx)(H,{displayUserCode:o.displayUserCode}),n.data?(0,P.jsx)(U,{userLabel:ae}):null,o.state===`checking`?(0,P.jsx)(K,{displayUserCode:o.displayUserCode}):o.state===`ready`?(0,P.jsx)(W,{pendingDecision:R,onApprove:()=>Q(`approve`),onDeny:()=>Q(`deny`)}):(0,P.jsx)(q,{view:o})]})})}function B(e){switch(e.state){case`approved`:return{title:`CLI session authorized`,description:`Open the console to continue.`};case`denied`:return{title:`CLI session denied`,description:`This login request was rejected.`};case`invalid`:return{title:`Cannot authorize CLI session`,description:`This device code cannot be authorized.`};default:return{title:`Authorize CLI session`,description:`Review the code before authorizing this CLI login.`}}}function V(e){return(0,P.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e.onSubmit,noValidate:!0,children:[(0,P.jsx)(I,{id:`device-user-code`,label:`Device code`,value:e.value,error:e.error,errorPulse:e.errorPulse,onChange:e.onChange}),(0,P.jsxs)(g,{type:`submit`,className:`font-mono`,children:[(0,P.jsx)(o,{className:`size-4`}),` Continue`]})]})}function H(e){return(0,P.jsxs)(`section`,{className:`rounded-md border bg-background p-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,P.jsx)(`p`,{className:`console-callout`,children:`Device code`}),(0,P.jsx)(b,{className:`size-4 text-muted-foreground`})]}),(0,P.jsx)(`p`,{className:`mt-2 break-all font-mono text-2xl font-semibold tracking-[0.12em] text-foreground`,children:e.displayUserCode})]})}function U(e){return(0,P.jsxs)(`p`,{className:`flex items-center gap-2 rounded-md border bg-background px-3 py-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(l,{className:`size-4 shrink-0`}),(0,P.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Signed in as `,e.userLabel]})]})}function W(e){return(0,P.jsxs)(`div`,{className:`grid gap-3`,children:[(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Authorizing will let this CLI session use your Flakes account.`}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,P.jsxs)(g,{type:`button`,disabled:e.pendingDecision!==null,className:`font-mono`,onClick:e.onApprove,children:[e.pendingDecision===`approve`?(0,P.jsx)(h,{className:`size-4 animate-spin`}):(0,P.jsx)(c,{className:`size-4`}),`Authorize`]}),(0,P.jsxs)(g,{type:`button`,variant:`outline`,disabled:e.pendingDecision!==null,className:`font-mono`,onClick:e.onDeny,children:[e.pendingDecision===`deny`?(0,P.jsx)(h,{className:`size-4 animate-spin`}):(0,P.jsx)(y,{className:`size-4`}),`Deny`]})]})]})}function G(e){return e.email??e.name??`Signed-in account`}function K(e){return(0,P.jsxs)(`p`,{className:`flex min-h-10 items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(h,{className:`size-4 animate-spin`}),(0,P.jsxs)(`span`,{children:[`Checking `,e.displayUserCode?e.displayUserCode:`device code`]})]})}function q(e){let t=e.view.state===`approved`;return(0,P.jsxs)(`section`,{className:a(`grid gap-2 rounded-md border p-4`,t?`border-primary/30 bg-primary/10`:`bg-muted/40`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t?(0,P.jsx)(_,{className:`size-4 text-primary`}):(0,P.jsx)(y,{className:`size-4 text-muted-foreground`}),(0,P.jsx)(`h2`,{className:`text-sm font-medium`,children:e.view.title})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.view.message}),t?(0,P.jsx)(g,{asChild:!0,className:`mt-1 font-mono`,children:(0,P.jsxs)(r,{to:`/runs`,children:[(0,P.jsx)(o,{className:`size-4`}),` Open Console`]})}):null]})}function J(e){return{state:`checking`,userCode:e,displayUserCode:T(e)}}function Y(){return{verify:async e=>{let t=await u.device({query:{user_code:e}});return{...t.data?{data:X(t.data)}:{},...t.error?{error:t.error}:{}}},approve:async e=>Z(await u.device.approve({userCode:e})),deny:async e=>Z(await u.device.deny({userCode:e}))}}function X(e){let t=e.status===`pending`||e.status===`approved`||e.status===`denied`?e.status:void 0;return{...e.user_code?{user_code:e.user_code}:{},...t?{status:t}:{}}}function Z(e){return{...e.data?{data:e.data}:{},...e.error?{error:e.error}:{}}}export{z as component};
|
|
1
|
+
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{t as r}from"./link-BsixJinJ.js";import{r as i,t as a}from"./utils-CEE0-YEp.js";import{t as o}from"./arrow-right-BMW8fJP5.js";import{r as s}from"./signin-form-Bp22jPob.js";import{t as c}from"./circle-check-B0gtb8OH.js";import{t as ee}from"./otp-verification-BSXwS5bo.js";import{t as l}from"./user-DK27uFod.js";import{D as u,E as d,ct as f,f as p,i as m,it as h,k as g,p as te,rt as _}from"./main-KBvz0mSQ.js";import{t as v}from"./auth-layout-DiUSgtaY.js";var y=i(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),b=i(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),x=n(t(),1);function S(e){return(e??``).trim().replace(/[\s-]+/g,``).toUpperCase()}function C(e){return S(E(e)??e)}function w(e){let t=e??``,n=(t.includes(`user_code=`)?C(t):void 0)??t.toUpperCase(),r=[];for(let e of n){if(r.length>=8)break;if(e===`-`)continue;if(e.trim()===``){r.push(` `);continue}let t=C(e);t.length>0&&r.push(t[0]??` `)}return r.concat(Array(8).fill(` `)).slice(0,8)}function T(e){let t=S(e);return t.length<=4?t:`${t.slice(0,4)}-${t.slice(4)}`}function E(e){let t=e?.trim();if(t?.includes(`user_code=`))try{return new URL(t,`http://console.invalid`).searchParams.get(`user_code`)??void 0}catch{return}}function D(e){let t=S(e);return t.length===0?`/device`:`/device?user_code=${encodeURIComponent(t)}`}async function ne(e,t){let n=S(t);if(n.length===0)return M(n,{title:`Device code missing`,message:`Start login again from the Flakes CLI.`});let r=await e.verify(n);if(r.error)return j(n,r.error);switch(r.data?.status){case`pending`:return{state:`ready`,userCode:n,displayUserCode:T(n)};case`approved`:return k(n);case`denied`:return A(n);default:return M(n,{title:`Device code not found`,message:`Start login again from the Flakes CLI.`})}}async function O(e,t,n){let r=S(n);if(r.length===0)return M(r,{title:`Device code missing`,message:`Start login again from the Flakes CLI.`});let i=t===`approve`?await e.approve(r):await e.deny(r);return i.error?j(r,i.error):t===`approve`?k(r):A(r)}function k(e){return{state:`approved`,userCode:e,displayUserCode:T(e),title:`CLI session authorized`,message:`Open the console to continue.`}}function A(e){return{state:`denied`,userCode:e,displayUserCode:T(e),title:`CLI session denied`,message:`The waiting login request has been rejected.`}}function j(e,t){switch(N(t)){case`expired_token`:return M(e,{title:`Device code expired`,message:`Start login again from the Flakes CLI.`});case`device_code_already_processed`:return M(e,{title:`Device code already used`,message:`This login request has already been completed.`});case`unauthorized`:return M(e,{title:`Sign-in required`,message:`Sign in again before authorizing the CLI.`});case`access_denied`:return M(e,{title:`Device code belongs to another user`,message:`Use the same account that opened the device request.`});default:return M(e,{title:`Device code not found`,message:`Start login again from the Flakes CLI.`})}}function M(e,t){return{state:`invalid`,userCode:e,displayUserCode:T(e),...t}}function N(e){if(typeof e!=`object`||!e)return``;let t=e;for(let e of[`code`,`error`,`status`,`statusText`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n.toLowerCase()}return``}var P=e(),F=[`device-code-slot-1`,`device-code-slot-2`,`device-code-slot-3`,`device-code-slot-4`,`device-code-slot-5`,`device-code-slot-6`,`device-code-slot-7`,`device-code-slot-8`];function I(e){let t=(0,x.useRef)([]),n=(0,x.useRef)(void 0),r=w(e.value);(0,x.useEffect)(()=>{if(!e.error){n.current=void 0;return}if(n.current!==e.errorPulse){n.current=e.errorPulse;for(let e of t.current)e&&(e.classList.remove(`device-code-slot-error`),e.offsetWidth,e.classList.add(`device-code-slot-error`))}},[e.error,e.errorPulse]);function i(n,r){e.onChange(n.slice(0,8).join(``)),r!==void 0&&requestAnimationFrame(()=>{t.current[L(r)]?.focus()})}function a(e,t){let n=C(t.currentTarget.value);if(n.length===0){let t=r.slice();t[e]=` `,i(t);return}let a=r.slice();for(let t=0;t<n.length;t+=1){let r=e+t;if(r>=8)break;a[r]=n[t]??` `}i(a,e+n.length)}function o(e,t){t.preventDefault();let n=C(t.clipboardData.getData(`text`));if(n.length===0)return;let a=r.slice();for(let t=0;t<n.length;t+=1){let r=e+t;if(r>=8)break;a[r]=n[t]??` `}i(a,e+n.length)}function s(e,n){if(n.key===`Backspace`){n.preventDefault();let t=r.slice();if(r[e]!==` `){t[e]=` `,i(t,e);return}e>0&&(t[e-1]=` `,i(t,e-1));return}if(n.key===`Delete`){n.preventDefault();let t=r.slice();t[e]=` `,i(t,e);return}if(n.key===`ArrowLeft`&&e>0){n.preventDefault(),t.current[e-1]?.focus();return}n.key===`ArrowRight`&&e<7&&(n.preventDefault(),t.current[e+1]?.focus())}return(0,P.jsxs)(`fieldset`,{className:`grid gap-2`,"aria-describedby":`${e.id}-error`,children:[(0,P.jsx)(`legend`,{className:`console-callout pb-2`,children:e.label}),(0,P.jsx)(`div`,{className:`flex items-center gap-1.5`,children:F.map((n,i)=>(0,P.jsx)(R,{ref:e=>{t.current[i]=e},id:i===0?e.id:void 0,value:r[i]?.trim()??``,error:e.error!==void 0,index:i,onChange:e=>a(i,e),onPaste:e=>o(i,e),onKeyDown:e=>s(i,e)},n))}),(0,P.jsx)(`p`,{id:`${e.id}-error`,className:`min-h-4 text-xs text-destructive`,children:e.error??``})]})}function L(e){return Math.max(0,Math.min(e,7))}function R(e){return(0,P.jsxs)(P.Fragment,{children:[e.index===4?(0,P.jsx)(`span`,{className:`px-0.5 font-mono text-sm text-muted-foreground`,children:`-`}):null,(0,P.jsx)(`input`,{ref:e.ref,id:e.id,value:e.value,"aria-label":`Device code character ${e.index+1}`,inputMode:`text`,autoComplete:e.index===0?`one-time-code`:`off`,autoCapitalize:`characters`,maxLength:8,onChange:e.onChange,onPaste:e.onPaste,onKeyDown:e.onKeyDown,className:a(`h-11 w-8 rounded-md border bg-background text-center font-mono text-lg font-semibold outline-none transition-colors sm:w-9`,`focus:border-primary focus:ring-[3px] focus:ring-ring/30`,e.error&&`device-code-slot-error focus:border-destructive focus:ring-destructive/20`)})]})}function z(){let{user_code:e}=m.useSearch(),t=f(),n=u.useSession(),i=S(e),a=(0,x.useMemo)(Y,[]),[o,c]=(0,x.useState)(()=>J(i)),[l,h]=(0,x.useState)(()=>T(i)),[g,_]=(0,x.useState)(),[y,b]=(0,x.useState)(0),[w,E]=(0,x.useState)(!1),[k,A]=(0,x.useState)(null),[j,M]=(0,x.useState)(`signin`),[N,F]=(0,x.useState)(``),[I,L]=(0,x.useState)(``),[R,z]=(0,x.useState)(null);(0,x.useEffect)(()=>{h(T(i)),_(void 0),b(0),M(`signin`),A(null)},[i]),(0,x.useEffect)(()=>{if(n.isPending||i.length===0||n.data===null)return;let e=!0;return c(J(i)),ne(a,i).then(t=>{e&&c(t)}),()=>{e=!1}},[a,n.data,n.isPending,i]);function X(e){e.preventDefault();let n=C(l);if(n.length!==8){_(`Enter the 8-character code shown in your terminal.`),b(e=>e+1);return}if(o.state===`invalid`&&n===i){_(o.title),b(e=>e+1);return}_(void 0),t({to:`/device`,search:{user_code:n},replace:!0})}function Z(e){h(e),_(void 0)}async function Q(e){R||(z(e),c(await O(a,e,i)),z(null))}async function re(e){E(!0),A(null),F(e.email),L(e.password);let t=await u.signIn.email({email:e.email,password:e.password});if(t.error){if(te(t.error)){let t=await u.emailOtp.sendVerificationOtp({email:e.email,type:`email-verification`});if(E(!1),t.error){A(p(t.error,`Could not send verification code.`));return}M(`verify`);return}E(!1),A(p(t.error));return}E(!1),window.location.assign(d(D(i)))}async function ie(e){if(E(!0),A(null),(await u.emailOtp.verifyEmail({email:N,otp:e})).error){E(!1),A(`Verification failed: the six-digit code is incorrect.`);return}let t=await u.signIn.email({email:N,password:I});if(E(!1),t.error){A(`Verification succeeded, but failed to sign in: ${p(t.error)}`),M(`signin`);return}window.location.assign(d(D(i)))}if(n.isPending)return(0,P.jsx)(v,{title:`Authorize CLI session`,description:`Flakes is checking your account session.`,children:(0,P.jsx)(K,{displayUserCode:T(i)})});if(i.length===0)return(0,P.jsx)(v,{title:`Authorize CLI session`,description:`Enter the code shown by the Flakes CLI.`,footer:n.data?(0,P.jsx)(U,{userLabel:G(n.data.user)}):(0,P.jsx)(`p`,{children:`Sign in after entering a code to authorize the CLI session.`}),children:(0,P.jsx)(V,{value:l,error:g,errorPulse:y,onChange:Z,onSubmit:X})});let ae=n.data?.user.email??n.data?.user.name??`Signed-in account`;if(n.data===null)return(0,P.jsx)(v,{title:`Authorize CLI session`,description:`Sign in to authorize this CLI login.`,footer:(0,P.jsxs)(`p`,{children:[`Need access?`,` `,(0,P.jsx)(r,{to:`/signup`,search:{redirect:D(i)},className:`text-foreground underline-offset-4 hover:underline`,children:`Create an account`})]}),children:(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsx)(H,{displayUserCode:T(i)}),j===`signin`?(0,P.jsx)(s,{error:k,pending:w,redirectTarget:D(i),onSubmit:re}):(0,P.jsx)(ee,{email:N,error:k,pending:w,onVerify:ie,onBack:()=>{A(null),M(`signin`)}})]})});if(o.state===`invalid`){let e=C(l)===i?o.title:void 0;return(0,P.jsx)(v,{title:`Authorize CLI session`,description:`Enter the code shown by the Flakes CLI.`,footer:(0,P.jsxs)(`p`,{children:[`Wrong account?`,` `,(0,P.jsx)(r,{to:`/signin`,search:{redirect:D(i)},className:`text-foreground underline-offset-4 hover:underline`,children:`Sign in again`})]}),children:(0,P.jsx)(V,{value:l,error:g??e,errorPulse:y,onChange:Z,onSubmit:X})})}let $=B(o);return(0,P.jsx)(v,{title:$.title,description:$.description,footer:(0,P.jsxs)(`p`,{children:[`Wrong account?`,` `,(0,P.jsx)(r,{to:`/signin`,search:{redirect:D(i)},className:`text-foreground underline-offset-4 hover:underline`,children:`Sign in again`})]}),children:(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsx)(H,{displayUserCode:o.displayUserCode}),n.data?(0,P.jsx)(U,{userLabel:ae}):null,o.state===`checking`?(0,P.jsx)(K,{displayUserCode:o.displayUserCode}):o.state===`ready`?(0,P.jsx)(W,{pendingDecision:R,onApprove:()=>Q(`approve`),onDeny:()=>Q(`deny`)}):(0,P.jsx)(q,{view:o})]})})}function B(e){switch(e.state){case`approved`:return{title:`CLI session authorized`,description:`Open the console to continue.`};case`denied`:return{title:`CLI session denied`,description:`This login request was rejected.`};case`invalid`:return{title:`Cannot authorize CLI session`,description:`This device code cannot be authorized.`};default:return{title:`Authorize CLI session`,description:`Review the code before authorizing this CLI login.`}}}function V(e){return(0,P.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e.onSubmit,noValidate:!0,children:[(0,P.jsx)(I,{id:`device-user-code`,label:`Device code`,value:e.value,error:e.error,errorPulse:e.errorPulse,onChange:e.onChange}),(0,P.jsxs)(g,{type:`submit`,className:`font-mono`,children:[(0,P.jsx)(o,{className:`size-4`}),` Continue`]})]})}function H(e){return(0,P.jsxs)(`section`,{className:`rounded-md border bg-background p-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,P.jsx)(`p`,{className:`console-callout`,children:`Device code`}),(0,P.jsx)(b,{className:`size-4 text-muted-foreground`})]}),(0,P.jsx)(`p`,{className:`mt-2 break-all font-mono text-2xl font-semibold tracking-[0.12em] text-foreground`,children:e.displayUserCode})]})}function U(e){return(0,P.jsxs)(`p`,{className:`flex items-center gap-2 rounded-md border bg-background px-3 py-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(l,{className:`size-4 shrink-0`}),(0,P.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Signed in as `,e.userLabel]})]})}function W(e){return(0,P.jsxs)(`div`,{className:`grid gap-3`,children:[(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Authorizing will let this CLI session use your Flakes account.`}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,P.jsxs)(g,{type:`button`,disabled:e.pendingDecision!==null,className:`font-mono`,onClick:e.onApprove,children:[e.pendingDecision===`approve`?(0,P.jsx)(h,{className:`size-4 animate-spin`}):(0,P.jsx)(c,{className:`size-4`}),`Authorize`]}),(0,P.jsxs)(g,{type:`button`,variant:`outline`,disabled:e.pendingDecision!==null,className:`font-mono`,onClick:e.onDeny,children:[e.pendingDecision===`deny`?(0,P.jsx)(h,{className:`size-4 animate-spin`}):(0,P.jsx)(y,{className:`size-4`}),`Deny`]})]})]})}function G(e){return e.email??e.name??`Signed-in account`}function K(e){return(0,P.jsxs)(`p`,{className:`flex min-h-10 items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(h,{className:`size-4 animate-spin`}),(0,P.jsxs)(`span`,{children:[`Checking `,e.displayUserCode?e.displayUserCode:`device code`]})]})}function q(e){let t=e.view.state===`approved`;return(0,P.jsxs)(`section`,{className:a(`grid gap-2 rounded-md border p-4`,t?`border-primary/30 bg-primary/10`:`bg-muted/40`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t?(0,P.jsx)(_,{className:`size-4 text-primary`}):(0,P.jsx)(y,{className:`size-4 text-muted-foreground`}),(0,P.jsx)(`h2`,{className:`text-sm font-medium`,children:e.view.title})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.view.message}),t?(0,P.jsx)(g,{asChild:!0,className:`mt-1 font-mono`,children:(0,P.jsxs)(r,{to:`/runs`,children:[(0,P.jsx)(o,{className:`size-4`}),` Open Console`]})}):null]})}function J(e){return{state:`checking`,userCode:e,displayUserCode:T(e)}}function Y(){return{verify:async e=>{let t=await u.device({query:{user_code:e}});return{...t.data?{data:X(t.data)}:{},...t.error?{error:t.error}:{}}},approve:async e=>Z(await u.device.approve({userCode:e})),deny:async e=>Z(await u.device.deny({userCode:e}))}}function X(e){let t=e.status===`pending`||e.status===`approved`||e.status===`denied`?e.status:void 0;return{...e.user_code?{user_code:e.user_code}:{},...t?{status:t}:{}}}function Z(e){return{...e.data?{data:e.data}:{},...e.error?{error:e.error}:{}}}export{z as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e}from"./react-DtOYBmep.js";import{t}from"./DocumentationPage-
|
|
1
|
+
import{h as e}from"./react-DtOYBmep.js";import{t}from"./DocumentationPage-DM-ZYPgQ.js";import{a as n,ot as r,st as i}from"./main-KBvz0mSQ.js";var a=e();function o(){return s(r().pathname)===`/documentation`?(0,a.jsx)(t,{selectedPath:n}):(0,a.jsx)(i,{})}function s(e){return e===`/`?e:e.replace(/\/$/,``)}export{o as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{t as r}from"./link-BsixJinJ.js";import{r as i}from"./utils-CEE0-YEp.js";import{i as a,n as o,t as s}from"./signin-form-
|
|
1
|
+
import{h as e,t,v as n}from"./react-DtOYBmep.js";import{t as r}from"./link-BsixJinJ.js";import{r as i}from"./utils-CEE0-YEp.js";import{i as a,n as o,t as s}from"./signin-form-Bp22jPob.js";import{D as c,f as l,it as u,k as d,u as f,v as p}from"./main-KBvz0mSQ.js";import{t as m}from"./auth-layout-DiUSgtaY.js";var h=i(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),g=n(t(),1),_=e();function v(e){let t=(0,g.useId)(),[n,i]=(0,g.useState)(``),[c,l]=(0,g.useState)();async function f(t){if(t.preventDefault(),e.pending||e.sent)return;let r=p({email:n,password:`placeholder`});if(!r.ok){l(r.errors.email);return}l(void 0),await e.onSubmit(r.data.email)}return e.sent?(0,_.jsxs)(`div`,{className:`grid gap-4`,children:[(0,_.jsx)(`p`,{className:`rounded-md border bg-background p-3 text-sm text-muted-foreground`,children:`If an account exists for that address, a reset link will arrive shortly.`}),(0,_.jsx)(d,{asChild:!0,variant:`outline`,children:(0,_.jsx)(r,{to:`/signin`,search:{redirect:e.redirectTarget},children:`Return to sign in`})})]}):(0,_.jsxs)(`form`,{className:`grid gap-4`,onSubmit:f,noValidate:!0,children:[(0,_.jsx)(s,{id:t,icon:a,label:`Email`,type:`email`,autoComplete:`email`,value:n,error:c,onChange:i}),(0,_.jsx)(o,{message:e.error}),(0,_.jsx)(d,{type:`submit`,disabled:e.pending,className:`font-mono`,children:e.pending?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(u,{className:`size-4 animate-spin`}),` Sending link`]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(h,{className:`size-4`}),` Send reset link`]})})]})}function y(){let{redirect:e}=f.useSearch(),[t,n]=(0,g.useState)(!1),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null);async function u(t){n(!0),s(null);let r=await c.requestPasswordReset({email:t,redirectTo:`/console/reset-password?redirect=${encodeURIComponent(e)}`});if(n(!1),r.error){s(l(r.error,`Could not send reset link.`));return}a(!0)}return(0,_.jsx)(m,{title:`Reset password`,description:`Request a password reset link for your Flakes account.`,footer:(0,_.jsxs)(`p`,{children:[`Remembered it?`,` `,(0,_.jsx)(r,{to:`/signin`,search:{redirect:e},className:`text-foreground underline-offset-4 hover:underline`,children:`Sign in`})]}),children:(0,_.jsx)(v,{error:o,pending:t,sent:i,redirectTarget:e,onSubmit:u})})}export{y as component};
|