2 lines
26 KiB
JavaScript
2 lines
26 KiB
JavaScript
import{c as pe,a as r,j as e,T as Se,R as Ne,W as Ce,L as Ie,S as te,F as Re,d as he,C as ne,A as ue,b as Le,X as Ae,e as ie,h as Te}from"./approval-presentation-QyCkfhWb.js";const Ue=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],Ee=pe("file-diff",Ue);const ze=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Me=pe("wifi-off",ze);class h extends Error{constructor(n,o=0){super(n),this.status=o}status}async function w(a,n){const o=new AbortController,u=setTimeout(()=>o.abort(),a.endsWith("/stop")?75e3:15e3);try{const p=await fetch("/mobile-api"+a,{method:n===void 0?"GET":"POST",credentials:"same-origin",cache:"no-store",signal:o.signal,headers:n===void 0?{}:{"Content-Type":"application/json"},...n===void 0?{}:{body:JSON.stringify(n)}}),x=await p.json();if(!p.ok)throw new h(x.error||"当前手机请求未完成。",p.status);return x}catch(p){throw p instanceof h?p:new h(n===void 0?"连接已断开。请核对 Wi-Fi 与电脑上的手机连接。":"没有收到完整回执,请先刷新并在电脑核对原操作。")}finally{clearTimeout(u)}}async function Pe(a,n=8*1024*1024){const o=await w(a);if(typeof o.text!="string"||o.text.length>n)throw new h("报告超出手机显示范围,请在电脑查看。");return await xe(o.text,o.sha256),o}async function xe(a,n){if(!/^[a-f0-9]{64}$/.test(n))throw new h("原结果缺少可核对的SHA-256。");if(Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(a)))).map(u=>u.toString(16).padStart(2,"0")).join("")!==n)throw new h("结果内容校验失败,请在电脑核对原工件。")}function qe({sessionId:a,observation:n,onError:o}){const[u,p]=r.useState(""),[x,v]=r.useState("");return r.useEffect(()=>{let y=!0,b="";const I=new AbortController;return p(""),v(""),(async()=>{const m=await fetch("/mobile-api/sessions/"+a+"/browser-observations/"+n.id+"/image",{credentials:"same-origin",cache:"no-store",signal:I.signal});if(!m.ok)throw new h("原网页截图读取失败。",m.status);const j=await m.arrayBuffer();if(j.byteLength>6*1024*1024)throw new h("原网页截图超过6MiB范围。");const g=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",j)),B=>B.toString(16).padStart(2,"0")).join("");if(g!==n.screenshotSha256||g!==m.headers.get("X-Content-SHA256"))throw new h("原网页截图SHA-256核对失败。");y&&(b=URL.createObjectURL(new Blob([j],{type:"image/png"})),p(b))})().catch(m=>{y&&(v(m.message),o(m))}),()=>{y=!1,I.abort(),b&&URL.revokeObjectURL(b)}},[a,n.id,n.screenshotSha256]),e.jsxs("section",{className:"mobile-input-image",children:[e.jsx("h2",{children:"电脑网页原观察"}),e.jsx("strong",{children:n.title||"所属网页"}),e.jsxs("p",{children:[u?"SHA-256 已核对":x||"正在核对原截图…"," · ",new Date(n.createdAt).toLocaleString("zh-CN")]}),e.jsx("code",{children:n.url}),u&&e.jsxs("details",{children:[e.jsx("summary",{children:"查看原页面截图"}),e.jsx("img",{src:u,alt:"电脑上所属标签页的原观察"}),e.jsx("code",{children:n.screenshotSha256})]}),e.jsx("p",{className:"mobile-muted",children:"这是原采样结果。新观察和浏览器控制在电脑执行,动作审批沿用原任务权限。"})]})}async function me(a,n,o=!1){const u=new AbortController,p=setTimeout(()=>u.abort(),15e3);try{const x=await fetch("/mobile-api/sessions/"+a+"/input-attachments/"+n.id+"/"+(o?"original":"image"),{credentials:"same-origin",cache:"no-store",signal:u.signal});if(!x.ok){const b=await x.json().catch(()=>({}));throw new h(b.error||"截图读取失败。",x.status)}const v=await x.arrayBuffer();if(v.byteLength>(o?2*1024*1024:768*1024))throw new h("截图超出允许大小。");if(Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",v)),b=>b.toString(16).padStart(2,"0")).join("")!==(o?n.sha256:n.sentSha256))throw new h("截图SHA-256核对失败,请在电脑核对。");return new Blob([v],{type:o?n.mediaType:"image/png"})}finally{clearTimeout(p)}}function Oe({sessionId:a,image:n,onError:o}){const[u,p]=r.useState(""),[x,v]=r.useState(""),[y,b]=r.useState(!1);r.useEffect(()=>{let m=!0,j="";return p(""),v(""),me(a,n).then(g=>{m&&(j=URL.createObjectURL(g),p(j))}).catch(g=>{m&&(v(g.message),o(g))}),()=>{m=!1,j&&URL.revokeObjectURL(j)}},[a,n.id,n.sentSha256]);async function I(){b(!0);try{const m=await me(a,n,!0),j=URL.createObjectURL(m),g=document.createElement("a");g.href=j,g.download=n.name,g.click(),setTimeout(()=>URL.revokeObjectURL(j),1e3)}catch(m){o(m)}finally{b(!1)}}return e.jsxs("section",{className:"mobile-input-image",children:[e.jsx("h2",{children:"本任务截图"}),e.jsx("strong",{children:n.name}),e.jsxs("p",{children:[u?"SHA-256 已核对":x||"正在核对截图…"," · 发送副本 ",n.sentWidth," × ",n.sentHeight]}),u&&e.jsxs("details",{children:[e.jsx("summary",{children:"查看发送给模型的截图"}),e.jsx("img",{src:u,alt:n.name}),e.jsx("code",{children:n.sentSha256})]}),e.jsx("button",{disabled:y||!u,onClick:()=>{I()},children:"核对并下载原图"}),e.jsxs("p",{className:"mobile-muted",children:["原图 ",n.width," × ",n.height,"。手机按现有项目观察权限读取;添加截图与预算续接在电脑操作。"]})]})}const q=a=>({idle:"未开始",waiting:"等待审批",validating:"校验中",queued:"排队中",executing:"执行中",error:"错误",running:"执行中",awaiting_approval:"等待审批",stopping:"正在停止",completed:"已完成",needs_review:"待审查",failed:"失败",interrupted:"已中断",cancelled:"已停止",paused:"已暂停",unknown:"需核对",completed_with_changes:"待审查",passed:"通过",pending:"待处理",applied:"已应用",denied:"已拒绝",approved:"已批准",conflict:"有冲突",unverified:"需核对",stale:"已变化"})[a]??a,X=a=>new Date(a).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function He({initialToken:a}){const[n,o]=r.useState(null),[u,p]=r.useState(a),[x,v]=r.useState("iPhone"),[y,b]=r.useState([]),[I,m]=r.useState([]),[j,g]=r.useState(""),[B,Z]=r.useState(""),[O,_]=r.useState(null),[J,re]=r.useState("progress"),[f,ae]=r.useState(""),[le,T]=r.useState(""),[k,F]=r.useState(!1),[fe,be]=r.useState(""),[oe,K]=r.useState(!!a),[d,R]=r.useState(null),[L,S]=r.useState(null),[ce,Q]=r.useState(""),U=r.useRef(0),E=r.useRef(null),N=r.useRef(""),Y=r.useRef(!1),ee=r.useRef(!1),z=r.useRef(!0),G=r.useRef(0),$=r.useRef(null),V=r.useRef(null),H=r.useCallback(s=>{G.current++,E.current=null,U.current=0,N.current="",o(null),b([]),m([]),_(null),Z(""),S(null),R(null),F(!1),K(!0),T(s)},[]),C=r.useCallback(async()=>{if(Y.current||!z.current||globalThis.document.visibilityState==="hidden")return;Y.current=!0;const s=G.current;try{const t=await w("/me");if(!z.current||s!==G.current)return;const l="workbench-mobile-cursor:"+t.gatewayId+":"+t.device.id;if(!E.current||E.current.device.id!==t.device.id||E.current.gatewayId!==t.gatewayId){let c="";try{c=sessionStorage.getItem(l)??""}catch{}U.current=/^\d+$/.test(c)&&Number.isSafeInteger(Number(c))?Number(c):0}for(let c=0;c<10;c++){const W=await w("/events?after="+U.current+"&limit=200");if(!Number.isSafeInteger(W.nextCursor)||W.nextCursor<U.current||W.events.some((ye,de)=>ye.seq<=(de?W.events[de-1].seq:U.current)))throw new h("原进展顺序无法核对,请在电脑查看。");U.current=W.nextCursor;try{sessionStorage.setItem(l,String(U.current))}catch{}if(!W.hasMore)break}const[D,P,A]=await Promise.all([w("/projects"),w("/sessions"),N.current?w("/sessions/"+N.current):Promise.resolve(null)]);if(!z.current||s!==G.current)return;E.current=t,o(t),b(D),m(P),A&&A.id===N.current&&_(c=>c&&c.id===A.id&&c.revision>A.revision?c:A),F(!0),K(!1),T(""),be(new Date().toISOString())}catch(t){if(!z.current||s!==G.current)return;t instanceof h&&[401,403].includes(t.status)?H(t.message):(F(!1),T(t instanceof Error?t.message:"手机连接未完成。"))}finally{Y.current=!1}},[H]);r.useEffect(()=>{z.current=!0,a||C();const s=setInterval(()=>{E.current&&C()},2500),t=()=>{(E.current||!a)&&C()},l=()=>F(!1);return globalThis.document.addEventListener("visibilitychange",t),window.addEventListener("online",t),window.addEventListener("offline",l),()=>{z.current=!1,clearInterval(s),globalThis.document.removeEventListener("visibilitychange",t),window.removeEventListener("online",t),window.removeEventListener("offline",l)}},[a,C]),r.useEffect(()=>{d&&$.current&&!$.current.open&&$.current.showModal()},[d]),r.useEffect(()=>{L&&V.current&&!V.current.open&&V.current.showModal()},[L]);async function M(s,t){if(!ee.current){ee.current=!0,ae(s),T("");try{await t()}catch(l){l instanceof h&&[401,403].includes(l.status)?H(l.message):(l instanceof h&&(l.status===0||l.status>=500)&&F(!1),T(l instanceof Error?l.message:"手机操作未完成。"))}finally{ee.current=!1,z.current&&ae("")}}}async function ge(s){s.preventDefault(),await M("pair",async()=>{let t=u.trim();if(t.startsWith("https://")){const l=new URL(t);if(l.origin!==location.origin)throw new h("配对链接不属于当前电脑地址,请重新扫码。");t=new URLSearchParams(l.hash.slice(1)).get("pair")??""}await w("/pair",{token:t,name:x}),p(""),K(!1),await C()})}async function we(s){N.current=s,Z(s),_(null),re("progress"),S(null),Q(""),await M("task",async()=>{const t=await w("/sessions/"+s);N.current===s&&_(t)})}async function ve(){if(!d)return;const s=d,t=s.task;await M("operation",async()=>{const l=await w("/sessions/"+t.id+"/"+s.kind,{requestId:s.requestId,taskId:t.taskId,runId:t.runId,revision:t.revision,...s.kind==="approve"?{approvalId:s.approval.id,fingerprint:s.approval.fingerprint,allow:s.allow}:{}});R(null),Q(l.status==="completed"?s.kind==="stop"?"原任务停止操作已返回。":s.allow?"已批准原请求。":"已拒绝原请求。":"原操作结果需在电脑核对;不会自动重放。"),await C()})}async function ke(s){if(!O)return;const t=O.id;await M("document",async()=>{let l="",D=0,P="",A=!0;for(;A;){const c=await w("/sessions/"+t+"/changes/"+s.id+"?offset="+D);if(c.offset!==D||c.nextOffset!==D+c.text.length||P&&c.sha256!==P||c.hasMore&&!c.text.length)throw new h("文件差异已变化,请刷新任务后重试。");if(P=c.sha256,l+=c.text,D=c.nextOffset,A=c.hasMore,l.length>2*1024*1024)throw new h("文件差异超过手机显示范围,请在电脑查看。")}await xe(l,P),N.current===t&&S({title:s.path,text:l,sha256:P})})}const se=s=>y.find(t=>t.id===s)?.name??"原项目",i=O?.id===B?O:null;return e.jsxs("div",{className:"mobile-app",children:[e.jsxs("header",{className:"mobile-header",children:[e.jsx("span",{className:"mobile-mark",children:e.jsx(Se,{size:20})}),e.jsxs("div",{children:[e.jsx("strong",{children:"Agent Workbench"}),e.jsx("span",{children:"手机伴随端 · Windows 执行宿主"})]}),e.jsx("button",{"aria-label":"刷新任务",disabled:!!f,onClick:()=>{C()},children:e.jsx(Ne,{size:19})})]}),n&&e.jsxs("div",{className:"mobile-connection "+(k?"":"disconnected"),children:[k?e.jsx(Ce,{size:14}):e.jsx(Me,{size:14}),e.jsx("span",{children:k?"已同步 · "+X(fe):"连接中断 · 当前内容可能已过期"}),e.jsx("span",{children:n.device.permissions.approve?"可审批":"观察"})]}),le&&e.jsxs("div",{className:"mobile-error",role:"alert",children:[e.jsx("strong",{children:k?"操作未完成":oe?"需要连接":"连接待恢复"}),e.jsx("p",{children:le}),n&&e.jsx("button",{onClick:()=>{C()},disabled:!!f,children:"重新同步"})]}),n?.operations?.some(s=>s.status==="unknown")&&e.jsxs("div",{className:"mobile-unknown",children:[e.jsx("strong",{children:"手机操作回执需要核对"}),e.jsx("p",{children:"有原审批或停止操作没有完整回执,请在电脑核对;手机不会自动重放。"}),n.operations.filter(s=>s.status==="unknown").map(s=>e.jsxs("code",{children:["Task ",s.taskId," · ",s.action==="stop"?"停止":"审批"]},s.requestId))]}),!n&&e.jsxs("main",{className:"mobile-pair-page",children:[e.jsxs("div",{className:"mobile-pair-heading",children:[e.jsx(Ie,{size:32}),e.jsx("h1",{children:"接续电脑上的任务"}),e.jsx("p",{children:"在 Windows 工作台打开「手机连接」,选择项目并生成一次性配对码。"})]}),oe||u?e.jsxs("form",{onSubmit:s=>{ge(s)},children:[e.jsxs("label",{children:["设备名称",e.jsx("input",{value:x,maxLength:60,onChange:s=>v(s.target.value),autoComplete:"off"})]}),e.jsxs("label",{children:["配对码或配对链接",e.jsx("input",{type:"password",value:u,onChange:s=>p(s.target.value),autoComplete:"off",autoCapitalize:"none",spellCheck:!1,placeholder:"扫描电脑上的二维码后自动填写"})]}),e.jsx("button",{className:"mobile-primary",disabled:!!f||!u.trim()||!x.trim(),children:f==="pair"?"正在核对授权…":"连接这台电脑"})]}):e.jsx("p",{role:"status",children:"正在核对当前手机连接…"}),e.jsxs("div",{className:"mobile-pair-help",children:[e.jsx(te,{size:18}),e.jsx("p",{children:"首次使用需要在 iPhone 安装并信任电脑生成的根证书。请按电脑「手机连接」中的指引操作。"})]})]}),n&&!B&&e.jsxs("main",{className:"mobile-task-list",children:[e.jsxs("div",{className:"mobile-page-title",children:[e.jsxs("div",{children:[e.jsx("span",{className:"mobile-eyebrow",children:n.device.name}),e.jsx("h1",{children:"项目任务"})]}),e.jsxs("span",{children:[I.length," 个会话"]})]}),e.jsxs("label",{className:"mobile-project-filter",children:[e.jsx(Re,{size:17}),e.jsxs("select",{"aria-label":"筛选项目",value:j,onChange:s=>g(s.target.value),children:[e.jsx("option",{value:"",children:"全部授权项目"}),y.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]}),!I.length&&e.jsxs("div",{className:"mobile-empty",children:[e.jsx(he,{size:30}),e.jsx("h2",{children:"暂无任务"}),e.jsx("p",{children:"在电脑创建或打开任务,手机会同步该项目的执行进展。"})]}),I.filter(s=>!j||s.projectId===j).map(s=>e.jsxs("button",{className:"mobile-task-row",onClick:()=>{we(s.id)},children:[e.jsxs("div",{children:[e.jsx("span",{className:"mobile-project-name",children:se(s.projectId)}),e.jsx("strong",{children:s.title}),e.jsxs("span",{className:"mobile-row-meta",children:[e.jsx("span",{className:"mobile-state state-"+s.status,children:q(s.status)}),e.jsx("time",{children:X(s.updatedAt)})]})]}),e.jsx(ne,{size:19})]},s.id)),e.jsxs("details",{className:"mobile-device-settings",children:[e.jsx("summary",{children:"设备连接与授权"}),e.jsx("p",{children:y.map(s=>s.name).join("、")}),e.jsxs("p",{children:["观察",n.device.permissions.approve?" · 审批":"",n.device.permissions.stop?" · 停止":""," · ",X(n.device.expiresAt)," 到期"]}),e.jsx("p",{children:"手机显示最近200个未归档会话,完整历史在电脑保留。"}),e.jsx("p",{children:"iPhone Safari 中点「共享 → 添加到主屏幕」可安装伴随端。主屏幕应用如要求连接,请在电脑生成新的配对码。"}),e.jsxs("div",{children:[e.jsx("button",{disabled:!!f||!k,onClick:()=>{M("rotate",async()=>{await w("/rotate",{}),await C(),Q("手机会话已轮换。")})},children:"轮换手机会话"}),e.jsx("button",{disabled:!!f,onClick:()=>{M("logout",async()=>{await w("/logout",{}),H("已断开并撤销这台手机。")})},children:"断开并撤销"})]})]})]}),n&&B&&e.jsxs("main",{className:"mobile-task-detail",children:[e.jsxs("button",{className:"mobile-back",onClick:()=>{N.current="",Z(""),_(null),S(null)},children:[e.jsx(ue,{size:18}),"项目任务"]}),i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mobile-task-title",children:[e.jsx("span",{className:"mobile-eyebrow",children:se(i.projectId)}),e.jsx("h1",{children:i.title}),e.jsxs("div",{children:[e.jsx("span",{className:"mobile-state state-"+i.status,children:q(i.status)}),e.jsxs("span",{children:["修订 ",i.revision]})]}),e.jsxs("details",{className:"mobile-goal",children:[e.jsx("summary",{children:"完整任务目标"}),e.jsx("p",{children:i.task?.goal??"此会话尚未创建执行任务。"})]}),e.jsxs("details",{children:[e.jsx("summary",{children:"原任务与运行"}),e.jsxs("code",{children:["Task ",i.taskId??"未开始",e.jsx("br",{}),"Run ",i.runId??"未开始"]})]})]}),ce&&e.jsx("p",{className:"mobile-receipt",role:"status",children:ce}),i.inputAttachments?.map(s=>e.jsx(Oe,{sessionId:i.id,image:s,onError:t=>{t instanceof h&&[401,403].includes(t.status)?H(t.message):T(t instanceof Error?t.message:"截图读取失败。")}},s.id)),i.budgetPause&&e.jsxs("aside",{className:"mobile-unknown",children:[e.jsx("strong",{children:"原任务因预算暂停"}),e.jsxs("p",{children:["必需输入 ",i.budgetPause.requiredInputTokens?.toLocaleString()??"旧记录未分解",";可用输入 ",i.budgetPause.inputBudget?.toLocaleString()??"未记录"," tokens。请在电脑核对预算并预览续接,原工具结果保留。"]})]}),!!i.progress.unknown.length&&e.jsxs("div",{className:"mobile-unknown",children:[e.jsxs("strong",{children:[i.progress.unknown.length," 项工具结果需要核对"]}),e.jsx("p",{children:"请在电脑核对原输入和实际结果。刷新、重连和手机审批均不会自动重新执行。"}),i.progress.unknown.map(s=>e.jsxs("code",{children:[s.tool," · ",q(s.state)]},s.id))]}),i.browserObservations?.slice(-1).map(s=>e.jsx(qe,{sessionId:i.id,observation:s,onError:t=>{t instanceof h&&[401,403].includes(t.status)?H(t.message):T(t instanceof Error?t.message:"原网页截图读取失败。")}},s.id)),!!i.approvals.length&&e.jsxs("section",{className:"mobile-approvals",children:[e.jsxs("h2",{children:[e.jsx(te,{size:18}),"等待你的确认"]}),i.approvals.map(s=>e.jsxs("article",{children:[e.jsx("span",{children:s.shell}),e.jsx("pre",{children:s.command}),e.jsx("p",{children:s.reason}),n.device.permissions.approve?s.actionable?e.jsxs("div",{className:"mobile-action-pair",children:[e.jsx("button",{disabled:!k||!!f,onClick:()=>R({requestId:crypto.randomUUID(),kind:"approve",task:i,approval:s,allow:!1}),children:"拒绝"}),e.jsx("button",{className:"mobile-primary",disabled:!k||!!f,onClick:()=>R({requestId:crypto.randomUUID(),kind:"approve",task:i,approval:s,allow:!0}),children:"核对并批准"})]}):e.jsx("p",{className:"mobile-muted",children:"原审批已失效,请在电脑核对。"}):e.jsx("p",{className:"mobile-muted",children:"此设备仅可观察,请在电脑审批。"})]},s.id))]}),!!i.fileResults?.length&&e.jsxs("section",{className:"mobile-file-results","aria-label":"当前文件成果",children:[e.jsx("h2",{children:"当前文件成果"}),i.fileResults.map(s=>e.jsxs("article",{children:[e.jsx("strong",{children:s.verification==="current"?"当前文件已核对":"文件或要求已变化,请在电脑重新核对"}),e.jsxs("p",{children:["Task ",s.taskId.slice(0,8)," · Run ",s.runId.slice(0,8)]}),s.files.map(t=>e.jsxs("p",{children:[e.jsx("strong",{children:t.path}),e.jsx("br",{}),e.jsxs("code",{children:["SHA-256 ",t.sha256]}),t.origin&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),"来源 Task ",t.origin.taskId.slice(0,8)," · Run ",t.origin.runId.slice(0,8),e.jsx("br",{}),e.jsxs("code",{children:["原 SHA-256 ",t.origin.sha256]})]})]},t.path)),e.jsx("p",{children:s.reason}),e.jsxs("details",{children:[e.jsx("summary",{children:"原成果凭据 SHA-256"}),e.jsx("code",{children:s.contractSha256})]})]},s.id)),e.jsx("p",{className:"mobile-muted",children:"已有成果与新增修改分开记录;测试、差异和Git结果见各自原记录。"})]}),e.jsx("nav",{className:"mobile-tabs","aria-label":"任务内容",children:[["progress","执行进展"],["changes","文件差异"],["checks","检查与报告"]].map(([s,t])=>e.jsxs("button",{"aria-current":J===s?"page":void 0,onClick:()=>{re(s),S(null)},children:[t,s==="changes"&&!!i.changes.length&&e.jsx("span",{children:i.changes.length})]},s))}),J==="progress"&&e.jsxs("section",{className:"mobile-progress",children:[e.jsxs("div",{className:"mobile-section-heading",children:[e.jsx("h2",{children:"原执行记录"}),e.jsxs("span",{children:[i.progress.completed," / ",i.progress.total," 工具完成"]})]}),e.jsx("ol",{children:i.events.map(s=>e.jsxs("li",{children:[e.jsxs("div",{children:[e.jsx("strong",{children:s.label||"执行事件"}),e.jsx("span",{className:"mobile-state state-"+s.phase,children:q(s.phase)})]}),s.stream&&s.stream.status!=="completed"&&e.jsxs("div",{className:"mobile-stream",children:[e.jsx("strong",{children:s.stream.status==="receiving"?"正在接收模型输出":"模型输出未完成"}),e.jsxs("span",{children:[s.stream.textCharacters??0," 字符 · 片段不执行工具"]}),s.stream.textPreview&&e.jsx("pre",{children:s.stream.textPreview})]}),s.output&&e.jsxs("details",{children:[e.jsxs("summary",{children:["查看原输出片段",s.exitCode!==void 0?" · 退出码 "+s.exitCode:""]}),e.jsx("pre",{children:s.output})]})]},s.id))}),!i.events.length&&e.jsx("p",{className:"mobile-muted",children:"尚无工具执行记录。"}),i.messages.map(s=>e.jsxs("article",{className:"mobile-message",children:[e.jsxs("span",{children:[s.role==="assistant"?"代理回复":"系统记录"," · ",X(s.createdAt)]}),e.jsx("p",{children:s.content})]},s.id)),e.jsx("p",{className:"mobile-muted",children:"手机显示最近60条执行记录和8条回复;完整记录保留在电脑原会话。"})]}),J==="changes"&&e.jsxs("section",{className:"mobile-changes",children:[e.jsxs("div",{className:"mobile-section-heading",children:[e.jsx("h2",{children:"当前任务的改动"}),e.jsxs("span",{children:[i.changes.length," 个文件"]})]}),!i.changes.length&&e.jsx("p",{className:"mobile-muted",children:"尚未提出文件改动。"}),i.changes.map(s=>e.jsxs("button",{className:"mobile-file-row",disabled:!!f||!k,onClick:()=>{ke(s)},children:[e.jsx(Ee,{size:19}),e.jsxs("div",{children:[e.jsx("strong",{children:s.path}),e.jsxs("span",{children:[q(s.status)," · ",e.jsxs("b",{children:["+",s.additions]})," / −",s.deletions]})]}),e.jsx(ne,{size:17})]},s.id)),e.jsx("p",{className:"mobile-muted",children:"手机可查看原差异;应用、恢复和 Git 提交在电脑审查。"})]}),J==="checks"&&e.jsxs("section",{className:"mobile-checks",children:[e.jsx("h2",{children:"工程检查"}),!i.checks.length&&e.jsx("p",{className:"mobile-muted",children:"尚无工程检查结果。"}),i.checks.map(s=>e.jsxs("article",{children:[e.jsxs("div",{className:"mobile-section-heading",children:[e.jsxs("strong",{children:["检查 ",s.id.slice(0,8)]}),e.jsx("span",{className:"mobile-state state-"+s.status,children:q(s.status)})]}),e.jsx("p",{children:s.summary}),s.results.map((t,l)=>e.jsxs("p",{className:"mobile-check-result",children:[e.jsx("span",{children:t.name}),e.jsxs("span",{children:[q(t.status),t.exitCode!==void 0?" · "+t.exitCode:"",t.tests?" · "+t.tests.passed+"/"+t.tests.total+" 项测试":""]})]},l))]},s.id)),e.jsx("h2",{children:"原交付报告"}),!i.reports.length&&e.jsx("p",{className:"mobile-muted",children:"尚未生成交付报告。"}),i.reports.map(s=>e.jsxs("button",{className:"mobile-file-row",disabled:!!f||!k,onClick:()=>{M("document",async()=>{const t=await Pe("/sessions/"+i.id+"/reports/"+s.id);N.current===i.id&&S({title:s.kind==="delivery-report-markdown"?"交付报告":"交付报告 JSON",...t})})},children:[e.jsx(he,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:s.kind==="delivery-report-markdown"?"交付报告":"交付报告 JSON"}),e.jsxs("span",{children:[s.bytes.toLocaleString()," bytes · 校验后显示"]})]}),e.jsx(ne,{size:17})]},s.id))]}),i.task&&e.jsxs("div",{className:"mobile-budget",children:[e.jsx("span",{children:"任务累计用量"}),e.jsxs("strong",{children:[i.task.usage.totalTokens.toLocaleString()," tokens / ",i.task.budget.maxTokens.toLocaleString()]}),!!i.task.usage.unknownRequests&&e.jsxs("p",{children:[i.task.usage.unknownRequests," 次用量未知,另按 ",i.task.usage.estimatedUnknownTokens.toLocaleString()," tokens 估算;不计为已确认用量。"]})]}),["running","awaiting_approval","stopping"].includes(i.status)&&e.jsxs("div",{className:"mobile-stop",children:[e.jsx("span",{children:n.device.permissions.stop?"停止仍由电脑等待所属工具退出":"此设备没有停止权限"}),e.jsxs("button",{disabled:!n.device.permissions.stop||!k||!!f||i.status==="stopping",onClick:()=>R({requestId:crypto.randomUUID(),kind:"stop",task:i}),children:[e.jsx(Le,{size:14}),"停止原任务"]})]})]}):e.jsx("div",{className:"mobile-empty",role:"status",children:"正在读取原任务…"})]}),L&&e.jsxs("dialog",{ref:V,className:"mobile-document","aria-label":L.title,onCancel:()=>S(null),children:[e.jsxs("header",{children:[e.jsx("button",{"aria-label":"关闭文档",onClick:()=>S(null),children:e.jsx(ue,{size:20})}),e.jsx("strong",{children:L.title})]}),e.jsxs("p",{children:[e.jsx(te,{size:14}),"SHA-256 已核对",L.redacted?" · 已脱敏":""]}),e.jsx("code",{children:L.sha256}),e.jsx("pre",{children:L.text}),e.jsx("button",{onClick:()=>S(null),children:"返回任务"})]}),d&&e.jsxs("dialog",{ref:$,className:"mobile-confirm",onCancel:()=>R(null),children:[e.jsx("button",{className:"mobile-confirm-close","aria-label":"关闭确认",onClick:()=>R(null),disabled:!!f,children:e.jsx(Ae,{size:20})}),e.jsx("h2",{children:d.kind==="stop"?"停止这个原任务":(d.allow?"批准原":"拒绝原")+ie(d.approval).subject}),e.jsxs("p",{children:[se(d.task.projectId)," · ",d.task.title]}),d.approval&&e.jsx("pre",{children:d.approval.command}),e.jsxs("code",{children:["Task ",d.task.taskId,e.jsx("br",{}),"Run ",d.task.runId,e.jsx("br",{}),"修订 ",d.task.revision]}),d.task.revision!==O?.revision&&e.jsx("p",{role:"alert",children:"任务修订已变化,请关闭并重新核对。"}),e.jsx("p",{children:d.kind==="stop"?"电脑将停止此运行,并保留已经完成的工具结果。":d.allow?ie(d.approval).scope:ie(d.approval).denied}),e.jsxs("div",{className:"mobile-action-pair",children:[e.jsx("button",{disabled:!!f,onClick:()=>R(null),children:"返回核对"}),e.jsx("button",{className:d.kind==="stop"?"mobile-danger":"mobile-primary",disabled:!!f||!k||d.task.revision!==O?.revision,onClick:()=>{ve()},children:f==="operation"?"等待原回执…":"确认"})]})]})]})}const je=new URLSearchParams(location.hash.slice(1)),De=je.get("pair")??"";je.has("pair")&&history.replaceState(null,"",location.pathname);Te.createRoot(document.getElementById("mobile-root")).render(e.jsx(r.StrictMode,{children:e.jsx(He,{initialToken:De})}));"serviceWorker"in navigator&&isSecureContext&&navigator.serviceWorker.register("/mobile-sw.js",{scope:"/"}).catch(()=>{});
|