nx-kv 0.7.0 → 0.8.0

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.
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,l as r,o as i,s as a,t as o}from"./index-BC4hXOgL.js";import{t as s}from"./CliHints-BcGuVv3q.js";var c=r(),l=a();function u(){let{boot:r,refreshBoot:a}=i(),u=e(),d=n(),[f,p]=(0,c.useState)(r?.email||``),[m,h]=(0,c.useState)(``),[g,_]=(0,c.useState)(!1),v=()=>d(async()=>{if(!f.trim()){u(`请填邮箱`);return}if(!m){u(`请填密码`);return}_(!0);try{let e=await t(`/api/auth/login`,{method:`POST`,body:{email:f.trim(),password:m}});h(``),u(`已登录: ${e.email}`),await a()}finally{_(!1)}});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`card`,children:[(0,l.jsxs)(`div`,{className:`colhead`,children:[(0,l.jsx)(`h3`,{children:`登录态`}),(0,l.jsx)(`span`,{className:r?.loggedIn?`tag strong`:`tag bad`,children:r?.loggedIn?`已登录`:`未登录`})]}),(0,l.jsxs)(`div`,{className:`settings`,children:[(0,l.jsx)(`dt`,{children:`账号`}),(0,l.jsx)(`dd`,{children:r?.email||(0,l.jsx)(`span`,{className:`muted`,children:`(未登录)`})}),(0,l.jsx)(`dt`,{children:`userId`}),(0,l.jsx)(`dd`,{children:r?.userId||`-`}),(0,l.jsx)(`dt`,{children:`后端`}),(0,l.jsx)(`dd`,{className:`mono`,children:(0,l.jsx)(o,{text:r?.baseUrl,children:r?.baseUrl})}),(0,l.jsx)(`dt`,{children:`本机配置`}),(0,l.jsx)(`dd`,{className:`mono`,children:(0,l.jsx)(o,{text:r?.configPath,children:r?.configPath})})]})]}),(0,l.jsxs)(`div`,{className:`card`,children:[(0,l.jsx)(`div`,{className:`colhead`,children:(0,l.jsx)(`h3`,{children:r?.loggedIn?`切换账号`:`登录`})}),(0,l.jsxs)(`div`,{className:`row-inline`,style:{padding:12},children:[(0,l.jsx)(`input`,{placeholder:`邮箱`,size:`24`,spellCheck:`false`,value:f,onChange:e=>p(e.target.value)}),(0,l.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v()}}),(0,l.jsx)(`button`,{className:`btn`,onClick:v,disabled:g,children:g?`登录中…`:`登录`}),r?.loggedIn?(0,l.jsx)(`button`,{className:`btn ghost danger`,onClick:()=>d(async()=>{await t(`/api/auth/logout`,{method:`POST`}),u(`已登出`),await a()}),children:`登出`}):null]}),(0,l.jsxs)(`div`,{className:`muted`,style:{padding:`0 12px 12px`,fontSize:12},children:[`密码只用于本次请求,不写入本机配置;配置里只保存 token。 也可以用 CLI:`,(0,l.jsx)(`code`,{children:`nx-kv auth login <email>`}),`(会交互式隐藏输入密码)。`]})]}),(0,l.jsx)(s,{module:`auth`})]})}export{u as default};
1
+ import{a as e,c as t,i as n,l as r,o as i,s as a,t as o}from"./index-g03vbcKX.js";import{t as s}from"./CliHints-T9OvbUA5.js";var c=r(),l=a();function u(){let{boot:r,refreshBoot:a}=i(),u=e(),d=n(),[f,p]=(0,c.useState)(r?.email||``),[m,h]=(0,c.useState)(``),[g,_]=(0,c.useState)(!1),v=()=>d(async()=>{if(!f.trim()){u(`请填邮箱`);return}if(!m){u(`请填密码`);return}_(!0);try{let e=await t(`/api/auth/login`,{method:`POST`,body:{email:f.trim(),password:m}});h(``),u(`已登录: ${e.email}`),await a()}finally{_(!1)}});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`card`,children:[(0,l.jsxs)(`div`,{className:`colhead`,children:[(0,l.jsx)(`h3`,{children:`登录态`}),(0,l.jsx)(`span`,{className:r?.loggedIn?`tag strong`:`tag bad`,children:r?.loggedIn?`已登录`:`未登录`})]}),(0,l.jsxs)(`div`,{className:`settings`,children:[(0,l.jsx)(`dt`,{children:`账号`}),(0,l.jsx)(`dd`,{children:r?.email||(0,l.jsx)(`span`,{className:`muted`,children:`(未登录)`})}),(0,l.jsx)(`dt`,{children:`userId`}),(0,l.jsx)(`dd`,{children:r?.userId||`-`}),(0,l.jsx)(`dt`,{children:`后端`}),(0,l.jsx)(`dd`,{className:`mono`,children:(0,l.jsx)(o,{text:r?.baseUrl,children:r?.baseUrl})}),(0,l.jsx)(`dt`,{children:`本机配置`}),(0,l.jsx)(`dd`,{className:`mono`,children:(0,l.jsx)(o,{text:r?.configPath,children:r?.configPath})})]})]}),(0,l.jsxs)(`div`,{className:`card`,children:[(0,l.jsx)(`div`,{className:`colhead`,children:(0,l.jsx)(`h3`,{children:r?.loggedIn?`切换账号`:`登录`})}),(0,l.jsxs)(`div`,{className:`row-inline`,style:{padding:12},children:[(0,l.jsx)(`input`,{placeholder:`邮箱`,size:`24`,spellCheck:`false`,value:f,onChange:e=>p(e.target.value)}),(0,l.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v()}}),(0,l.jsx)(`button`,{className:`btn`,onClick:v,disabled:g,children:g?`登录中…`:`登录`}),r?.loggedIn?(0,l.jsx)(`button`,{className:`btn ghost danger`,onClick:()=>d(async()=>{await t(`/api/auth/logout`,{method:`POST`}),u(`已登出`),await a()}),children:`登出`}):null]}),(0,l.jsxs)(`div`,{className:`muted`,style:{padding:`0 12px 12px`,fontSize:12},children:[`密码只用于本次请求,不写入本机配置;配置里只保存 token。 也可以用 CLI:`,(0,l.jsx)(`code`,{children:`nx-kv auth login <email>`}),`(会交互式隐藏输入密码)。`]})]}),(0,l.jsx)(s,{module:`auth`})]})}export{u as default};
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./index-BC4hXOgL.js";import{t as l}from"./CliHints-BcGuVv3q.js";var u=r(),d=s(),f=[[`open`,`待办`],[`done`,`已完成`],[`freeze`,`冻结`]],p=e=>e?String(e).slice(0,16).replace(`T`,` `):``,m=15,h=(e,t)=>`${e}:${t.id}:${t.text}`;function g({bucket:e,task:t,dupCount:n,onAct:r}){let i=e===`done`,a=e===`freeze`,o=i?t.doneAt:a?t.frozenAt:t.createdAt;return(0,d.jsxs)(`div`,{className:`row`,children:[(0,d.jsxs)(`span`,{className:`tid`,children:[`#`,t.id]}),(0,d.jsx)(c,{className:`topic`,text:t.topic,title:`点击复制主题`,children:t.topic}),(0,d.jsx)(`span`,{className:`text`,title:t.text,children:t.text}),n>1?(0,d.jsxs)(`span`,{className:`tag`,title:`同内容有 ${n} 条,操作时需要消歧`,children:[`同内容×`,n]}):null,(0,d.jsx)(`span`,{className:`muted time`,children:p(o)}),(0,d.jsxs)(`span`,{className:`acts`,children:[e===`open`?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`button`,{className:`btn small`,onClick:()=>r(`done`,t),children:`完成`}),(0,d.jsx)(`button`,{className:`btn small ghost`,onClick:()=>r(`freeze`,t),children:`冻结`})]}):null,a?(0,d.jsx)(`button`,{className:`btn small`,onClick:()=>r(`unfreeze`,t),children:`解冻`}):null,(0,d.jsx)(`button`,{className:`btn small ghost`,onClick:()=>r(`edit`,t,e),children:`编辑`}),(0,d.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>r(`remove`,t,e),children:`删除`})]}),t.note?(0,d.jsx)(`div`,{className:`note`,children:t.note}):null]})}function _(){let{boot:r,ui:s,patchUi:c,refreshBoot:_}=a(),v=e(),y=n(),{dialog:b,node:x}=o(),[S,C]=(0,u.useState)(null),[w,T]=(0,u.useState)(!1),[E,D]=(0,u.useState)({topic:``,text:``}),[O,k]=(0,u.useState)(null),[A,j]=(0,u.useState)({}),M=r?.groupId??0,N=(r?.groups||[]).find(e=>e.id===M)?.name||(M?`#${M}`:`默认组`),P=(0,u.useCallback)(async()=>{if(r?.loggedIn)try{C(await t(`/api/todo`))}catch(e){v(e.message)}},[r?.loggedIn,v]);(0,u.useEffect)(()=>{P()},[P,M]);let F=(0,u.useCallback)(async()=>{T(!0);try{await P()}finally{T(!1)}},[P]),I=(0,u.useMemo)(()=>{let e=new Map;if(!S)return e;for(let[t]of f)for(let n of S[t]||[])e.set(n.text,(e.get(n.text)||0)+1);return e},[S]),L=(0,u.useMemo)(()=>{if(!S)return null;let e=s.topic,t=t=>t?e?t.filter(t=>t.topic===e):t:null;return{open:t(S.open),done:t(S.done),freeze:t(S.freeze)}},[S,s.topic]);if(!r?.loggedIn)return(0,d.jsxs)(`div`,{className:`card`,style:{padding:16},children:[(0,d.jsx)(`div`,{className:`colhead`,children:(0,d.jsx)(`h3`,{children:`请先登录`})}),(0,d.jsxs)(`div`,{className:`muted`,children:[`在「登录」页填写邮箱与密码,或执行 `,(0,d.jsx)(`code`,{children:`nx-kv auth login <email>`}),`。`]})]});let R=async(e,t)=>{let n=[];for(let[t]of f)for(let r of S[t]||[])r.text===e.text&&n.push({bucket:t,task:r});if(n.length<=1)return{bucket:t,task:e,pick:void 0};let r=n.findIndex(n=>n.bucket===t&&n.task.createdAt===e.createdAt),i=await b({title:`「${e.text.slice(0,30)}」有 ${n.length} 条,选哪一条?`,message:n.map((e,t)=>`[${t}] ${e.bucket} ${p(e.task.createdAt)} #${e.task.id}`).join(`
1
+ import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./index-g03vbcKX.js";import{t as l}from"./CliHints-T9OvbUA5.js";var u=r(),d=s(),f=[[`open`,`待办`],[`done`,`已完成`],[`freeze`,`冻结`]],p=e=>e?String(e).slice(0,16).replace(`T`,` `):``,m=15,h=(e,t)=>`${e}:${t.id}:${t.text}`;function g({bucket:e,task:t,dupCount:n,onAct:r}){let i=e===`done`,a=e===`freeze`,o=i?t.doneAt:a?t.frozenAt:t.createdAt;return(0,d.jsxs)(`div`,{className:`row`,children:[(0,d.jsxs)(`span`,{className:`tid`,children:[`#`,t.id]}),(0,d.jsx)(c,{className:`topic`,text:t.topic,title:`点击复制主题`,children:t.topic}),(0,d.jsx)(`span`,{className:`text`,title:t.text,children:t.text}),n>1?(0,d.jsxs)(`span`,{className:`tag`,title:`同内容有 ${n} 条,操作时需要消歧`,children:[`同内容×`,n]}):null,(0,d.jsx)(`span`,{className:`muted time`,children:p(o)}),(0,d.jsxs)(`span`,{className:`acts`,children:[e===`open`?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`button`,{className:`btn small`,onClick:()=>r(`done`,t),children:`完成`}),(0,d.jsx)(`button`,{className:`btn small ghost`,onClick:()=>r(`freeze`,t),children:`冻结`})]}):null,a?(0,d.jsx)(`button`,{className:`btn small`,onClick:()=>r(`unfreeze`,t),children:`解冻`}):null,(0,d.jsx)(`button`,{className:`btn small ghost`,onClick:()=>r(`edit`,t,e),children:`编辑`}),(0,d.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>r(`remove`,t,e),children:`删除`})]}),t.note?(0,d.jsx)(`div`,{className:`note`,children:t.note}):null]})}function _(){let{boot:r,ui:s,patchUi:c,refreshBoot:_}=a(),v=e(),y=n(),{dialog:b,node:x}=o(),[S,C]=(0,u.useState)(null),[w,T]=(0,u.useState)(!1),[E,D]=(0,u.useState)({topic:``,text:``}),[O,k]=(0,u.useState)(null),[A,j]=(0,u.useState)({}),M=r?.groupId??0,N=(r?.groups||[]).find(e=>e.id===M)?.name||(M?`#${M}`:`默认组`),P=(0,u.useCallback)(async()=>{if(r?.loggedIn)try{C(await t(`/api/todo`))}catch(e){v(e.message)}},[r?.loggedIn,v]);(0,u.useEffect)(()=>{P()},[P,M]);let F=(0,u.useCallback)(async()=>{T(!0);try{await P()}finally{T(!1)}},[P]),I=(0,u.useMemo)(()=>{let e=new Map;if(!S)return e;for(let[t]of f)for(let n of S[t]||[])e.set(n.text,(e.get(n.text)||0)+1);return e},[S]),L=(0,u.useMemo)(()=>{if(!S)return null;let e=s.topic,t=t=>t?e?t.filter(t=>t.topic===e):t:null;return{open:t(S.open),done:t(S.done),freeze:t(S.freeze)}},[S,s.topic]);if(!r?.loggedIn)return(0,d.jsxs)(`div`,{className:`card`,style:{padding:16},children:[(0,d.jsx)(`div`,{className:`colhead`,children:(0,d.jsx)(`h3`,{children:`请先登录`})}),(0,d.jsxs)(`div`,{className:`muted`,children:[`在「登录」页填写邮箱与密码,或执行 `,(0,d.jsx)(`code`,{children:`nx-kv auth login <email>`}),`。`]})]});let R=async(e,t)=>{let n=[];for(let[t]of f)for(let r of S[t]||[])r.text===e.text&&n.push({bucket:t,task:r});if(n.length<=1)return{bucket:t,task:e,pick:void 0};let r=n.findIndex(n=>n.bucket===t&&n.task.createdAt===e.createdAt),i=await b({title:`「${e.text.slice(0,30)}」有 ${n.length} 条,选哪一条?`,message:n.map((e,t)=>`[${t}] ${e.bucket} ${p(e.task.createdAt)} #${e.task.id}`).join(`
2
2
  `),input:!0,placeholder:`输入 0..${n.length-1}`,value:String(r>=0?r:0)});if(i===null)return null;let a=Number(i);return!Number.isInteger(a)||!n[a]?(v(`请输入 0..${n.length-1}`),null):{...n[a],pick:a}},z=(e,n,r)=>y(async()=>{let i=e===`remove`||e===`edit`?await R(n,r):{bucket:r,task:n,pick:void 0};if(!i)return;let a={group:M,ref:i.task.text,pick:i.pick};if(e===`done`){let e=await b({title:`完成结果`,message:`完成「${n.text.slice(0,40)}」`,input:!0,placeholder:`可选:写一句完成结果`});if(e===null)return;await t(`/api/todo/done`,{method:`POST`,body:{...a,result:e||void 0}}),v(`已完成`)}else if(e===`freeze`)await t(`/api/todo/freeze`,{method:`POST`,body:a}),v(`已冻结`);else if(e===`unfreeze`)await t(`/api/todo/unfreeze`,{method:`POST`,body:a}),v(`已解冻`);else if(e===`remove`){if(!await b({message:`删除「${n.text.slice(0,40)}」?`,danger:!0}))return;await t(`/api/todo/item`,{method:`DELETE`,body:a}),v(`已删除`)}else if(e===`edit`){let e=await b({title:`编辑内容`,input:!0,value:i.task.text});if(e===null||!e)return;await t(`/api/todo/item`,{method:`PATCH`,body:{...a,text:e,matchTopic:i.task.topic}}),v(`已更新`)}await F(),await _()}),B=()=>y(async()=>{let e=await b({title:`归档已完成的旧记录`,message:`把「完成时间早于该日期」的记录移到冷 key(默认 30 天前)。留空用默认值。`,input:!0,placeholder:`YYYY-MM-DD,留空 = 30 天前`});if(e===null)return;let n=await t(`/api/todo/archive`,{method:`POST`,body:{before:e.trim()||void 0,group:M}});v(n.moved?`已归档 ${n.moved} 条 → ${n.coldKey}`:`没有需要归档的记录`),await F()}),V=()=>y(async()=>{let e=E.topic.trim(),n=E.text.trim();if(!e){v(`请填主题`);return}if(!n){v(`请填内容`);return}let r=await t(`/api/todo`,{method:`POST`,body:{topic:e,text:n,group:M}});D({topic:e,text:``}),v(`已加入待办${r.topicAdded?`(新主题 ${e})`:``}`),await F()}),H=(e,t)=>A[e]?t:t.slice(0,m),U=S?.topics||[],W=L?f.map(([e,t])=>`${t} ${(L[e]||[]).length}`).join(` · `):``;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`toolbar`,children:[(0,d.jsx)(`label`,{children:`工作空间`}),(0,d.jsx)(`span`,{className:`pill on`,children:N}),(0,d.jsx)(`span`,{className:`sep`}),(0,d.jsx)(`label`,{children:`主题`}),(0,d.jsxs)(`select`,{value:s.topic,onChange:e=>c({topic:e.target.value}),children:[(0,d.jsx)(`option`,{value:``,children:`全部`}),U.map(e=>(0,d.jsx)(`option`,{value:e,children:e},e))]}),(0,d.jsx)(`span`,{className:`sep`}),(0,d.jsx)(`input`,{placeholder:`主题`,size:`8`,value:E.topic,onChange:e=>D({...E,topic:e.target.value})}),(0,d.jsx)(`input`,{placeholder:`要做什么…`,size:`30`,value:E.text,onChange:e=>D({...E,text:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&V()}}),(0,d.jsx)(`button`,{className:`btn`,onClick:V,children:`加入待办`}),(0,d.jsx)(`button`,{className:`btn ghost`,onClick:F,disabled:w,children:w?`刷新中…`:`刷新`})]}),(0,d.jsx)(`div`,{className:`muted`,style:{margin:`0 0 8px 2px`,fontSize:12},children:W}),(0,d.jsx)(`div`,{className:`cols`,children:f.map(([e,t])=>(0,d.jsxs)(`div`,{className:`col`,children:[(0,d.jsxs)(`div`,{className:`colhead`,children:[(0,d.jsx)(`h3`,{children:t}),(0,d.jsx)(`span`,{className:`muted`,children:(L?.[e]||[]).length}),e===`done`&&(L?.done||[]).length?(0,d.jsx)(`button`,{className:`btn small ghost`,style:{marginLeft:`auto`},onClick:B,title:`把较旧的完成记录移到冷 key`,children:`归档旧记录`}):null]}),(0,d.jsxs)(`div`,{className:`card list`,children:[(L?.[e]||[]).length?H(e,L[e]).map(t=>(0,d.jsx)(g,{bucket:e,task:t,dupCount:I.get(t.text)||1,onAct:z},h(e,t))):(0,d.jsx)(`div`,{className:`row muted`,children:`(空)`}),(L?.[e]||[]).length>m?(0,d.jsx)(`div`,{className:`row muted`,style:{cursor:`pointer`,justifyContent:`center`},onClick:()=>j(t=>({...t,[e]:!t[e]})),children:A[e]?`收起`:`还有 ${L[e].length-m} 条,点击展开`}):null]})]},e))}),(0,d.jsx)(l,{module:`todo`}),O?(0,d.jsx)(i,{title:O.title,onClose:()=>k(null),children:O.node}):null,x]})}export{_ as default};
@@ -0,0 +1 @@
1
+ import{a as e,c as t,i as n,l as r,s as i}from"./index-g03vbcKX.js";import{t as a}from"./CliHints-T9OvbUA5.js";var o=r(),s=i();function c(e){let t=/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/.exec(e||``);return t?new Date(+t[1],t[2]-1,+t[3],+t[4],+t[5],+t[6]):null}function l(e){let t=c(e);if(!t)return``;let n=t.getTime()-Date.now();if(n<=0)return`等待中 0:00`;let r=Math.floor(n/6e4),i=Math.floor(n%6e4/1e3);return`等待中 ${r}:${String(i).padStart(2,`0`)}`}function u(){let r=e(),i=n(),[c,u]=(0,o.useState)(null),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(180),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(!1),[C,w]=(0,o.useState)(null),[T,E]=(0,o.useState)(``),[D,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)(null),[j,M]=(0,o.useState)(null),[N,P]=(0,o.useState)(!1),[F,I]=(0,o.useState)(()=>new Set),[L,R]=(0,o.useState)(!1),z=(0,o.useCallback)(async()=>{try{u(await t(`/api/localtasks`))}catch(e){r(e.message)}},[r]);(0,o.useEffect)(()=>{z()},[z]),(0,o.useEffect)(()=>{let e=setInterval(z,1500);return()=>clearInterval(e)},[z]);let B=c?c.topics:[];(0,o.useEffect)(()=>{c&&c.settings&&v(c.settings.timeoutSec)},[c]);let V=e=>i(async()=>{v(Number(e)),b(!0);try{let n=await t(`/api/localtasks/setting`,{method:`PATCH`,body:{timeout:Number(e)}});v(n.timeoutSec),r(`等待超时已配置为 ${n.timeoutSec} 秒`)}finally{b(!1)}}),H=()=>i(async()=>{S(!0);try{let e=await t(`/api/localtasks/prune`,{method:`POST`,body:{}});r(e.count?`已清理 ${e.count} 个旧主题`:`没有需要清理的旧数据`),await z()}finally{S(!1)}});(0,o.useEffect)(()=>{if(!B.length){f(null);return}if(d&&B.some(e=>e.key===d))return;let e=B.find(e=>e.waiting)||B[0];f(e.key)},[B,d]),(0,o.useEffect)(()=>{I(e=>{let t=new Set([...e].filter(e=>B.some(t=>t.key===e)));return t.size===e.size?e:t})},[B]);let U=B.find(e=>e.key===d)||null,W=e=>I(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),G=B.length>0&&F.size===B.length,K=()=>I(G?new Set:new Set(B.map(e=>e.key))),q=()=>i(async()=>{let e=p.trim();if(!e){r(`请输入任务内容`);return}if(!U){r(`请先选择一个主题(工作目录)`);return}g(!0);try{let n=await t(`/api/localtasks`,{method:`POST`,body:{cwd:U.cwd,text:e}});m(``),r(n.delivered?`已返回给等待中的 agent`:`已排入该主题队列,等待 agent 下一次 wait`),await z()}finally{g(!1)}}),ee=e=>i(async()=>{await t(`/api/localtasks/item`,{method:`DELETE`,body:{cwd:U.cwd,id:e}}),r(`已删除`),await z()}),te=e=>i(async()=>{let n=e.waiting?`主题「${e.name}」正在等待中,删除后其 agent 将超时收尾,确认删除?`:`删除主题「${e.name}」及其全部 ${e.total} 条任务?`;if(window.confirm(n)){R(!0);try{await t(`/api/localtasks/topic`,{method:`DELETE`,body:e.waiting?{key:e.key,force:!0}:{key:e.key}}),I(t=>{let n=new Set(t);return n.delete(e.key),n}),r(`已删除主题`),await z()}finally{R(!1)}}}),ne=()=>i(async()=>{if(!F.size)return;let e=B.filter(e=>F.has(e.key)),n=e.filter(e=>e.waiting).length,i=`确认删除选中的 ${e.length} 个主题?`;if(n&&(i+=`(其中 ${n} 个等待中,删除后其 agent 将超时收尾)`),window.confirm(i)){R(!0);try{let e=await t(`/api/localtasks/topics/remove`,{method:`POST`,body:{keys:[...F],force:n>0}});r(`已删除 ${e.count} 个主题`+(e.skipped.length?`,跳过 ${e.skipped.length} 个`:``)),I(new Set),await z()}finally{R(!1)}}}),re=e=>{w(e.id),E(e.text)},J=()=>{w(null),E(``)},Y=()=>i(async()=>{let e=T.trim();if(!e){r(`任务内容不能为空`);return}O(!0);try{await t(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:U.cwd,id:C,text:e}}),r(`已保存修改`),w(null),await z()}finally{O(!1)}}),X=U?U.tasks.slice().reverse():[],Z=U?U.tasks.filter(e=>e.status!==`consumed`):[],Q=(e,{beforeId:n,afterId:a})=>i(async()=>{P(!0);try{await t(`/api/localtasks/reorder`,{method:`PATCH`,body:{cwd:U.cwd,id:e,beforeId:n,afterId:a}}),r(`已调整领取优先级`),await z()}finally{P(!1),A(null),M(null)}}),$=(e,t)=>{let n=Z.findIndex(t=>t.id===e.id);t===`up`&&n>0&&Q(e.id,{beforeId:Z[n-1].id}),t===`down`&&n<Z.length-1&&Q(e.id,{afterId:Z[n+1].id})},ie=(e,t)=>{if(k===null||t.status===`consumed`||k===t.id)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2?`top`:`bottom`;M(e=>e&&e.id===t.id&&e.pos===r?e:{id:t.id,pos:r})},ae=(e,t)=>{if(k===null||t.status===`consumed`||k===t.id)return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2,i=k;A(null),M(null),Q(i,r?{afterId:t.id}:{beforeId:t.id})};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`card`,style:{padding:`10px 14px`},children:(0,s.jsxs)(`div`,{className:`muted`,style:{fontSize:12},children:[`agent 用法:完成当前任务后,把`,(0,s.jsx)(`code`,{children:` nx-kv localtask wait --cwd "<工作目录>" --summary "<当前现状>" --json `}),`作为本轮`,(0,s.jsx)(`strong`,{children:`最后一个动作`}),`调用——工作目录即`,(0,s.jsx)(`strong`,{children:`主题`}),`、主题拥有任务队列, 同目录共用队列、不同目录互不串,任务可在队列里堆积;命令阻塞并自动打开浏览器弹窗, 用户回填后解除阻塞、返回新任务;超时未回填则返回 `,(0,s.jsx)(`code`,{children:`status:"timeout"`}),`,agent 收尾结束本轮。`]})}),(0,s.jsxs)(`div`,{className:`card`,style:{padding:`10px 14px`,display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,s.jsx)(`span`,{style:{fontWeight:700},children:`等待超时`}),(0,s.jsxs)(`select`,{value:_,disabled:y,onChange:e=>V(e.target.value),style:{font:`inherit`,padding:`5px 8px`},children:[(0,s.jsx)(`option`,{value:60,children:`1 分钟`}),(0,s.jsx)(`option`,{value:120,children:`2 分钟`}),(0,s.jsx)(`option`,{value:180,children:`3 分钟(推荐)`}),(0,s.jsx)(`option`,{value:240,children:`4 分钟`}),(0,s.jsx)(`option`,{value:300,children:`5 分钟`}),(0,s.jsx)(`option`,{value:600,children:`10 分钟(最大)`})]}),(0,s.jsx)(`span`,{className:`muted`,style:{fontSize:12},children:`agent wait 未带 --timeout 时使用此值;推荐 3 分钟、最大 10 分钟。`})]}),(0,s.jsxs)(`div`,{className:`colhead`,children:[(0,s.jsx)(`input`,{type:`checkbox`,checked:G,onChange:K,disabled:!B.length,title:`全选 / 取消全选`,style:{margin:0}}),(0,s.jsx)(`h3`,{children:`主题总览(按工作目录)`}),(0,s.jsx)(`span`,{className:`muted`,children:c?`${B.length} 个 · 等待中 ${c.waiting}`:``}),(0,s.jsxs)(`span`,{style:{marginLeft:`auto`,display:`flex`,gap:8},children:[(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:ne,disabled:!F.size||L,title:`删除勾选的主题(含其全部任务)`,children:L?`删除中…`:`批量删除${F.size?` (${F.size})`:``}`}),(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:H,disabled:x,title:`清理旧模型无目录主题与空主题(等待中一律保留)`,children:x?`清理中…`:`清理旧数据`})]})]}),(0,s.jsx)(`div`,{style:{display:`flex`,gap:10,flexWrap:`wrap`,marginBottom:14},children:B.length?B.map(e=>{let t=e.key===d;return(0,s.jsxs)(`div`,{onClick:()=>f(e.key),className:`card`,style:{textAlign:`left`,width:270,padding:`10px 12px`,cursor:`pointer`,border:t?`1px solid var(--ink,#14161a)`:`1px solid transparent`,boxShadow:t?`0 0 0 2px rgba(20,22,26,.12)`:`0 1px 2px rgba(20,22,26,.06), 0 6px 16px rgba(20,22,26,.05)`},children:[(0,s.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:[(0,s.jsx)(`input`,{type:`checkbox`,checked:F.has(e.key),onChange:()=>W(e.key),onClick:e=>e.stopPropagation(),title:`选择以批量删除`,style:{margin:`3px 0 0`}}),(0,s.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,s.jsx)(`div`,{style:{fontWeight:700,marginBottom:2},children:e.name||`(未命名)`}),(0,s.jsx)(`div`,{className:`mono muted`,title:e.cwd,style:{fontSize:11,wordBreak:`break-all`,marginBottom:6,minHeight:15},children:e.cwd||`(旧数据,无目录)`})]})]}),e.summary&&(0,s.jsxs)(`div`,{className:`muted`,style:{fontSize:11,whiteSpace:`pre-wrap`,marginBottom:6},children:[`现状:`,e.summary]}),(0,s.jsxs)(`div`,{style:{display:`flex`,gap:6,alignItems:`center`},children:[e.waiting?(0,s.jsx)(`span`,{className:`tag strong`,children:l(e.waitingUntil)}):(0,s.jsx)(`span`,{className:`tag`,children:`已结束`}),(0,s.jsxs)(`span`,{className:`muted`,style:{fontSize:11},children:[`待领取 `,e.pending,`/`,e.total]})]}),(0,s.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginTop:8},onClick:e=>e.stopPropagation(),children:(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:()=>te(e),disabled:L,title:`删除整个主题(含全部任务)`,children:`删除主题`})})]},e.key)}):(0,s.jsx)(`div`,{className:`card muted`,style:{padding:`20px 16px`,width:`100%`,textAlign:`center`},children:`(暂无主题;agent 调用 localtask wait 后会出现在这里)`})}),U&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`div`,{className:`toolbar`,children:[(0,s.jsx)(`span`,{style:{fontWeight:700,maxWidth:240},title:U.cwd,children:U.name}),(0,s.jsx)(`span`,{className:`sep`}),(0,s.jsx)(`textarea`,{style:{flex:1,minWidth:240,minHeight:40,resize:`vertical`},spellCheck:`false`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),q())},placeholder:`向主题「${U.name}」的队列回填下一条任务(Enter 提交,Shift+Enter 换行)`}),(0,s.jsx)(`button`,{className:`btn`,onClick:q,disabled:h,children:h?`提交中…`:`回填新任务`})]}),(0,s.jsxs)(`div`,{className:`colhead`,children:[(0,s.jsx)(`h3`,{children:`该主题的任务队列`}),(0,s.jsxs)(`span`,{className:`muted`,children:[`待领取 `,U.pending,` · 共 `,U.total,` 条`]}),(0,s.jsx)(`span`,{className:`muted`,style:{fontSize:12,marginLeft:`auto`},children:`拖拽待领取行(或用「提前/置后」)调整领取优先级`})]}),(0,s.jsx)(`div`,{className:`card`,style:{padding:4},children:(0,s.jsxs)(`table`,{children:[(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{style:{width:34}}),(0,s.jsx)(`th`,{style:{width:56},children:`#`}),(0,s.jsx)(`th`,{children:`任务`}),(0,s.jsx)(`th`,{style:{width:80},children:`状态`}),(0,s.jsx)(`th`,{style:{width:160},children:`时间`}),(0,s.jsx)(`th`,{style:{width:150},children:`操作`})]})}),(0,s.jsx)(`tbody`,{children:X.length?X.map(e=>{let t=e.status!==`consumed`,n=k===e.id,r=j&&j.id===e.id;return(0,s.jsxs)(`tr`,{draggable:t&&C!==e.id,onDragStart:t=>{A(e.id),t.dataTransfer.effectAllowed=`move`;try{t.dataTransfer.setData(`text/plain`,String(e.id))}catch{}},onDragOver:t=>ie(t,e),onDrop:t=>ae(t,e),onDragEnd:()=>{A(null),M(null)},style:{cursor:t&&C!==e.id?`grab`:`default`,opacity:n?.4:1,boxShadow:r?j.pos===`top`?`inset 0 2px 0 var(--ink,#14161a)`:`inset 0 -2px 0 var(--ink,#14161a)`:`none`,background:r?`rgba(20,22,26,.04)`:void 0},children:[(0,s.jsx)(`td`,{className:`mono muted`,title:`按住拖拽调整优先级`,style:{textAlign:`center`,userSelect:`none`},children:t?`⠿`:``}),(0,s.jsxs)(`td`,{className:`mono`,children:[`#`,e.id]}),(0,s.jsx)(`td`,{style:{whiteSpace:`pre-wrap`},children:C===e.id?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`textarea`,{value:T,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),Y()),e.key===`Escape`&&J()},spellCheck:`false`,autoFocus:!0,style:{width:`100%`,minHeight:60,resize:`vertical`}}),(0,s.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:6},children:[(0,s.jsx)(`button`,{className:`btn small`,onClick:Y,disabled:D,children:D?`保存中…`:`保存`}),(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:J,disabled:D,children:`取消`}),(0,s.jsx)(`span`,{className:`muted`,style:{fontSize:11,alignSelf:`center`},children:`Ctrl+Enter 保存 · Esc 取消`})]})]}):(0,s.jsxs)(s.Fragment,{children:[e.text,e.roundSummary&&(0,s.jsxs)(`div`,{className:`muted`,style:{fontSize:11,marginTop:4,paddingTop:4,borderTop:`1px dashed var(--line,#e6e8eb)`,whiteSpace:`pre-wrap`},title:`该任务所回应的 agent 上一轮完成总结`,children:[`上一轮完成:`,e.roundSummary]})]})}),(0,s.jsx)(`td`,{children:e.status===`consumed`?(0,s.jsx)(`span`,{className:`tag strong`,children:`已领取`}):(0,s.jsx)(`span`,{className:`tag`,children:`待领取`})}),(0,s.jsx)(`td`,{className:`mono`,children:e.consumedAt||e.createdAt}),(0,s.jsxs)(`td`,{className:`ops`,children:[t&&C!==e.id&&(()=>{let t=Z.findIndex(t=>t.id===e.id);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:()=>re(e),children:`编辑`}),(0,s.jsx)(`button`,{className:`btn small ghost`,title:`提高优先级(更早被领取)`,disabled:N||t<=0,onClick:()=>$(e,`up`),children:`提前`}),(0,s.jsx)(`button`,{className:`btn small ghost`,title:`降低优先级(更晚被领取)`,disabled:N||t>=Z.length-1,onClick:()=>$(e,`down`),children:`置后`})]})})(),(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ee(e.id),children:`删除`})]})]},e.id)}):(0,s.jsx)(`tr`,{children:(0,s.jsx)(`td`,{colSpan:`6`,className:`muted`,style:{textAlign:`center`,padding:`22px 0`},children:`(暂无任务,在上方回填第一条)`})})})]})})]}),(0,s.jsx)(a,{module:`localtask`})]})}export{u as default};
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./index-BC4hXOgL.js";import{t as l}from"./CliHints-BcGuVv3q.js";var u=r(),d=s();function f(){let{boot:r,refreshBoot:s}=a(),f=e(),p=n(),{dialog:m,node:h}=o(),[g,_]=(0,u.useState)([]),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)({name:``,description:``}),[S,C]=(0,u.useState)(null),w=(0,u.useCallback)(async()=>{if(r?.loggedIn)try{let e=await t(`/api/groups`);_(e.groups||[]),y(``)}catch(e){y(e.message)}},[r?.loggedIn]);(0,u.useEffect)(()=>{w()},[w]);let T=e=>p(async()=>{let n=await t(`/api/group`,{method:`POST`,body:{locator:e}});f(n.id===0?`已切回默认组`:`已切换到 ${n.name}`),await s(),await w()}),E=()=>p(async()=>{let e=b.name.trim();if(!e){f(`请填名称`);return}let n=await t(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),f(`已新建工作空间 ${n.name}(id=${n.id})`),await s(),await w()}),D=e=>p(async()=>{let n=await m({title:`重命名「${e.name}」`,input:!0,value:e.name});n!==null&&n.trim()&&(await t(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:n.trim()}}),f(`已更新名称`),await s(),await w())}),O=e=>p(async()=>{await m({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await t(`/api/groups/${e.id}`,{method:`DELETE`}),f(`已解散 ${e.name}`),await s(),await w())}),k=e=>p(async()=>{let n=await t(`/api/groups/${e.id}/members`);C({title:`成员 · ${e.name}`,node:(0,d.jsx)(`div`,{className:`list`,children:n.members.length?n.members.map(e=>(0,d.jsxs)(`div`,{className:`row`,children:[(0,d.jsx)(c,{className:`name`,text:e.email,title:`点击复制邮箱`,children:e.email}),(0,d.jsx)(`span`,{className:`tag`,children:e.role||`member`}),(0,d.jsx)(`span`,{className:`muted`,children:e.nickname})]},e.userId)):(0,d.jsx)(`div`,{className:`row muted`,children:`(没有成员)`})})})});return r?.loggedIn?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`toolbar`,children:[(0,d.jsx)(`input`,{placeholder:`新工作空间名称`,size:`16`,value:b.name,onChange:e=>x({...b,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&E()}}),(0,d.jsx)(`input`,{placeholder:`描述(可选)`,size:`20`,value:b.description,onChange:e=>x({...b,description:e.target.value})}),(0,d.jsx)(`button`,{className:`btn`,onClick:E,children:`新建`}),(0,d.jsx)(`span`,{className:`sep`}),(0,d.jsx)(`button`,{className:`btn ghost`,onClick:()=>p(w),children:`刷新`})]}),(0,d.jsxs)(`div`,{className:`card`,children:[(0,d.jsxs)(`div`,{className:`colhead`,children:[(0,d.jsx)(`h3`,{children:`我的工作空间`}),(0,d.jsx)(`span`,{className:`muted`,children:`切换后清单页立即跟着变`})]}),(0,d.jsxs)(`div`,{className:`list`,children:[v?(0,d.jsx)(`div`,{className:`row muted`,children:v}):null,(0,d.jsxs)(`div`,{className:`row`,children:[(0,d.jsx)(`span`,{className:`name`,children:`默认组`}),(0,d.jsx)(`span`,{className:`desc`,children:`不传 groupId,由后端回落`}),(0,d.jsx)(`span`,{className:`acts`,children:r.groupId===0?(0,d.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,d.jsx)(`button`,{className:`btn small`,onClick:()=>T(`default`),children:`切到这里`})})]}),g.map(e=>(0,d.jsxs)(`div`,{className:`row`,children:[(0,d.jsx)(c,{className:`name`,text:e.name,title:`点击复制名称`,children:e.name}),(0,d.jsx)(`span`,{className:`tag`,children:e.myRole||`member`}),(0,d.jsx)(`span`,{className:`desc`,children:e.description||``}),(0,d.jsxs)(`span`,{className:`muted mono`,children:[`id=`,e.id]}),(0,d.jsxs)(`span`,{className:`muted`,children:[e.memberCount,` 人`]}),(0,d.jsxs)(`span`,{className:`acts`,children:[e.id===r.groupId?(0,d.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,d.jsx)(`button`,{className:`btn small`,onClick:()=>T(String(e.id)),children:`切到这里`}),(0,d.jsx)(`button`,{className:`btn small ghost`,onClick:()=>k(e),children:`成员`}),(0,d.jsx)(`button`,{className:`btn small ghost`,onClick:()=>D(e),children:`改名`}),(0,d.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>O(e),children:`解散`})]})]},e.id)),!v&&!g.length?(0,d.jsx)(`div`,{className:`row muted`,children:`(没有其他工作空间)`}):null]})]}),(0,d.jsx)(l,{module:`group`}),S?(0,d.jsx)(i,{title:S.title,onClose:()=>C(null),children:S.node}):null,h]}):(0,d.jsxs)(`div`,{className:`card`,style:{padding:16},children:[(0,d.jsx)(`div`,{className:`colhead`,children:(0,d.jsx)(`h3`,{children:`请先登录`})}),(0,d.jsx)(`div`,{className:`muted`,children:`工作空间需要登录后才能列出。`})]})}export{f as default};
1
+ import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./index-g03vbcKX.js";import{t as l}from"./CliHints-T9OvbUA5.js";var u=r(),d=s();function f(){let{boot:r,refreshBoot:s}=a(),f=e(),p=n(),{dialog:m,node:h}=o(),[g,_]=(0,u.useState)([]),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)({name:``,description:``}),[S,C]=(0,u.useState)(null),w=(0,u.useCallback)(async()=>{if(r?.loggedIn)try{let e=await t(`/api/groups`);_(e.groups||[]),y(``)}catch(e){y(e.message)}},[r?.loggedIn]);(0,u.useEffect)(()=>{w()},[w]);let T=e=>p(async()=>{let n=await t(`/api/group`,{method:`POST`,body:{locator:e}});f(n.id===0?`已切回默认组`:`已切换到 ${n.name}`),await s(),await w()}),E=()=>p(async()=>{let e=b.name.trim();if(!e){f(`请填名称`);return}let n=await t(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),f(`已新建工作空间 ${n.name}(id=${n.id})`),await s(),await w()}),D=e=>p(async()=>{let n=await m({title:`重命名「${e.name}」`,input:!0,value:e.name});n!==null&&n.trim()&&(await t(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:n.trim()}}),f(`已更新名称`),await s(),await w())}),O=e=>p(async()=>{await m({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await t(`/api/groups/${e.id}`,{method:`DELETE`}),f(`已解散 ${e.name}`),await s(),await w())}),k=e=>p(async()=>{let n=await t(`/api/groups/${e.id}/members`);C({title:`成员 · ${e.name}`,node:(0,d.jsx)(`div`,{className:`list`,children:n.members.length?n.members.map(e=>(0,d.jsxs)(`div`,{className:`row`,children:[(0,d.jsx)(c,{className:`name`,text:e.email,title:`点击复制邮箱`,children:e.email}),(0,d.jsx)(`span`,{className:`tag`,children:e.role||`member`}),(0,d.jsx)(`span`,{className:`muted`,children:e.nickname})]},e.userId)):(0,d.jsx)(`div`,{className:`row muted`,children:`(没有成员)`})})})});return r?.loggedIn?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`toolbar`,children:[(0,d.jsx)(`input`,{placeholder:`新工作空间名称`,size:`16`,value:b.name,onChange:e=>x({...b,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&E()}}),(0,d.jsx)(`input`,{placeholder:`描述(可选)`,size:`20`,value:b.description,onChange:e=>x({...b,description:e.target.value})}),(0,d.jsx)(`button`,{className:`btn`,onClick:E,children:`新建`}),(0,d.jsx)(`span`,{className:`sep`}),(0,d.jsx)(`button`,{className:`btn ghost`,onClick:()=>p(w),children:`刷新`})]}),(0,d.jsxs)(`div`,{className:`card`,children:[(0,d.jsxs)(`div`,{className:`colhead`,children:[(0,d.jsx)(`h3`,{children:`我的工作空间`}),(0,d.jsx)(`span`,{className:`muted`,children:`切换后清单页立即跟着变`})]}),(0,d.jsxs)(`div`,{className:`list`,children:[v?(0,d.jsx)(`div`,{className:`row muted`,children:v}):null,(0,d.jsxs)(`div`,{className:`row`,children:[(0,d.jsx)(`span`,{className:`name`,children:`默认组`}),(0,d.jsx)(`span`,{className:`desc`,children:`不传 groupId,由后端回落`}),(0,d.jsx)(`span`,{className:`acts`,children:r.groupId===0?(0,d.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,d.jsx)(`button`,{className:`btn small`,onClick:()=>T(`default`),children:`切到这里`})})]}),g.map(e=>(0,d.jsxs)(`div`,{className:`row`,children:[(0,d.jsx)(c,{className:`name`,text:e.name,title:`点击复制名称`,children:e.name}),(0,d.jsx)(`span`,{className:`tag`,children:e.myRole||`member`}),(0,d.jsx)(`span`,{className:`desc`,children:e.description||``}),(0,d.jsxs)(`span`,{className:`muted mono`,children:[`id=`,e.id]}),(0,d.jsxs)(`span`,{className:`muted`,children:[e.memberCount,` 人`]}),(0,d.jsxs)(`span`,{className:`acts`,children:[e.id===r.groupId?(0,d.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,d.jsx)(`button`,{className:`btn small`,onClick:()=>T(String(e.id)),children:`切到这里`}),(0,d.jsx)(`button`,{className:`btn small ghost`,onClick:()=>k(e),children:`成员`}),(0,d.jsx)(`button`,{className:`btn small ghost`,onClick:()=>D(e),children:`改名`}),(0,d.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>O(e),children:`解散`})]})]},e.id)),!v&&!g.length?(0,d.jsx)(`div`,{className:`row muted`,children:`(没有其他工作空间)`}):null]})]}),(0,d.jsx)(l,{module:`group`}),S?(0,d.jsx)(i,{title:S.title,onClose:()=>C(null),children:S.node}):null,h]}):(0,d.jsxs)(`div`,{className:`card`,style:{padding:16},children:[(0,d.jsx)(`div`,{className:`colhead`,children:(0,d.jsx)(`h3`,{children:`请先登录`})}),(0,d.jsx)(`div`,{className:`muted`,children:`工作空间需要登录后才能列出。`})]})}export{f as default};
@@ -12,7 +12,7 @@
12
12
  <!-- .ico 兜底:浏览器不认上面的 <link> 时会自己请求 /favicon.ico -->
13
13
  <link rel="icon" type="image/x-icon" href="/favicon.ico">
14
14
  <link rel="apple-touch-icon" sizes="512x512" href="/logo-rounded.png">
15
- <script type="module" crossorigin src="/assets/index-BC4hXOgL.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-g03vbcKX.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="/assets/index-CmCYxz0e.css">
17
17
  </head>
18
18
  <body>
@@ -1,112 +0,0 @@
1
- ---
2
- name: kv-sessiontask
3
- description: 在一个对话里通过工具调用实时向 agent 回填任务(本机人机接力),替代在原始输入框打字——agent 完成当前任务、提交结果后,把 nx-kv sessiontask wait --summary "<当前现状总结>" 作为本轮最后一步强制调用;现状总结作为等待点 key,命令阻塞并自动打开浏览器弹窗,用户在面板看清现状、针对该现状回填后解除阻塞、把新任务作为工具结果返回,agent 继续;不同现状分散为不同等待点、可分别回填;120 秒未回填则超时收尾。触发词:实时任务、下一条任务、继续给任务、连续提交任务、补充任务、回填任务、现状总结、在网页/弹窗里给任务、任务表提交、不想用输入框、用工具调用实现用户输入、阻塞等待、挂起等用户、人机接力、分散答复、sessiontask、session wait。凡是「agent 不结束本轮、靠一个阻塞工具调用等用户在浏览器里继续喂任务」的场景,都走本 skill。
4
- ---
5
-
6
- # kv-sessiontask — 对话内实时任务接力
7
-
8
- 本质是一个循环:**agent 提交结果 → CLI 阻塞 → 用户在 web 看清现状、回填新任务 →
9
- agent 接收并继续**。在一个对话里连续给任务,不靠原始输入框。
10
-
11
- agent 完成当前任务、需要下一条输入时,调用一个**阻塞式**工具
12
- `nx-kv sessiontask wait`,并带上一句**当前现状总结**;它自动打开浏览器弹窗。
13
- 用户在面板/弹窗一眼看到现状,针对该现状回填,阻塞解除、新任务作为工具结果返回,
14
- agent 接着干。如此循环。
15
-
16
- > 纯本机协调:弹窗由 wait 进程临时起的 http 服务器直出,数据存本机文件,
17
- > **不需要登录 KV 后端**。
18
-
19
- ## 四条硬规则(最重要)
20
-
21
- 1. **wait 必须是本轮最后一个动作。** 把它安排在所有分析与工具调用之后(阶段
22
- 结果已经通过正常输出提交);调用之后不要再安排任何别的工具、输出或推理——
23
- 它会阻塞,直到拿到新任务或超时。
24
- 2. **这次工具调用的超时设为 `120000` ms(2 分钟)。** 与 CLI 的阻塞上限一致,
25
- 避免宿主在等待中途把调用杀掉。
26
- 3. **wait 必须带 `--summary "<当前现状总结>"`,现状总结就是等待点的 key。**
27
- - 回到**同一个现状**就用**同一句**总结(逐字一致,忽略首尾/连续空白差异),
28
- 从而复用同一个等待点;
29
- - 进入**新的现状**就换一句新总结,自然分散成新的等待点。
30
- - 总结写**当前做到哪、卡在哪、等用户决定什么**,让用户不读对话也能在面板
31
- 快速了解现状。
32
- 4. **返回 `status:"timeout"` 时直接收尾。** 用户 2 分钟内没回填,就不要再追问、
33
- 不要再次调用 wait,把当前结论交代清楚、结束本轮即可。
34
-
35
- ## 核心命令
36
-
37
- ```bash
38
- # 阻塞等待用户针对该现状回填(agent 本轮最后一步;务必加 --json)
39
- nx-kv sessiontask wait --summary "<当前现状总结>" --json
40
- ```
41
-
42
- 返回形状:
43
-
44
- | 返回 | 含义 | agent 怎么做 |
45
- | --- | --- | --- |
46
- | `{status:"ok", queued:true, task}` | 取到用户**提前排队**的回填(弹窗未开) | 直接执行 task |
47
- | `{status:"ok", delivered:true, task}` | 用户在弹窗/面板**实时回填** | 执行 task |
48
- | `{status:"timeout", key, summary, timeoutMs}` | 120 秒未收到回填 | 收尾、结束本轮 |
49
-
50
- 成功结果里带 `key` 与 `summary`;`task` 形如
51
- `{id, text, status, createdAt, consumedAt}`,**任务内容在 `task.text`**。
52
-
53
- ## 一次循环长什么样
54
-
55
- ```
56
- agent:干活 → 提交阶段结果
57
- → 最后一步:nx-kv sessiontask wait --summary "已完成登录,等待选择工作空间" --json
58
- (阻塞,弹窗/面板顶部显示这句现状)
59
- 用户:看清现状 → 回填「选择工作空间 A」→ 提交
60
- agent:工具结果拿到 task.text → 继续干活、提交结果
61
- → 新现状再 wait(同现状用同一句,新现状换新句)……(循环)
62
- 若 120 秒没回填:wait 返回 timeout → agent 结束本轮
63
- ```
64
-
65
- ## 分散答复:多个等待点并存
66
-
67
- - 每个不同的现状总结 = 一个等待点;面板「等待点总览」把它们并排展示,每张卡
68
- 显示现状、等待状态/倒计时、待领取数。
69
- - 用户点选任一等待点,即可**分别回填**(分散答复);也可趁 agent 在忙,给几个
70
- 等待点提前排队。
71
- - agent 用对应现状调用 wait 时取走该等待点的任务,互不串。
72
-
73
- ## 配套命令(弹窗背后同一套,agent 一般不直接用)
74
-
75
- ```bash
76
- nx-kv sessiontask list # 等待点总览
77
- nx-kv sessiontask add "<回填内容>" --summary "<现状>" # 针对现状排队/投递
78
- nx-kv sessiontask get --id <n> --summary "<现状>" # 查看单条
79
- nx-kv sessiontask update --id <n> --text "<新内容>" --summary "<现状>"
80
- nx-kv sessiontask remove --id <n> --summary "<现状>" # 删除单条任务
81
- nx-kv sessiontask topic remove --cwd "<工作目录>" # 删除整个主题(等待中需 --force)
82
- nx-kv sessiontask topic remove-many --keys "<key,key>" # 批量删除主题(或 --cwds "<dir,dir>",或 --all)
83
- ```
84
-
85
- > 删除主题:面板「主题总览」每张卡有「删除主题」,顶部勾选后可「批量删除」。
86
- > 等待中的主题默认不删(避免让阻塞的 agent 干等),确认要删会二次提示并以
87
- > `--force` 强删、agent 随后超时收尾。
88
-
89
- 常驻面板(`nx-kv serve`)的「实时任务」页就是等待点总览,可直接点选回填;
90
- wait 同样能取走(跨进程由轮询兜底)。
91
-
92
- ## 先判断你要做哪件事
93
-
94
- | 你要做的事 | 读哪份 |
95
- | --- | --- |
96
- | 要在对话里阻塞等用户回填,需要**完整时序、现状 key、排队语义、避坑** | [[sessiontask-workflow]] |
97
- | 只是查命令与返回形状 | 本页即可 |
98
-
99
- ## 与 nx-kv skill 的分工
100
-
101
- - **nx-kv**:操作 KV **后端**上的清单(todo,需登录、按 groupId 隔离)。
102
- - **kv-sessiontask(本 skill)**:**本机**实时人机接力,把用户在浏览器的回填
103
- 变成阻塞工具的返回,现状即 key,不碰后端、不需登录。
104
-
105
- 两者可同时安装,各管一段,不冲突。
106
-
107
- ## 安装
108
-
109
- ```bash
110
- nx-kv skill install kv-sessiontask # 装到 ~/.claude/skills/kv-sessiontask
111
- nx-kv skill list # 列出 nx-kv / kv-sessiontask
112
- ```
@@ -1 +0,0 @@
1
- import{a as e,c as t,i as n,l as r,s as i}from"./index-BC4hXOgL.js";import{t as a}from"./CliHints-BcGuVv3q.js";var o=r(),s=i();function c(e){let t=/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/.exec(e||``);return t?new Date(+t[1],t[2]-1,+t[3],+t[4],+t[5],+t[6]):null}function l(e){let t=c(e);if(!t)return``;let n=t.getTime()-Date.now();if(n<=0)return`等待中 0:00`;let r=Math.floor(n/6e4),i=Math.floor(n%6e4/1e3);return`等待中 ${r}:${String(i).padStart(2,`0`)}`}function u(){let r=e(),i=n(),[c,u]=(0,o.useState)(null),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(180),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(!1),[C,w]=(0,o.useState)(null),[T,E]=(0,o.useState)(``),[D,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)(null),[j,M]=(0,o.useState)(null),[N,P]=(0,o.useState)(!1),[F,I]=(0,o.useState)(()=>new Set),[L,R]=(0,o.useState)(!1),z=(0,o.useCallback)(async()=>{try{u(await t(`/api/sessiontasks`))}catch(e){r(e.message)}},[r]);(0,o.useEffect)(()=>{z()},[z]),(0,o.useEffect)(()=>{let e=setInterval(z,1500);return()=>clearInterval(e)},[z]);let B=c?c.topics:[];(0,o.useEffect)(()=>{c&&c.settings&&v(c.settings.timeoutSec)},[c]);let V=e=>i(async()=>{v(Number(e)),b(!0);try{let n=await t(`/api/sessiontasks/setting`,{method:`PATCH`,body:{timeout:Number(e)}});v(n.timeoutSec),r(`等待超时已配置为 ${n.timeoutSec} 秒`)}finally{b(!1)}}),H=()=>i(async()=>{S(!0);try{let e=await t(`/api/sessiontasks/prune`,{method:`POST`,body:{}});r(e.count?`已清理 ${e.count} 个旧主题`:`没有需要清理的旧数据`),await z()}finally{S(!1)}});(0,o.useEffect)(()=>{if(!B.length){f(null);return}if(d&&B.some(e=>e.key===d))return;let e=B.find(e=>e.waiting)||B[0];f(e.key)},[B,d]),(0,o.useEffect)(()=>{I(e=>{let t=new Set([...e].filter(e=>B.some(t=>t.key===e)));return t.size===e.size?e:t})},[B]);let U=B.find(e=>e.key===d)||null,W=e=>I(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),G=B.length>0&&F.size===B.length,K=()=>I(G?new Set:new Set(B.map(e=>e.key))),q=()=>i(async()=>{let e=p.trim();if(!e){r(`请输入任务内容`);return}if(!U){r(`请先选择一个主题(工作目录)`);return}g(!0);try{let n=await t(`/api/sessiontasks`,{method:`POST`,body:{cwd:U.cwd,text:e}});m(``),r(n.delivered?`已返回给等待中的 agent`:`已排入该主题队列,等待 agent 下一次 wait`),await z()}finally{g(!1)}}),ee=e=>i(async()=>{await t(`/api/sessiontasks/item`,{method:`DELETE`,body:{cwd:U.cwd,id:e}}),r(`已删除`),await z()}),te=e=>i(async()=>{let n=e.waiting?`主题「${e.name}」正在等待中,删除后其 agent 将超时收尾,确认删除?`:`删除主题「${e.name}」及其全部 ${e.total} 条任务?`;if(window.confirm(n)){R(!0);try{await t(`/api/sessiontasks/topic`,{method:`DELETE`,body:e.waiting?{key:e.key,force:!0}:{key:e.key}}),I(t=>{let n=new Set(t);return n.delete(e.key),n}),r(`已删除主题`),await z()}finally{R(!1)}}}),ne=()=>i(async()=>{if(!F.size)return;let e=B.filter(e=>F.has(e.key)),n=e.filter(e=>e.waiting).length,i=`确认删除选中的 ${e.length} 个主题?`;if(n&&(i+=`(其中 ${n} 个等待中,删除后其 agent 将超时收尾)`),window.confirm(i)){R(!0);try{let e=await t(`/api/sessiontasks/topics/remove`,{method:`POST`,body:{keys:[...F],force:n>0}});r(`已删除 ${e.count} 个主题`+(e.skipped.length?`,跳过 ${e.skipped.length} 个`:``)),I(new Set),await z()}finally{R(!1)}}}),re=e=>{w(e.id),E(e.text)},J=()=>{w(null),E(``)},Y=()=>i(async()=>{let e=T.trim();if(!e){r(`任务内容不能为空`);return}O(!0);try{await t(`/api/sessiontasks/item`,{method:`PATCH`,body:{cwd:U.cwd,id:C,text:e}}),r(`已保存修改`),w(null),await z()}finally{O(!1)}}),X=U?U.tasks.slice().reverse():[],Z=U?U.tasks.filter(e=>e.status!==`consumed`):[],Q=(e,{beforeId:n,afterId:a})=>i(async()=>{P(!0);try{await t(`/api/sessiontasks/reorder`,{method:`PATCH`,body:{cwd:U.cwd,id:e,beforeId:n,afterId:a}}),r(`已调整领取优先级`),await z()}finally{P(!1),A(null),M(null)}}),$=(e,t)=>{let n=Z.findIndex(t=>t.id===e.id);t===`up`&&n>0&&Q(e.id,{beforeId:Z[n-1].id}),t===`down`&&n<Z.length-1&&Q(e.id,{afterId:Z[n+1].id})},ie=(e,t)=>{if(k===null||t.status===`consumed`||k===t.id)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2?`top`:`bottom`;M(e=>e&&e.id===t.id&&e.pos===r?e:{id:t.id,pos:r})},ae=(e,t)=>{if(k===null||t.status===`consumed`||k===t.id)return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2,i=k;A(null),M(null),Q(i,r?{afterId:t.id}:{beforeId:t.id})};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`card`,style:{padding:`10px 14px`},children:(0,s.jsxs)(`div`,{className:`muted`,style:{fontSize:12},children:[`agent 用法:完成当前任务后,把`,(0,s.jsx)(`code`,{children:` nx-kv sessiontask wait --cwd "<工作目录>" --summary "<当前现状>" --json `}),`作为本轮`,(0,s.jsx)(`strong`,{children:`最后一个动作`}),`调用——工作目录即`,(0,s.jsx)(`strong`,{children:`主题`}),`、主题拥有任务队列, 同目录共用队列、不同目录互不串,任务可在队列里堆积;命令阻塞并自动打开浏览器弹窗, 用户回填后解除阻塞、返回新任务;超时未回填则返回 `,(0,s.jsx)(`code`,{children:`status:"timeout"`}),`,agent 收尾结束本轮。`]})}),(0,s.jsxs)(`div`,{className:`card`,style:{padding:`10px 14px`,display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,s.jsx)(`span`,{style:{fontWeight:700},children:`等待超时`}),(0,s.jsxs)(`select`,{value:_,disabled:y,onChange:e=>V(e.target.value),style:{font:`inherit`,padding:`5px 8px`},children:[(0,s.jsx)(`option`,{value:60,children:`1 分钟`}),(0,s.jsx)(`option`,{value:120,children:`2 分钟`}),(0,s.jsx)(`option`,{value:180,children:`3 分钟(推荐)`}),(0,s.jsx)(`option`,{value:240,children:`4 分钟`}),(0,s.jsx)(`option`,{value:300,children:`5 分钟`}),(0,s.jsx)(`option`,{value:600,children:`10 分钟(最大)`})]}),(0,s.jsx)(`span`,{className:`muted`,style:{fontSize:12},children:`agent wait 未带 --timeout 时使用此值;推荐 3 分钟、最大 10 分钟。`})]}),(0,s.jsxs)(`div`,{className:`colhead`,children:[(0,s.jsx)(`input`,{type:`checkbox`,checked:G,onChange:K,disabled:!B.length,title:`全选 / 取消全选`,style:{margin:0}}),(0,s.jsx)(`h3`,{children:`主题总览(按工作目录)`}),(0,s.jsx)(`span`,{className:`muted`,children:c?`${B.length} 个 · 等待中 ${c.waiting}`:``}),(0,s.jsxs)(`span`,{style:{marginLeft:`auto`,display:`flex`,gap:8},children:[(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:ne,disabled:!F.size||L,title:`删除勾选的主题(含其全部任务)`,children:L?`删除中…`:`批量删除${F.size?` (${F.size})`:``}`}),(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:H,disabled:x,title:`清理旧模型无目录主题与空主题(等待中一律保留)`,children:x?`清理中…`:`清理旧数据`})]})]}),(0,s.jsx)(`div`,{style:{display:`flex`,gap:10,flexWrap:`wrap`,marginBottom:14},children:B.length?B.map(e=>{let t=e.key===d;return(0,s.jsxs)(`div`,{onClick:()=>f(e.key),className:`card`,style:{textAlign:`left`,width:270,padding:`10px 12px`,cursor:`pointer`,border:t?`1px solid var(--ink,#14161a)`:`1px solid transparent`,boxShadow:t?`0 0 0 2px rgba(20,22,26,.12)`:`0 1px 2px rgba(20,22,26,.06), 0 6px 16px rgba(20,22,26,.05)`},children:[(0,s.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:[(0,s.jsx)(`input`,{type:`checkbox`,checked:F.has(e.key),onChange:()=>W(e.key),onClick:e=>e.stopPropagation(),title:`选择以批量删除`,style:{margin:`3px 0 0`}}),(0,s.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,s.jsx)(`div`,{style:{fontWeight:700,marginBottom:2},children:e.name||`(未命名)`}),(0,s.jsx)(`div`,{className:`mono muted`,title:e.cwd,style:{fontSize:11,wordBreak:`break-all`,marginBottom:6,minHeight:15},children:e.cwd||`(旧数据,无目录)`})]})]}),e.summary&&(0,s.jsxs)(`div`,{className:`muted`,style:{fontSize:11,whiteSpace:`pre-wrap`,marginBottom:6},children:[`现状:`,e.summary]}),(0,s.jsxs)(`div`,{style:{display:`flex`,gap:6,alignItems:`center`},children:[e.waiting?(0,s.jsx)(`span`,{className:`tag strong`,children:l(e.waitingUntil)}):(0,s.jsx)(`span`,{className:`tag`,children:`已结束`}),(0,s.jsxs)(`span`,{className:`muted`,style:{fontSize:11},children:[`待领取 `,e.pending,`/`,e.total]})]}),(0,s.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginTop:8},onClick:e=>e.stopPropagation(),children:(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:()=>te(e),disabled:L,title:`删除整个主题(含全部任务)`,children:`删除主题`})})]},e.key)}):(0,s.jsx)(`div`,{className:`card muted`,style:{padding:`20px 16px`,width:`100%`,textAlign:`center`},children:`(暂无主题;agent 调用 sessiontask wait 后会出现在这里)`})}),U&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`div`,{className:`toolbar`,children:[(0,s.jsx)(`span`,{style:{fontWeight:700,maxWidth:240},title:U.cwd,children:U.name}),(0,s.jsx)(`span`,{className:`sep`}),(0,s.jsx)(`textarea`,{style:{flex:1,minWidth:240,minHeight:40,resize:`vertical`},spellCheck:`false`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),q())},placeholder:`向主题「${U.name}」的队列回填下一条任务(Enter 提交,Shift+Enter 换行)`}),(0,s.jsx)(`button`,{className:`btn`,onClick:q,disabled:h,children:h?`提交中…`:`回填新任务`})]}),(0,s.jsxs)(`div`,{className:`colhead`,children:[(0,s.jsx)(`h3`,{children:`该主题的任务队列`}),(0,s.jsxs)(`span`,{className:`muted`,children:[`待领取 `,U.pending,` · 共 `,U.total,` 条`]}),(0,s.jsx)(`span`,{className:`muted`,style:{fontSize:12,marginLeft:`auto`},children:`拖拽待领取行(或用「提前/置后」)调整领取优先级`})]}),(0,s.jsx)(`div`,{className:`card`,style:{padding:4},children:(0,s.jsxs)(`table`,{children:[(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{style:{width:34}}),(0,s.jsx)(`th`,{style:{width:56},children:`#`}),(0,s.jsx)(`th`,{children:`任务`}),(0,s.jsx)(`th`,{style:{width:80},children:`状态`}),(0,s.jsx)(`th`,{style:{width:160},children:`时间`}),(0,s.jsx)(`th`,{style:{width:150},children:`操作`})]})}),(0,s.jsx)(`tbody`,{children:X.length?X.map(e=>{let t=e.status!==`consumed`,n=k===e.id,r=j&&j.id===e.id;return(0,s.jsxs)(`tr`,{draggable:t&&C!==e.id,onDragStart:t=>{A(e.id),t.dataTransfer.effectAllowed=`move`;try{t.dataTransfer.setData(`text/plain`,String(e.id))}catch{}},onDragOver:t=>ie(t,e),onDrop:t=>ae(t,e),onDragEnd:()=>{A(null),M(null)},style:{cursor:t&&C!==e.id?`grab`:`default`,opacity:n?.4:1,boxShadow:r?j.pos===`top`?`inset 0 2px 0 var(--ink,#14161a)`:`inset 0 -2px 0 var(--ink,#14161a)`:`none`,background:r?`rgba(20,22,26,.04)`:void 0},children:[(0,s.jsx)(`td`,{className:`mono muted`,title:`按住拖拽调整优先级`,style:{textAlign:`center`,userSelect:`none`},children:t?`⠿`:``}),(0,s.jsxs)(`td`,{className:`mono`,children:[`#`,e.id]}),(0,s.jsx)(`td`,{style:{whiteSpace:`pre-wrap`},children:C===e.id?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`textarea`,{value:T,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),Y()),e.key===`Escape`&&J()},spellCheck:`false`,autoFocus:!0,style:{width:`100%`,minHeight:60,resize:`vertical`}}),(0,s.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:6},children:[(0,s.jsx)(`button`,{className:`btn small`,onClick:Y,disabled:D,children:D?`保存中…`:`保存`}),(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:J,disabled:D,children:`取消`}),(0,s.jsx)(`span`,{className:`muted`,style:{fontSize:11,alignSelf:`center`},children:`Ctrl+Enter 保存 · Esc 取消`})]})]}):(0,s.jsxs)(s.Fragment,{children:[e.text,e.roundSummary&&(0,s.jsxs)(`div`,{className:`muted`,style:{fontSize:11,marginTop:4,paddingTop:4,borderTop:`1px dashed var(--line,#e6e8eb)`,whiteSpace:`pre-wrap`},title:`该任务所回应的 agent 上一轮完成总结`,children:[`上一轮完成:`,e.roundSummary]})]})}),(0,s.jsx)(`td`,{children:e.status===`consumed`?(0,s.jsx)(`span`,{className:`tag strong`,children:`已领取`}):(0,s.jsx)(`span`,{className:`tag`,children:`待领取`})}),(0,s.jsx)(`td`,{className:`mono`,children:e.consumedAt||e.createdAt}),(0,s.jsxs)(`td`,{className:`ops`,children:[t&&C!==e.id&&(()=>{let t=Z.findIndex(t=>t.id===e.id);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:()=>re(e),children:`编辑`}),(0,s.jsx)(`button`,{className:`btn small ghost`,title:`提高优先级(更早被领取)`,disabled:N||t<=0,onClick:()=>$(e,`up`),children:`提前`}),(0,s.jsx)(`button`,{className:`btn small ghost`,title:`降低优先级(更晚被领取)`,disabled:N||t>=Z.length-1,onClick:()=>$(e,`down`),children:`置后`})]})})(),(0,s.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ee(e.id),children:`删除`})]})]},e.id)}):(0,s.jsx)(`tr`,{children:(0,s.jsx)(`td`,{colSpan:`6`,className:`muted`,style:{textAlign:`center`,padding:`22px 0`},children:`(暂无任务,在上方回填第一条)`})})})]})})]}),(0,s.jsx)(a,{module:`sessiontask`})]})}export{u as default};