@michengai/dsh-automation 1.0.0 → 1.0.1
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/CHANGELOG.md +8 -0
- package/CHANGELOG.zh-CN.md +8 -0
- package/lib/client.js +23 -9
- package/lib/client.js.map +2 -2
- package/lib/types/client/locales.d.ts +2 -0
- package/lib/types/client/schedule-overview.d.ts +6 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
window.__ModuleLoader__.load({ id: "@michengai/dsh-automation", factory: (require) => {
|
|
2
2
|
var module = { exports: {} }; var exports = module.exports;
|
|
3
|
-
"use strict";var Jo=Object.create;var sn=Object.defineProperty;var Yo=Object.getOwnPropertyDescriptor;var Qo=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty;var tr=(e,n)=>{for(var t in n)sn(e,t,{get:n[t],enumerable:!0})},bt=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Qo(n))!nr.call(e,r)&&r!==t&&sn(e,r,{get:()=>n[r],enumerable:!(s=Yo(n,r))||s.enumerable});return e};var on=(e,n,t)=>(t=e!=null?Jo(er(e)):{},bt(n||!e||!e.__esModule?sn(t,"default",{value:e,enumerable:!0}):t,e)),sr=e=>bt(sn({},"__esModule",{value:!0}),e);var yi={};tr(yi,{apply:()=>fi,inject:()=>ai,name:()=>ii});module.exports=sr(yi);var Fe=require("react");var Y=require("react");function wt(e,n){return n(`run.trigger.${e}`)}var de=class extends Error{constructor(t){super(t);this.key=t}},or=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function dn(e){return`/${or.test(e.name)?e.name:e.id}`}function rr(e,n,t){let s=n.startsWith("/")?n:`/${n}`,r=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(^|\\s)${r}(?=\\s|$)`).test(e))return{text:e,caret:Math.min(Math.max(t,0),e.length)};let i=Math.min(Math.max(t,0),e.length),o=e.slice(0,i),a=e.slice(i),c=`${o.length>0&&!/\s$/.test(o)?" ":""}${s} `;return{text:o+c+a,caret:o.length+c.length}}function Un(e,n){let t=Math.min(Math.max(n,0),e.length),s=/(?:^|\s)\/([^\s/]*)$/.exec(e.slice(0,t));if(s===null)return;let r=s[1]??"";return{start:t-r.length-1,query:r}}function St(e,n){let t=n.trim().toLowerCase();return t===""?[...e]:e.filter(s=>s.id.toLowerCase().includes(t)||s.name.toLowerCase().includes(t))}function kt(e,n,t){let s=Un(e,n),r=t.startsWith("/")?t:`/${t}`;return s===void 0?rr(e,r,n):{text:`${e.slice(0,s.start)}${r} ${e.slice(n)}`,caret:s.start+r.length+1}}function xt(e,n){let t=new Set(n.map(o=>dn(o).slice(1))),s=[],r=/(^|\s)(\/[a-z0-9]+(?:-[a-z0-9]+)*)(?=\s|$)/gi,i=0;for(let o of e.matchAll(r)){let a=o[1]??"",l=o[2]??"",c=(o.index??0)+a.length;t.has(l.slice(1))&&(c>i&&s.push({kind:"text",text:e.slice(i,c)}),s.push({kind:"skill",text:l}),i=c+l.length)}return(i<e.length||s.length===0)&&s.push({kind:"text",text:e.slice(i)}),s}function At(e=new Date){let n=new Date(e.getTime()+36e5);n.setMinutes(0,0,0);let t=n.getTimezoneOffset()*6e4;return new Date(n.getTime()-t).toISOString().slice(0,16)}function Bn(e=new Date,n=[],t,s=""){return{name:"",prompt:"",scheduleKind:"daily",onceAt:At(e),everyMinutes:"60",maxConcurrentRuns:"1",intervalAnchor:"",time:"09:00",weekdays:[1,2,3,4,5],hourlyMinute:"00",monthDay:"1",customDays:"2",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone||"Asia/Shanghai",permission:s,workspaceId:n[0]?.id??"",modelKey:t==null?"default":`${t.provider}::${t.model}`,reasoningEffort:t?.reasoning?.defaultEffort??"none",skills:[]}}function Tt(e,n,t,s=new Date,r={}){let i=Number(e.maxConcurrentRuns);if(!Number.isSafeInteger(i)||i<1)throw new de("form.error.maxConcurrentRuns");let o=e.name.trim(),a=e.prompt.trim();if(o==="")throw new de("form.error.name");if(a==="")throw new de("form.error.prompt");let l=n.find(m=>m.id===e.workspaceId);if(l===void 0)throw new de("form.error.workspace");let c;switch(e.scheduleKind){case"once":{let m=new Date(e.onceAt);if(!Number.isFinite(m.getTime())||r.allowPastOnce!==!0&&m.getTime()<=s.getTime())throw new de("form.error.once");c={kind:"once",at:m.toISOString(),timeZone:e.timeZone};break}case"interval":{let m=Number(e.everyMinutes);if(!Number.isInteger(m)||m<1||m>43200)throw new de("form.error.interval");c={kind:"interval",everyMinutes:m,anchor:e.intervalAnchor.trim()||s.toISOString(),timeZone:e.timeZone};break}case"daily":c={kind:"daily",time:e.time,timeZone:e.timeZone};break;case"weekly":if(e.weekdays.length===0)throw new de("form.error.weekdays");c={kind:"weekly",time:e.time,weekdays:[...e.weekdays].sort((m,x)=>m-x),timeZone:e.timeZone};break;case"hourly":{let m=Number(e.hourlyMinute);if(!Number.isInteger(m)||m<0||m>59)throw new de("form.error.interval");c={kind:"hourly",minute:m,timeZone:e.timeZone};break}case"monthly":{let m=Number(e.monthDay);if(!Number.isInteger(m)||m<1||m>31)throw new de("form.error.interval");c={kind:"monthly",day:m,time:e.time,timeZone:e.timeZone};break}case"custom":{let m=Number(e.customDays);if(!Number.isInteger(m)||m<1)throw new de("form.error.interval");c={kind:"custom",everyDays:m,time:e.time,timeZone:e.timeZone};break}}let g=t.find(m=>`${m.provider}::${m.model}`===e.modelKey);return{name:o,prompt:a,schedule:c,timeZone:e.timeZone,permission:e.permission,maxConcurrentRuns:i,workspaceId:l.id,cwd:l.path,...g===void 0?{provider:null,model:null}:{provider:g.provider,model:g.model},reasoningEffort:e.reasoningEffort==="none"?null:e.reasoningEffort}}function It(e,n,t){let s=Date.parse(e);if(!Number.isFinite(s))return e;let r=Math.round((s-n.getTime())/6e4),i=Math.abs(r);if(i<1)return t("time.now");let o=r>0;if(i<60)return t(o?"time.inMinute":"time.minuteAgo",{count:i});let a=Math.round(i/60);if(a<24)return t(o?"time.inHour":"time.hourAgo",{count:a});let l=Math.round(a/24);return t(o?"time.inDay":"time.dayAgo",{count:l})}function ln(e,n){switch(e.kind){case"once":return n("schedule.onceAt",{time:new Date(e.at).toLocaleString()});case"interval":return n("schedule.everyMinutes",{count:e.everyMinutes});case"daily":return n("schedule.dailyAt",{time:e.time});case"weekly":{let t=e.weekdays.map(s=>n(`day.${s}`)).join("\u3001");return n("schedule.weeklyAt",{days:t,time:e.time})}case"hourly":return n("schedule.hourlyAt",{minute:String(e.minute).padStart(2,"0")});case"monthly":return n("schedule.monthlyAt",{day:e.day,time:e.time});case"custom":return n("schedule.customAt",{count:e.everyDays,time:e.time})}}function cn(e,n,t){let s=Date.parse(e)-n.getTime();if(!Number.isFinite(s)||s<=0)return t("time.now");let r=Math.max(1,Math.ceil(s/6e4));if(r<60)return t("time.withinMinute",{count:r});let i=Math.ceil(r/60);return i<24?t("time.withinHour",{count:i}):t("time.withinDay",{count:Math.ceil(i/24)})}function Ct(e,n){if(e===void 0||n===void 0)return;let t=(Date.parse(n)-Date.parse(e))/1e3;if(!(!Number.isFinite(t)||t<0))return`${t.toFixed(1)}s`}function Nt(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}var Rt=["succeeded","failed","interrupted","running","queued","skipped","cancelled"];function rn(e){let n=Date.parse(e);return Number.isFinite(n)?n:0}function un(e,n,t){let s=t==="asc"?1:-1;return e.slice().sort((r,i)=>{if(n==="planned"){let a=r.nextRunAt,l=i.nextRunAt;if(a===void 0||l===void 0)return a===void 0&&l===void 0?r.name.localeCompare(i.name)||r.id.localeCompare(i.id):a===void 0?1:-1;let c=rn(a)-rn(l);return c!==0?c*s:r.name.localeCompare(i.name)||r.id.localeCompare(i.id)}let o=rn(r.createdAt)-rn(i.createdAt);return o!==0?o*s:r.id.localeCompare(i.id)})}var pn="dsh-automation.sort-default.settings",mn="dsh-automation.sort-default.overview";function Ce(e,n){if(e!==void 0)try{let t=e.getItem(n);if(t===null)return;let s=JSON.parse(t);return s.key!=="created"&&s.key!=="planned"||s.direction!=="asc"&&s.direction!=="desc"?void 0:{key:s.key,direction:s.direction}}catch{return}}function Et(e,n,t,s){e.setItem(n,JSON.stringify({key:t,direction:s}))}function Mt(e,n,t,s){let r=new Map;for(let i of e){let o=new Date(i.finishedAt??i.startedAt??i.scheduledFor);if(Number.isNaN(o.getTime()))continue;let a;if(n==="month")a=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}`;else if(n==="week"){let c=ir(o);a=an(c)}else a=an(o);let l=r.get(a)??[];l.push(i),r.set(a,l)}return[...r.entries()].map(([i,o])=>({key:i,label:o[0]===void 0?i:n==="month"?s("history.month",{month:i.replace("-","/")}):n==="week"?s("history.week",{date:i.slice(5).replace("-","/")}):i===an(t)?s("history.today"):i===an(new Date(t.getTime()-864e5))?s("history.yesterday"):s("history.date",{date:i.slice(5).replace("-","/")}),items:o}))}function an(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function ir(e){let n=new Date(e),t=n.getDay(),s=t===0?6:t-1;return n.setHours(0,0,0,0),n.setDate(n.getDate()-s),n}function Lt(e,n=[],t,s=e.permission){let r=Bn(new Date,n,t,s),i=e.schedule,o=e.provider&&e.model?`${e.provider}::${e.model}`:"default",a={...r,name:e.name,prompt:e.prompt,permission:e.permission,maxConcurrentRuns:String(e.maxConcurrentRuns??1),workspaceId:e.workspaceId??r.workspaceId,modelKey:o,reasoningEffort:e.reasoningEffort??"none",timeZone:e.timeZone||i.timeZone||r.timeZone};switch(i.kind){case"once":return{...a,scheduleKind:"once",onceAt:ar(i.at)};case"interval":return{...a,scheduleKind:"interval",everyMinutes:String(i.everyMinutes),intervalAnchor:i.anchor??""};case"hourly":return{...a,scheduleKind:"hourly",hourlyMinute:String(i.minute).padStart(2,"0")};case"daily":return{...a,scheduleKind:"daily",time:i.time};case"weekly":return{...a,scheduleKind:"weekly",time:i.time,weekdays:[...i.weekdays]};case"monthly":return{...a,scheduleKind:"monthly",time:i.time,monthDay:String(i.day)};case"custom":return{...a,scheduleKind:"custom",time:i.time,customDays:String(i.everyDays)}}}function ar(e){let n=new Date(e);if(Number.isNaN(n.getTime()))return At();let t=n.getTimezoneOffset()*6e4;return new Date(n.getTime()-t).toISOString().slice(0,16)}var Ke=class extends Error{code="workspace/picker-unavailable";constructor(){super("workspace picker unavailable"),this.name="WorkspacePickerUnavailableError"}};function Le(e,n){if(!(e===null||typeof e!="object"&&typeof e!="function"))return Reflect.get(e,n)}function fn(e,n){if(e===null||typeof e!="object")return;let t;try{t=Reflect.get(e,"reflect")}catch{t=void 0}let s=Le(t,"get");if(typeof s=="function")try{let i=s.call(t,n);if(i!==void 0)return i}catch{}let r=Le(e,"get");if(typeof r=="function")try{let i=r.call(e,n);if(i!==void 0)return i}catch{return}if(typeof s!="function")try{return Le(e,n)}catch{return}}function Ot(e){if(typeof e=="string"&&e.trim()!=="")return e;if(e===null||typeof e!="object"||Reflect.get(e,"canceled")===!0)return;let n=Reflect.get(e,"path");if(typeof n=="string"&&n.trim()!=="")return n;let t=Reflect.get(e,"filePaths"),s=Array.isArray(t)?t[0]:void 0;return typeof s=="string"&&s.trim()!==""?s:void 0}async function Pt(e){let n=Le(e,"pickDirectory");if(typeof n=="function")return{picked:Ot(await n.call(e))}}async function $n(e,n){let t=fn(e,"workspaces"),s=Le(t,"create");if(typeof s!="function")return!1;try{return await s.call(t,{path:n}),!0}catch{return!1}}async function Vn(e){let n;try{n=Reflect.get(globalThis,"__DSH_DIRECTORY_PICKER__")}catch{n=void 0}let t=Le(n,"pick");if(typeof t=="function")return Ot(await t.call(n));for(let s of["uiWorkspace","dialog","workspaces"]){let r=await Pt(fn(e,s));if(r!==void 0)return r.picked}try{let s=await Pt(Le(e,"workspaces"));if(s!==void 0)return s.picked}catch{}throw new Ke}var dr={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"},Dt=new Map;function lr(e){let n=Dt.get(e);if(n!==void 0)return n;let t=new Intl.DateTimeFormat("en-CA",{...dr,timeZone:e});return Dt.set(e,t),t}function qe(e,n){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;if(n===void 0){let s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,r=`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`;return`${s} ${r}`}try{let s=lr(n).formatToParts(t),r=g=>s.find(m=>m.type===g)?.value,[i,o,a,l,c]=["year","month","day","hour","minute"].map(g=>r(g));return[i,o,a,l,c].some(g=>g===void 0)?e:`${i}-${o}-${a} ${l}:${c}`}catch{return e}}var We="dsh-automation-session-",qn="dsh-automation.sidebar-tab";function hn(e,n){let t=new Map,s=new Map;for(let o of e)t.set(o.id,o.name),o.timeZone!==void 0&&s.set(o.id,o.timeZone);for(let o of n){let a=(o.automationName||"").trim();a!==""&&a!==o.automationId&&!t.has(o.automationId)&&t.set(o.automationId,a)}let r=[],i=new Set;for(let o of e)i.has(o.id)||(r.push(o.id),i.add(o.id));for(let o of n)o.sessionId===void 0||o.sessionId===""||i.has(o.automationId)||(r.push(o.automationId),i.add(o.automationId));return r.map(o=>{let a=t.get(o)??o;return{id:o,name:a,sessions:n.filter(l=>l.automationId===o&&l.sessionId!==void 0&&l.sessionId!=="").slice().sort((l,c)=>Date.parse(c.startedAt??c.scheduledFor)-Date.parse(l.startedAt??l.scheduledFor)).map(l=>({id:l.sessionId,running:l.status==="running"||l.status==="queued",label:qe(l.startedAt??l.scheduledFor,s.get(o))+" - "+a}))}}).filter(o=>o.sessions.length>0)}function gn(e){return e==="active"?"pause":"resume"}function Ut(e){return e.map(n=>({id:n.id,name:n.name,status:n.status,...n.nextRunAt===void 0?{}:{nextRunAt:n.nextRunAt}}))}function Bt(e,n,t){if(e===void 0||e==="")return!1;let s=n.has(e);return t==="only"?s:t==="show"?!0:!s}function yn(e,n){return e==null||e===""||!e.startsWith(We)?!1:!(n??[]).some(t=>t.sessionId===e)}function $t(e){let n=new Set;for(let t of e??[]){let s=t.sessionId;typeof s=="string"&&s!==""&&n.add(s)}return n}var cr=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/;function jn(e,n,t=new Set){if(e.startsWith(We)||t.has(e))return!0;let s=String(n?.title??n?.displayTitle??"");return cr.test(s)}function Ft(e,n=new Set){if(e===void 0||e.blank===!0||e.origin==="im"||e.origin==="subagent")return!1;let t=e.id??"";return!(t.startsWith("im:")||jn(t,e,n))}function Vt(e,n,t,s=new Set){let r=e.byId??{},i=new Set(n?.archivedSessionIds??[]),o=new Set,a=[];for(let c of n?.items??[]){let g=(c.sessionIds??[]).map(m=>r[m]).filter(m=>m!==void 0&&m.id!==void 0&&Ft(m,s)&&!i.has(m.id));for(let m of g)m.id!==void 0&&o.add(m.id);g.length>0&&a.push({id:c.workspaceId??c.id??c.path??c.title??"workspace",label:c.title||c.path||t,sessions:g})}let l=(e.ids??[]).map(c=>r[c]).filter(c=>c!==void 0&&c.id!==void 0&&!o.has(c.id)&&Ft(c,s)&&!i.has(c.id));return l.length>0&&a.push({id:"",label:t,sessions:l}),a}function Kt(e){return e==="channels"||e==="schedule"||e==="tasks"?e:"tasks"}function qt(e,n){let t=e??"",s=n??"";return s!==""&&t!==s}function jt(e){let n=["tasks"];for(let t of e.extraTabIds)t===""||t==="tasks"||t==="schedule"||n.includes(t)||n.push(t);return e.channelsReady&&!n.includes("channels")&&n.push("channels"),n.push("schedule"),n}function Zt(e){return e.extraTabIds.includes(e.tab)?e.tab:e.tab==="channels"&&!e.channelsReady?"tasks":e.tab}function Xt(e,n){if(!(e==null||e===""))return(n!==void 0?n.has(e):e.startsWith(We))?"schedule":e.startsWith("im:")?"channels":"tasks"}function ur(e){return/dsh-codex-ui|michengai-codex-ui|michengai\.codexUi|codex-ui/i.test(String(e??""))}function pr(e){let n=e;return String(n?.options?.locale??n?.options?.id??n?.options?.name??n?.options?.registrant??n?.component?.displayName??n?.component?.name??n?.id??n?.name??"")}function Jt(e){return(e??[]).some(n=>ur(pr(n)))}var Ht=new WeakMap,Wt=new WeakMap;function Yt(e){return e.size===0?"":[...e].sort().join("\0")}function Qt(e,n=new Set){let t=e??{ids:[],byId:{}},s=Yt(n);if(typeof t=="object"&&t!==null){let a=Ht.get(t);if(a!==void 0&&a.key===s)return a.result}let r=(t.ids??[]).filter(a=>{let l=String(a);return!l.startsWith("im:")&&!jn(l,t.byId?.[l],n)}),o=r.length===(t.ids??[]).length?t:{...t,ids:r,byId:Object.fromEntries(r.map(a=>[a,t.byId?.[a]]).filter(a=>a[1]!==void 0))};return typeof t=="object"&&t!==null&&Ht.set(t,{key:s,result:o}),o}function je(e){let n=e?.byId??{};for(let[t,s]of Object.entries(n))if((s?.retainedBy?.mainView??0)>0){let r=s.id?.trim();return r!==void 0&&r!==""?r:t}return null}function mr(e){if(e===null||typeof e!="object")return;let n=e.openSession;if(typeof n=="function")return{openSession:t=>{n.call(e,t)}}}function es(e){let n=mr(fn(e,"uiWorkspace"));return{...n===void 0?{}:{uiWorkspace:n}}}function ns(e){return typeof e.uiWorkspace?.openSession=="function"}function ts(e,n){if(typeof e.uiWorkspace?.openSession=="function"){e.uiWorkspace.openSession(n);return}throw new Error("no client session opener")}function _t(e,n,t){if(e==="")return!1;let s=e.startsWith(We)||e.startsWith("im:")?[n,t]:[t,n];for(let r of s)if(typeof r=="function")try{return r(e),!0}catch{}return!1}async function ss(e){let n=e.id.trim();return n===""?!1:(await e.adopt?.(n).catch(()=>{}),!(e.listed?.(n)===!0)&&e.refresh!==void 0&&await e.refresh().catch(()=>{}),_t(n,e.openRuntime,e.openHost)?!0:(e.refresh!==void 0&&await e.refresh().catch(()=>{}),_t(n,e.openRuntime,e.openHost)))}function fr(e,n=new Set){return e.startsWith("im:")||jn(e,void 0,n)}function os(e,n=new Set){let t=e??{items:[],archivedSessionIds:[]},s=Yt(n);if(typeof t=="object"&&t!==null){let a=Wt.get(t);if(a!==void 0&&a.key===s)return a.result}let r=!1,i=(t.items??[]).map(a=>{let l=(a.sessionIds??[]).filter(c=>!fr(String(c),n));return l.length!==(a.sessionIds??[]).length?(r=!0,{...a,sessionIds:l}):a}),o=r?{...t,items:i}:t;return typeof t=="object"&&t!==null&&Wt.set(t,{key:s,result:o}),o}function rs(e){return e==null||typeof e!="function"&&typeof e!="object"?{}:e}function hr(e){return rs(e).__dshAutomationWrapped===!0}function is(e){let n=new Set,t=e;for(;t!=null&&!n.has(t);){n.add(t);let s=rs(t),r=s.__dshAutomationOriginal??s.__imConnectOriginal;if(r!==void 0&&r!==t){t=r;continue}return s.__dshAutomationWrapped===!0||s.__imConnectWrapped===!0?void 0:t}}function gr(e){let n=e,t=String(n?.options?.id??""),s=String(n?.component?.displayName??n?.component?.name??"");return t==="dsh-automation-native-switcher"||t==="dsh-automation-wrap-bump"||s==="AutomationNativeWorkspaceShell"||s==="AutomationWrapBump"||hr(n?.component)}function as(e){for(let n of e)if(n?.component!==void 0&&!gr(n))return n}function He(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function zt(e,n){let t=He(e),s,r=-1;for(let i of n){let o=He(i);o.length>r&&t!==o&&t.startsWith(`${o}/`)&&(s=i,r=o.length)}return s}function ds(e,n,t){let s=new Map;for(let u of n)for(let y of u.sessionIds??[])s.set(y,u);let r=new Map,i=[];for(let u of e){let y=u.id===void 0?void 0:s.get(u.id),h=y?.workspaceId??y?.id??y?.path;if(y===void 0||h===void 0||h===""){i.push(u);continue}let S=r.get(h)??[];S.push(u),r.set(h,S)}let o=new Map;for(let u of n)u.path!==void 0&&u.path!==""&&o.set(He(u.path),u);let a=new Map;for(let u of n){let y=u.workspaceId??u.id??u.path;if(y===void 0||y===""||!r.has(y))continue;a.set(y,u);let h=u.path,S=new Set;for(;h!==void 0&&h!==""&&!S.has(h);){S.add(h);let N=zt(h,[...o.keys()]);if(N===void 0)break;let M=o.get(He(N)),_=M?.workspaceId??M?.id??M?.path;if(M===void 0||_===void 0||_==="")break;a.set(_,M),h=M.path}}let l=[...a.values()],c=l.map(u=>u.path).filter(u=>u!==void 0&&u!==""),g=u=>u.workspaceId??u.id??u.path??"",m=new Map,x=[];for(let u of l){let y=u.path===void 0?void 0:zt(u.path,c),h=y===void 0?void 0:l.find(N=>N.path!==void 0&&He(N.path)===He(y)),S=h===void 0?void 0:g(h);if(h===void 0||S===void 0||S==="")x.push(u);else{let N=m.get(S)??[];N.push(u),m.set(S,N)}}let A=(u,y)=>(u.title||u.path||"").localeCompare(y.title||y.path||""),f=[],p=(u,y)=>{let h=g(u),S=r.get(h)??[];f.push({id:h,name:u.title||u.path||t,depth:y,keep:S.length===0,sessions:S});for(let N of(m.get(h)??[]).sort(A))p(N,y+1)};for(let u of x.sort(A))p(u,0);return i.length>0&&f.push({id:"",name:t,depth:0,sessions:i}),f}function ls(e,n,t,s="workspace"){let r=n.trim().toLocaleLowerCase(),i=e.map(o=>{if(r===""||o.name.toLocaleLowerCase().includes(r))return o;let a=o.sessions.filter(l=>`${l.title??""} ${l.label??""}`.toLocaleLowerCase().includes(r));return{...o,sessions:a}}).filter(o=>o.sessions.length>0||r===""&&o.keep===!0||r!==""&&o.name.toLocaleLowerCase().includes(r));if(s==="list"){let o=i.flatMap(a=>[...a.sessions]);return t==="time"&&o.sort((a,l)=>Kn(l)-Kn(a)),o.length===0?[]:[{...i[0],name:"",sessions:o}]}return s==="workspace-tree"||t==="manual"?i:[...i].sort((o,a)=>Gt(a)-Gt(o))}function Kn(e){let n=Date.parse(e.updatedAt??"");return Number.isFinite(n)?n:0}function Gt(e){let n=0;for(let t of e.sessions){let s=Kn(t);s>n&&(n=s)}return n}var te=require("react/jsx-runtime");function Ze({children:e,...n}){return(0,te.jsx)("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n,children:e})}function vn(e){return(0,te.jsx)(Ze,{...e,children:(0,te.jsx)("path",{d:"M12 5v14M5 12h14"})})}function cs(e){return(0,te.jsxs)(Ze,{...e,children:[(0,te.jsx)("path",{d:"M19 7v5h-5"}),(0,te.jsx)("path",{d:"M18.1 15.5A7.5 7.5 0 1 1 19 12"})]})}function us(e){return(0,te.jsxs)(Ze,{...e,children:[(0,te.jsx)("rect",{x:"4",y:"5.5",width:"16",height:"14",rx:"2"}),(0,te.jsx)("path",{d:"M8 3.8v3.4M16 3.8v3.4M4 9.5h16"})]})}function ps(e){return(0,te.jsxs)(Ze,{...e,children:[(0,te.jsx)("circle",{cx:"12",cy:"12",r:"8.25"}),(0,te.jsx)("path",{d:"M12 10.4V16"}),(0,te.jsx)("path",{d:"M12 7.6h.01"})]})}function ms(e){return(0,te.jsx)(Ze,{...e,children:(0,te.jsx)("path",{d:"M5.5 6.5h13v9.2H9.2L5.5 18.8V6.5Z"})})}function fs(e){return(0,te.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,"aria-hidden":"true",focusable:"false",...e,children:(0,te.jsx)("path",{fill:"currentColor",d:"M8 0a8 8 0 0 0-2.53 15.59c.4.074.547-.173.547-.385 0-.19-.007-.693-.01-1.36-2.226.484-2.695-1.073-2.695-1.073-.364-.924-.89-1.17-.89-1.17-.726-.496.055-.486.055-.486.803.056 1.225.824 1.225.824.714 1.223 1.872.87 2.328.665.072-.517.28-.87.508-1.07-1.777-.202-3.645-.888-3.645-3.956 0-.874.31-1.588.823-2.148-.083-.202-.357-1.017.078-2.12 0 0 .672-.215 2.2.82A7.65 7.65 0 0 1 8 4.8c.68.003 1.365.092 2.004.27 1.527-1.035 2.197-.82 2.197-.82.437 1.103.162 1.918.08 2.12.513.56.822 1.274.822 2.148 0 3.076-1.872 3.752-3.654 3.95.288.248.544.735.544 1.482 0 1.07-.01 1.932-.01 2.195 0 .214.144.463.55.384A8.001 8.001 0 0 0 8 0Z"})})}function hs(e){return(0,te.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...e,children:(0,te.jsx)("path",{d:"M9.5 2.5 13.5 6.5 6 14H2v-4z"})})}var Pe=require("react"),yr=on(require("@deepseek-ai/dsh-client-ui-primitives"),1);function bn(e,n){return function(s){return e(s)??n(s)}}function X(e,...n){for(let t of n){let s=e[t];if(typeof s=="function")return s}return function(){return null}}var J=yr;function vr(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 3h4v3H3V3Zm6 1h4M3 10h4v3H3v-3Zm6 1.5h4M7 4.5h2M7 11.5h2",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"}))}function br(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"}))}function wr(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 6.5h10v6H3v-6Zm1.2-2.5h7.6L13 6.5H3L4.2 4Zm2.3 5.2 1.3 1.3 2.6-2.6",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"}))}var Xe=X(J,"IconEllipsisOutlineRegular"),gs=X(J,"IconSettingsOutlineRegular"),_e=X(J,"IconArchiveOutlineRegular"),ys=X(J,"IconBranchOutlineRegular"),vs=X(J,"IconEditOutlineRegular"),Zn=X(J,"IconTrashOutlineRegular"),Ri=X(J,"IconCheckOutlineRegular"),Ei=X(J,"IconChevronDownOutlineRegular"),Mi=X(J,"IconListPenOutlineRegular"),bs=X(J,"IconSearchOutlineRegular"),ws=X(J,"IconCloseFillRegular"),wn=X(J,"IconSlidersTwoOutlineRegular"),Sn=X(J,"IconFolderCloseRegular"),Ss=X(J,"IconFolderOpenRegular"),ks=X(J,"IconTriangleRightFillRegular"),Xn=X(J,"IconUnarchiveOutlineRegular"),kn=bn(X(J,"IconWorkspaceTreeOutlineRegular"),vr),ze=bn(X(J,"IconFlatListOutlineRegular"),br),Li=X(J,"IconChevronsUpDownOutlineRegular"),Ne=X(J,"IconClockOutlineRegular"),xs=X(J,"IconCopyOutlineRegular"),As=X(J,"IconArchiveOffOutlineRegular"),Ts=bn(X(J,"IconArchiveCheckOutlineRegular"),wr);var ie=require("@deepseek-ai/dsh-client-ui-primitives");var Jn=on(require("react"),1),Is=require("@deepseek-ai/dsh-client-ui-primitives"),Yn={width:22,minWidth:22,height:22,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"var(--dsw-radius-sm, 8px)"},Cs=Jn.default.forwardRef(function(n,t){let{className:s,rows:r,...i}=n;return Jn.default.createElement("textarea",{...i,ref:t,className:["dsh-st-textarea",s].filter(Boolean).join(" "),rows:r||4})}),Ge=Is.Input;function xn(e,n){let t=e.target;if(!(t instanceof Element)||t.getAttribute("aria-hidden")!=="true")return;let s=t.parentElement?.querySelector('[role="dialog"]');!(s instanceof HTMLElement)||!s.classList.contains(n)||e.stopPropagation()}var le=on(require("react"),1),An=require("@deepseek-ai/dsh-client-ui-primitives");function Qn(e){return{id:e.value,label:e.label,...e.disabled!==void 0?{disabled:e.disabled}:{},...e.danger!==void 0?{danger:e.danger}:{}}}function fe(e){let[n,t]=le.useState(!1),s=le.useRef(null),r=e.options??[];le.useEffect(()=>{if(!n)return;let c=s.current?.getBoundingClientRect().width??0;return c>0&&document.documentElement.style.setProperty("--dsh-st-menu-width",`${Math.round(c)}px`),()=>{document.documentElement.style.removeProperty("--dsh-st-menu-width")}},[n]),le.useEffect(()=>{if(!n||typeof window>"u")return;let c=g=>{g.key==="Escape"&&(g.stopPropagation(),t(!1))};return window.addEventListener("keydown",c,!0),()=>{window.removeEventListener("keydown",c,!0)}},[n]);let i=le.useMemo(()=>e.groups!==void 0&&e.groups.length>0?e.groups.flatMap(c=>[{type:"label",id:`label-${c.id}`,text:c.label},...c.options.map(Qn)]):r.map(Qn),[r,e.groups]),o=e.footer?.map(Qn),a=r.find(c=>c.value===e.value)??e.groups?.flatMap(c=>[...c.options]).find(c=>c.value===e.value),l=a?a.label:e.placeholder??e.label??"";return le.createElement("div",{ref:s,className:["dsh-st-menu-select-wrap",e.compact===!0?"is-compact":"",e.className].filter(Boolean).join(" ")},le.createElement(An.Menu,{open:n,onClose:()=>{t(!1)},onSelect:c=>{if(e.footer?.some(g=>g.value===c)===!0){e.onFooter?.(c),t(!1);return}e.onChange(c),t(!1)},selectedId:e.value,align:"start",portal:!0,dense:!0,listClassName:["dsh-st-form-menu",e.listClassName].filter(Boolean).join(" "),...o!==void 0?{footer:o}:{},anchor:le.createElement(An.Button,{variant:"outline",...e.compact===!0?{size:"sm"}:{},role:"combobox","aria-label":e.label??(typeof l=="string"?l:a?.text)??e.placeholder??"","aria-expanded":n,disabled:e.disabled,className:["dsh-st-menu-select-trigger",n?"is-open":""].filter(Boolean).join(" "),onClick:()=>{e.disabled||t(c=>!c)}},le.createElement("span",{className:"dsh-st-menu-select-label"},l),le.createElement("svg",{className:"dsh-st-menu-select-arrow",viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",style:{marginLeft:4,transition:"transform 150ms ease",transform:n?"rotate(180deg)":"none"}},le.createElement("path",{d:"m4 6 4 4 4-4"}))),items:i}))}var pe=require("react");var Sr=new Map([["read-only",["permission.readOnly","Read Only"]],["workspace-write",["permission.workspaceWrite","Workspace Write"]],["danger-full-access",["permission.fullAccess","Full access"]]]);function Ns(e,n){let t=Sr.get(e.value);return t!==void 0&&(e.name===e.value||e.name===t[1])?n(t[0]):e.name||e.value}function Rs(e,n){return e!==n&&n==="danger-full-access"}var be=require("@deepseek-ai/dsh-client-ui-primitives");var b=require("react/jsx-runtime");function kr(e,n,t,s){if(e==="deepseek-account"){let r=t("provider.account");return r&&r!=="provider.account"?r:s("form.providerAccount")}return n}function xr(e,n){return(e==="deepseek-account"?0:e==="deepseek-official"?1:2)-(n==="deepseek-account"?0:n==="deepseek-official"?1:2)}function Ar(e){return(e.provider==="deepseek-account"||e.provider==="deepseek-official")&&e.model==="deepseek-flash"?(0,b.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,b.jsx)("span",{children:e.label}),(0,b.jsx)(be.Tag,{tone:"info",children:"1017"})]}):e.label}var Tr=[1,2,3,4,5,6,7],Ir=["once","interval","hourly","daily","weekly","monthly","custom"],Cr=Array.from({length:24},(e,n)=>String(n).padStart(2,"0")),Ls=Array.from({length:60},(e,n)=>String(n).padStart(2,"0"));function Ps({t:e,permissionT:n,modelT:t,busy:s,workspaces:r,models:i,modelFailures:o,defaultModel:a,skills:l,permissions:c,defaultPermission:g,draft:m,editing:x,onClose:A,onSubmit:f,onAddWorkspace:p}){let[u,y]=(0,pe.useState)(()=>({...Bn(new Date,r,a,g),...m})),[h,S]=(0,pe.useState)(),[N,M]=(0,pe.useState)(),[_,se]=(0,pe.useState)(!1),[re,z]=(0,pe.useState)(!1),[Q,V]=(0,pe.useState)(0),[F,G]=(0,pe.useState)(0),[W,ee]=(0,pe.useState)(),ce=(0,pe.useRef)(null),I=(0,pe.useRef)(0);(0,pe.useEffect)(()=>{let d=B=>{if(B.key==="Escape"&&document.querySelector('[role="menu"]')===null){if(B.preventDefault(),B.stopPropagation(),B.stopImmediatePropagation(),N!==void 0){se(!1),M(void 0);return}A()}},T=B=>{xn(B,"dsh-st-create-dialog")};return window.addEventListener("keydown",d,!0),document.addEventListener("click",T,!0),()=>{window.removeEventListener("keydown",d,!0),document.removeEventListener("click",T,!0)}},[N,A]);let R=d=>{y(T=>({...T,...d})),S(void 0)},H=r.some(d=>d.id===u.workspaceId),L=async()=>{if(!(p===void 0||re)){z(!0),S(void 0),document.activeElement instanceof HTMLElement&&document.activeElement.blur();try{let d=await p();d!==void 0&&R({workspaceId:d})}catch(d){d instanceof Ke?S(e("form.workspaceUnavailable")):d instanceof Error&&d.message!==""?S(d.message):S(e("form.addWorkspaceFailed"))}finally{z(!1)}}},ue=d=>{if(Rs(u.permission,d)){se(!1),M(d);return}R({permission:d})},he=async d=>{d?.preventDefault();try{await f(u)}catch(T){if(T instanceof de){S(e(T.key));return}S(T instanceof Error?T.message:e("error.action"))}},ae=u.onceAt.slice(0,10),oe=u.onceAt.slice(11,16)||"09:00",me=Nr(new Date),ge=i.find(d=>`${d.provider}::${d.model}`===u.modelKey)?.reasoning,Z=Un(u.prompt,Q),ne=Z===void 0||W===Z.query?[]:St(l,Z.query),ye=Math.min(F,Math.max(ne.length-1,0)),we=d=>{I.current=d,V(d)};(0,pe.useEffect)(()=>{let d=document.querySelector('.dsh-st-skill-menu [aria-selected="true"]');d instanceof HTMLElement&&d.scrollIntoView({block:"nearest"})},[ye,Z?.query]);let k=d=>{let T=kt(u.prompt,I.current,dn(d));R({prompt:T.text}),ee(void 0),queueMicrotask(()=>{let B=ce.current;B!=null&&(B.focus(),B.setSelectionRange(T.caret,T.caret),we(T.caret))})};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(be.Modal,{open:!0,className:"dsh-st-create-dialog",title:e(x===!0?"modal.edit":"modal.title"),closeLabel:e("form.cancel"),onClose:A,footer:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(be.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:s,onClick:A,children:e("form.cancel")}),(0,b.jsx)(be.Button,{variant:"primary",className:"dsh-st-modal-action",type:"submit",form:"dsh-st-create-form",disabled:s||re||!H,children:e("modal.save")})]}),children:(0,b.jsxs)("form",{id:"dsh-st-create-form",className:"dsh-st-form",onSubmit:d=>{he(d)},children:[(0,b.jsx)("p",{children:e("form.subtitle")}),(0,b.jsxs)("label",{className:"dsh-st-field",children:[e("form.name"),(0,b.jsx)(Ge,{value:u.name,placeholder:e("form.namePlaceholder"),onChange:d=>R({name:d.target.value})})]}),(0,b.jsxs)("div",{className:"dsh-st-plan-row",children:[(0,b.jsxs)("div",{className:"dsh-st-field",children:[e("form.planTime"),(0,b.jsxs)("div",{className:"dsh-st-inline",children:[(0,b.jsx)(fe,{value:u.scheduleKind,options:Ir.map(d=>({value:d,label:e(`form.${d}`)})),onChange:d=>R({scheduleKind:d})}),u.scheduleKind==="once"&&(0,b.jsx)(Ge,{type:"date",min:me,value:ae,onChange:d=>R({onceAt:Ms(`${d.target.value}T${oe}`)})}),(u.scheduleKind==="once"||u.scheduleKind==="daily"||u.scheduleKind==="weekly"||u.scheduleKind==="monthly")&&(0,b.jsx)(Es,{value:u.scheduleKind==="once"?oe:u.time,onChange:d=>{u.scheduleKind==="once"?R({onceAt:Ms(`${ae}T${d}`)}):R({time:d})}}),u.scheduleKind==="interval"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.every")}),(0,b.jsxs)("span",{className:"dsh-st-amount",children:[(0,b.jsx)(Ge,{type:"number",min:1,value:u.everyMinutes,onChange:d=>R({everyMinutes:d.target.value})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.minutes")})]})]}),u.scheduleKind==="hourly"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(fe,{value:u.hourlyMinute,options:Ls.map(d=>({value:d,label:d})),onChange:d=>R({hourlyMinute:d})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.minutesShort")})]}),u.scheduleKind==="monthly"&&(0,b.jsx)(fe,{value:u.monthDay,options:Array.from({length:31},(d,T)=>{let B=String(T+1);return{value:B,label:e("form.monthDay",{day:B})}}),onChange:d=>R({monthDay:d})}),u.scheduleKind==="custom"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.every")}),(0,b.jsxs)("span",{className:"dsh-st-amount",children:[(0,b.jsx)(Ge,{type:"number",min:1,value:u.customDays,onChange:d=>R({customDays:d.target.value})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.daysShort")})]}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.atTime")}),(0,b.jsx)(Es,{value:u.time,onChange:d=>R({time:d})})]})]}),u.scheduleKind==="interval"&&(0,b.jsx)("span",{className:"dsh-st-plan-hint",children:e("form.intervalHint")}),u.scheduleKind==="custom"&&(0,b.jsx)("span",{className:"dsh-st-plan-hint",children:e("form.customHint")})]}),(0,b.jsxs)("label",{className:"dsh-st-field dsh-st-concurrency",title:e("form.maxConcurrentRunsHint"),children:[e("form.maxConcurrentRuns"),(0,b.jsx)(Ge,{type:"number",min:1,step:1,value:u.maxConcurrentRuns,onChange:d=>R({maxConcurrentRuns:d.target.value})})]})]}),u.scheduleKind==="weekly"&&(0,b.jsx)("div",{className:"dsh-st-weekdays",children:Tr.map(d=>(0,b.jsx)(be.Checkbox,{checked:u.weekdays.includes(d),label:e(`day.${d}`),onChange:T=>R({weekdays:T?[...u.weekdays,d]:u.weekdays.filter(B=>B!==d)})},d))}),(0,b.jsxs)("div",{className:"dsh-st-settings",children:[(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldWorkspace")}),r.length===0?(0,b.jsxs)("div",{className:"dsh-st-workspace-empty",children:[(0,b.jsx)(be.Button,{variant:"primary",icon:(0,b.jsx)(vn,{width:14,height:14}),disabled:re,onClick:()=>{L()},children:e("form.addWorkspace")}),(0,b.jsx)("span",{className:"dsh-st-workspace-note",children:e("form.workspaceRequired")})]}):(0,b.jsx)(fe,{value:u.workspaceId,label:e("form.fieldWorkspace"),placeholder:e("form.workspace"),options:r.map(d=>({value:d.id,label:d.title})),footer:[{value:"add-workspace",label:e("form.addWorkspace"),disabled:re}],onFooter:()=>{L()},onChange:d=>R({workspaceId:d})})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldModel")}),(0,b.jsx)(fe,{value:u.modelKey,label:e("form.fieldModel"),groups:Array.from(i.reduce((d,T)=>{let B=kr(T.provider,T.providerLabel,t,e),Ie=d.get(T.provider)??{label:B,options:[]};return Ie.options.push({value:`${T.provider}::${T.model}`,label:Ar(T),text:T.label}),d.set(T.provider,Ie),d},new Map)).sort(([d],[T])=>xr(d,T)).map(([d,T])=>({id:d,label:T.label,options:T.options})),onChange:d=>{let T=i.find(B=>`${B.provider}::${B.model}`===d);R({modelKey:d,reasoningEffort:T?.reasoning?.defaultEffort??"none"})}})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldEffort")}),(0,b.jsx)(fe,{disabled:ge===void 0,value:ge===void 0?"":u.reasoningEffort,label:e("form.fieldEffort"),placeholder:t("effort.providerDefault"),options:ge===void 0?[]:[...ge.defaultEffort===void 0?[{value:"none",label:t("effort.providerDefault")}]:[],...ge.efforts.map(d=>({value:d.id,label:d.name}))],onChange:d=>R({reasoningEffort:d})})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldPermission")}),(0,b.jsx)(fe,{value:u.permission,options:c.map(d=>({value:d.value,label:Ns(d,e)})),onChange:d=>ue(d)})]})]}),(0,b.jsxs)("div",{className:"dsh-st-field",children:[(0,b.jsxs)("span",{className:"dsh-st-prompt-label",children:[e("form.prompt"),(0,b.jsx)("em",{children:e("form.slashHint")})]}),(0,b.jsxs)("div",{className:"dsh-st-prompt-anchor",children:[Z!==void 0&&W!==Z.query&&(0,b.jsx)("div",{className:"dsh-st-skill-menu",role:"listbox",children:ne.length===0?(0,b.jsx)("p",{children:e("form.slashEmpty")}):ne.map((d,T)=>(0,b.jsxs)("button",{type:"button",role:"option","aria-selected":T===ye,onMouseDown:B=>B.preventDefault(),onClick:()=>k(d),children:[(0,b.jsx)("span",{children:d.name}),(0,b.jsx)("code",{children:dn(d)})]},d.id))}),(0,b.jsxs)("div",{className:"dsh-st-prompt-card",children:[(0,b.jsx)("div",{className:"dsh-st-prompt-backdrop","aria-hidden":"true",children:xt(u.prompt,l).map((d,T)=>d.kind==="skill"?(0,b.jsx)("span",{className:"dsh-st-skill-token",children:d.text},T):(0,b.jsx)("span",{children:d.text},T))}),(0,b.jsx)(Cs,{ref:ce,spellCheck:!1,className:"dsh-st-prompt-input",value:u.prompt,placeholder:e("form.promptPlaceholder"),rows:4,onChange:d=>{we(d.target.selectionStart),R({prompt:d.target.value}),ee(void 0)},onSelect:d=>we(d.currentTarget.selectionStart),onScroll:d=>{let T=d.currentTarget.closest(".dsh-st-prompt-card")?.querySelector(".dsh-st-prompt-backdrop");T instanceof HTMLElement&&(T.scrollTop=d.currentTarget.scrollTop)},onKeyDown:d=>{if(Z!==void 0){if(d.key==="Escape"){d.preventDefault(),ee(Z.query);return}if(ne.length!==0){if(d.key==="ArrowDown")d.preventDefault(),G(T=>(Math.min(T,ne.length-1)+1)%ne.length);else if(d.key==="ArrowUp")d.preventDefault(),G(T=>(Math.min(T,ne.length-1)+ne.length-1)%ne.length);else if(d.key==="Enter"||d.key==="Tab"){d.preventDefault();let T=ne[ye];T!==void 0&&k(T)}}}}})]})]})]}),o.map(d=>(0,b.jsx)("p",{className:"dsh-st-error",children:t("warning.groupLoad",{name:d.providerLabel,message:d.message})},d.provider)),h!==void 0&&(0,b.jsx)("p",{className:"dsh-st-error",children:h})]})}),(0,b.jsx)(be.RiskConfirmation,{open:N!==void 0,title:n("confirm.title"),description:n("confirm.description"),acknowledgeLabel:n("confirm.acknowledge"),cancelLabel:n("confirm.cancel"),closeLabel:n("confirm.cancel"),confirmLabel:n("confirm.enable"),acknowledged:_,onAcknowledgedChange:se,onCancel:()=>{se(!1),M(void 0)},onConfirm:()=>{!_||N===void 0||(R({permission:N}),se(!1),M(void 0))}})]})}function Es({value:e,onChange:n}){let[t,s]=e.split(":");return(0,b.jsxs)("span",{className:"dsh-st-time",children:[(0,b.jsx)(fe,{value:t,options:Cr.map(r=>({value:r,label:r})),onChange:r=>n(`${r}:${s}`)}),(0,b.jsx)("span",{className:"dsh-st-time-sep",children:":"}),(0,b.jsx)(fe,{value:s,options:Ls.map(r=>({value:r,label:r})),onChange:r=>n(`${t}:${r}`)})]})}function Nr(e){let n=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-n).toISOString().slice(0,10)}function Ms(e){let n=new Date(e),t=new Date;if(!Number.isFinite(n.getTime())||n.getTime()>t.getTime())return e;let s=new Date(t.getTime()+6e4);s.setSeconds(0,0);let r=s.getTimezoneOffset()*6e4;return new Date(s.getTime()-r).toISOString().slice(0,16)}var Os=require("react"),Je=require("@deepseek-ai/dsh-client-ui-primitives");var Re=require("react/jsx-runtime");function Ds({target:e,t:n,busy:t,onCancel:s,onConfirm:r}){return(0,Os.useEffect)(()=>{if(e===void 0)return;let i=a=>{a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation(),s())},o=a=>{xn(a,"dsh-st-delete-dialog")};return window.addEventListener("keydown",i,!0),document.addEventListener("click",o,!0),()=>{window.removeEventListener("keydown",i,!0),document.removeEventListener("click",o,!0)}},[s,e]),(0,Re.jsx)(Je.Modal,{open:e!==void 0,className:"dsh-st-delete-dialog",title:n("card.confirmDelete"),...e===void 0?{}:{description:`${e.name} ${n("card.confirmDeleteHint")}`},closeLabel:n("card.cancel"),onClose:s,footer:(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)(Je.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:t,onClick:s,children:n("card.cancel")}),(0,Re.jsx)(Je.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:t,onClick:r,children:n("card.confirm")})]})})}var Ye=null,et=new Set;function Fs(e){Ye=e;for(let n of[...et])n(Ye)}function nt(){let e=Ye;return Ye=null,e}function Hs(){return Ye}function Ws(e){return et.add(e),()=>{et.delete(e)}}function _s(e){let n=document.querySelector("[data-composer-seat] textarea");return n instanceof HTMLTextAreaElement?(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set?.call(n,e),n.dispatchEvent(new InputEvent("input",{bubbles:!0})),n.focus(),!0):!1}function Qe(e){if(typeof e!="object"||e===null||!("ok"in e))throw new Error("\u81EA\u52A8\u5316\u4E3B\u673A\u8FD4\u56DE\u4E86\u65E0\u6548\u54CD\u5E94\u3002");let n=e;if(n.ok===!0&&"value"in n)return n.value;if(n.ok===!1&&"error"in n){let t=n.error;throw new Error(t?.message??"\u81EA\u52A8\u5316\u8BF7\u6C42\u5931\u8D25\u3002")}throw new Error("\u81EA\u52A8\u5316\u4E3B\u673A\u8FD4\u56DE\u4E86\u65E0\u6548\u54CD\u5E94\u3002")}var en="/dsh-automation",Gs=15e3,Rr=2e3,Us=[1,2,4],zs=Us.length+1,Er=5*60*1e3,Mr=24*60*60*1e3;function Lr(e){return(e??[]).some(n=>n.status==="running"||n.status==="queued")?Rr:Gs}function tt(e,n){return n>0?Lr(e):Gs}function st(e){let n=e instanceof Error?e.message:String(e);return/failed to fetch|networkerror|load failed|network request failed/i.test(n)}function Pr(e,n){let t=Date.parse(n),r=(Number.isFinite(t)?t:Date.now())-Mr;return[...new Set(e.filter(i=>{if(i.status==="queued"||i.status==="running")return!0;let o=Date.parse(i.finishedAt??i.startedAt??i.scheduledFor);return Number.isFinite(o)&&o>=r}).map(i=>i.sessionId).filter(i=>i!==void 0&&i!==""))].sort()}function Bs(e,n,t={}){let s=!1,r=0,i=e.source.getSnapshot().phase==="loading",o,a,l=0,c=0,g=0,m,x,A=!1,f=h=>{a=h,l=0,c=r,g=0,m=void 0},p=h=>{let S=e.source.getSnapshot().snapshot,N=h?.list?.getSnapshot();if(S===void 0||N===void 0||h?.refresh===void 0)return;let M=new Set([...N.ids??[],...Object.keys(N.byId??{})]);return Pr(S.runs,S.serverNow).filter(_=>!M.has(_)).join("\0")},u=()=>{if(s)return;let h=n();h!==o&&(o=h,f());let S=p(h);if(S===void 0)return;if(S===""){f();return}if(S!==a&&f(S),l>=zs){if((t.now??Date.now)()<g)return;f(S)}if(r<c)return;if(x!==void 0){A=!0;return}let N=l;l+=1;let M=Us[N];c=M===void 0?Number.POSITIVE_INFINITY:r+M,l>=zs&&(g=(t.now??Date.now)()+Er),x=Promise.resolve().then(async()=>{await h.refresh()}).catch(_=>{!s&&m!==S&&(m=S,console.warn("[dsh-automation] \u5237\u65B0 Host \u4F1A\u8BDD\u5217\u8868\u5931\u8D25",_))}).finally(()=>{x=void 0,!(s||!A)&&(A=!1,u())})},y=e.source.subscribe(()=>{e.source.getSnapshot().phase==="loading"?i=!0:i&&(i=!1,r+=1),u()},{background:!0});return u(),()=>{s=!0,A=!1,y()}}function $s(e){let n={phase:"idle"},t,s,r=()=>{},i=new Set,o=new Set,a=()=>{if(s!==void 0&&clearInterval(s),i.size===0){s=void 0;return}s=setInterval(()=>{m().catch(()=>{})},tt(n.snapshot?.runs,o.size))},l=()=>{if(r(),o.size===0)return;let f=()=>{m().catch(()=>{})},p=()=>{document.visibilityState==="visible"&&f()};typeof window<"u"&&window.addEventListener("focus",f),typeof document<"u"&&document.addEventListener("visibilitychange",p),r=()=>{typeof window<"u"&&window.removeEventListener("focus",f),typeof document<"u"&&document.removeEventListener("visibilitychange",p),r=()=>{}}},c=f=>{let p=tt(n.snapshot?.runs,o.size);n=f,i.size>0&&p!==tt(n.snapshot?.runs,o.size)&&a();for(let u of[...i])u()},g={getSnapshot:()=>n,subscribe:(f,p={})=>{let u=i.size>0,y=o.size>0;return i.add(f),p.background!==!0&&o.add(f),(!u||p.background!==!0&&!y)&&queueMicrotask(()=>{i.size>0&&m().catch(()=>{})}),a(),o.size>0&&!y&&l(),()=>{i.delete(f),o.delete(f),i.size===0&&s!==void 0?(clearInterval(s),s=void 0):i.size>0&&a(),o.size===0&&r()}}},m=async()=>{if(t!==void 0)return t;let f=n.snapshot;return c(f===void 0?{phase:"loading"}:{phase:"loading",snapshot:f,...n.refreshedAt===void 0?{}:{refreshedAt:n.refreshedAt}}),t=(async()=>{try{let p=await e.call(en,"snapshot",{sessionId:"settings"}),u=Qe(p);c({phase:"ready",snapshot:u,refreshedAt:Date.now()})}catch(p){let u=p instanceof Error?p.message:String(p);throw c(f===void 0?{phase:"error",error:u}:{phase:"error",snapshot:f,error:u,...n.refreshedAt===void 0?{}:{refreshedAt:n.refreshedAt}}),p}finally{t=void 0}})(),t},x=async(f,p)=>{try{return await e.call(en,f,p)}catch(u){if(!st(u))throw u;return await e.call(en,f,p)}},A=async(f,p,u)=>{Qe(await x(f,p));let y=()=>{u!==void 0&&n.snapshot!==void 0&&c({phase:"ready",snapshot:u(n.snapshot),refreshedAt:Date.now()})},h=t;y(),h!==void 0&&(await h.catch(()=>{}),y());try{await m()}catch{}};return{source:g,refresh:m,async createAutomation(f){await A("create",{sessionId:"settings",input:f})},async mutateAutomation(f,p){await A("mutate",{sessionId:"settings",automationId:f,mutation:p},p==="delete"?y=>({...y,automations:y.automations.filter(h=>h.id!==f)}):y=>({...y,automations:y.automations.map(h=>h.id===f?{...h,status:p==="pause"?"paused":"active"}:h)}))},async updateAutomation(f,p){await A("update",{sessionId:"settings",automationId:f,input:p})},async runNow(f){await A("run-now",{sessionId:"settings",automationId:f})},async markRunRead(f){await A("mark-read",{sessionId:"settings",runId:f})},async registerWorkspace(f){let p=Qe(await e.call(en,"register-workspace",{path:f}));return await m(),p},async adoptSession(f){Qe(await e.call(en,"adopt-session",{sessionId:f}))},async forgetSession(f){await A("forget-session",{sessionId:f},p=>({...p,runs:p.runs.map(u=>{if(u.sessionId!==f)return u;let{sessionId:y,...h}=u;return h})}))},async forgetAutomationSessions(f){await A("forget-automation-sessions",{automationId:f},p=>({...p,runs:p.runs.map(u=>{if(u.automationId!==f)return u;let{sessionId:y,...h}=u;return h})}))}}}var ot=require("react"),Ue=require("@deepseek-ai/dsh-client-ui-primitives");var Se=require("react/jsx-runtime"),Or=[["created","desc"],["created","asc"],["planned","asc"],["planned","desc"]];function Tn({t:e,storage:n,storageKey:t,sortKey:s,sortDirection:r,onSelect:i,iconOnly:o=!1,className:a}){let[l,c]=(0,ot.useState)(!1),[g,m]=(0,ot.useState)(()=>Ce(n,t)),x=e(s==="planned"?`sort.planned.${r}`:`sort.created.${r}`),A=g?.key===s&&g.direction===r,f=()=>{n===void 0||A||(Et(n,t,s,r),m({key:s,direction:r}))},p=[...Or.map(([y,h])=>({id:`${y}-${h}`,label:e(y==="planned"?`sort.planned.${h}`:`sort.created.${h}`)})),...n===void 0?[]:[{type:"separator",id:"sort-default-sep"},{id:"save-default",label:e(A?"sort.default.saved":"sort.default.save")}]],u=o?(0,Se.jsx)(Ue.Tooltip,{label:x,side:"bottom",delayMs:500,disabled:l,portal:!0,children:(0,Se.jsx)("button",{type:"button",className:l?"dsh-st-n-head-btn is-on":"dsh-st-n-head-btn","aria-label":x,"aria-expanded":l,onClick:()=>c(y=>!y),children:(0,Se.jsx)(wn,{size:16})})}):(0,Se.jsxs)(Ue.Button,{variant:"outline",size:"sm",role:"combobox","aria-label":x,"aria-expanded":l,className:["dsh-st-menu-select-trigger",l?"is-open":""].filter(Boolean).join(" "),onClick:()=>c(y=>!y),children:[(0,Se.jsx)("span",{className:"dsh-st-menu-select-label",children:x}),(0,Se.jsx)("svg",{className:"dsh-st-menu-select-arrow",viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",style:{marginLeft:4,transition:"transform 150ms ease",transform:l?"rotate(180deg)":"none"},children:(0,Se.jsx)("path",{d:"m4 6 4 4 4-4"})})]});return(0,Se.jsx)("div",{className:["dsh-st-menu-select-wrap",a].filter(Boolean).join(" "),style:{display:"inline-flex",verticalAlign:"middle"},children:(0,Se.jsx)(Ue.Menu,{open:l,onClose:()=>c(!1),selectedId:`${s}-${r}`,align:o?"end":"start",portal:!0,dense:!0,anchor:u,items:p,onSelect:y=>{if(y==="save-default"){f(),c(!1);return}let[h,S]=y.split("-");i(h,S),c(!1)}})})}var In="dsh-automation:open-task-settings",rt="dsh-automation:pending-task-settings";function it(e){if(typeof e!="object"||e===null)return;let n=e;if(!(typeof n.name!="string"||n.name.trim()===""||!Array.isArray(n.sessionIds)||n.sessionIds.some(t=>typeof t!="string"))&&!(n.automationId!==void 0&&(typeof n.automationId!="string"||n.automationId.trim()==="")))return{...typeof n.automationId=="string"?{automationId:n.automationId}:{},name:n.name,sessionIds:[...n.sessionIds]}}function Dr(e,n){try{e?.setItem(rt,JSON.stringify(n))}catch{}}function at(e){typeof window>"u"||(Dr(window.sessionStorage,e),window.dispatchEvent(new CustomEvent(In,{detail:e})))}function Vs(e){if(e!==void 0)try{let n=e.getItem(rt);return n===null?void 0:it(JSON.parse(n))}catch{return}}function Ks(e){try{e?.removeItem(rt)}catch{}}function qs(e,n,t){if(e.automationId!==void 0){let a=n.find(l=>l.id===e.automationId);if(a!==void 0)return a}let s=new Set(e.sessionIds),r=t.find(a=>a.sessionId!==void 0&&s.has(a.sessionId))?.automationId,i=n.find(a=>a.id===r);if(i!==void 0)return i;let o=n.filter(a=>a.name===e.name);return o.length===1?o[0]:void 0}var w=require("react/jsx-runtime");var Cn=typeof window>"u"?void 0:window.localStorage,js=typeof window>"u"?void 0:window.sessionStorage,Fr=[{name:"\u6BCF\u65E5\u56DE\u5F52\u68C0\u67E5",scheduleKind:"daily",time:"09:00",weekdays:[1,2,3,4,5]},{name:"\u6BCF\u5468\u4F9D\u8D56\u5DE1\u68C0",scheduleKind:"weekly",time:"10:00",weekdays:[1]},{name:"\u5DE5\u4F5C\u65E5\u65E9\u62A5",scheduleKind:"weekly",time:"08:00",weekdays:[1,2,3,4,5]}];function Zs({t:e,permissionT:n,modelT:t,runtime:s,closeSettings:r,addWorkspace:i}){let o=(0,Y.useSyncExternalStore)(s.source.subscribe,s.source.getSnapshot,s.source.getSnapshot),[a,l]=(0,Y.useState)("mine"),[c,g]=(0,Y.useState)(""),[m,x]=(0,Y.useState)(!1),[A,f]=(0,Y.useState)(),[p,u]=(0,Y.useState)(),[y,h]=(0,Y.useState)(),[S,N]=(0,Y.useState)(!1),[M,_]=(0,Y.useState)(),[se,re]=(0,Y.useState)("day"),[z,Q]=(0,Y.useState)("all"),[V,F]=(0,Y.useState)("all"),[G,W]=(0,Y.useState)(()=>Ce(Cn,pn)?.key??"created"),[ee,ce]=(0,Y.useState)(()=>Ce(Cn,pn)?.direction??"desc"),[I,R]=(0,Y.useState)(()=>Vs(js)),H=(0,Y.useMemo)(()=>new Date(o.snapshot?.serverNow??Date.now()),[o.snapshot?.serverNow,o.refreshedAt]),L=o.snapshot,ue=L?.workspaces??[],he=L?.models??[],ae=L?.permissions??[],oe=L?.defaultPermission??"",me=un((L?.automations??[]).filter(k=>c.trim()===""||`${k.name} ${k.prompt}`.toLowerCase().includes(c.trim().toLowerCase())),G,ee),ke=(L?.runs??[]).filter(k=>!(z!=="all"&&k.automationId!==z||V!=="all"&&k.status!==V)),ge=Mt(ke,se,H,e),Z=async k=>{N(!0),_(void 0);try{await k()}catch(d){_(d instanceof de?e(d.key):st(d)?e("error.offline"):d instanceof Error?d.message:e("error.action"))}finally{N(!1)}},ne=()=>{x(!1),h(void 0),f(void 0)},ye=k=>{oe===""||ae.length===0||(f(void 0),h(k),x(!0))},we=k=>{f(k.id),h(Lt(k,ue,L?.defaultModel??null,L?.defaultPermission??k.permission)),x(!0)};return(0,Y.useEffect)(()=>{if(typeof window>"u")return;let k=d=>{let T=it(d.detail);T!==void 0&&R(T)};return window.addEventListener(In,k),()=>{window.removeEventListener(In,k)}},[]),(0,Y.useEffect)(()=>{if(I===void 0||L===void 0)return;let k=qs(I,L.automations,L.runs);if(Ks(js),R(void 0),l("mine"),g(""),k===void 0){_(e("error.taskMissing"));return}we(k)},[L,I,e]),(0,w.jsxs)("div",{className:"dsh-st-shell",children:[(0,w.jsxs)("header",{className:"dsh-st-top",children:[(0,w.jsxs)("div",{className:"dsh-st-heading",children:[(0,w.jsxs)("div",{className:"dsh-st-heading-row",children:[(0,w.jsx)("h1",{children:e("tab")}),(0,w.jsxs)("div",{className:"dsh-st-heading-links",children:[(0,w.jsx)(ie.Button,{variant:"outline",size:"sm","aria-label":e("header.githubProject"),icon:(0,w.jsx)(fs,{}),onClick:()=>{window.open("https://github.com/MichengAI/dsh-automation","_blank","noreferrer")},children:e("header.githubProject")}),(0,w.jsx)(ie.Button,{variant:"outline",size:"sm","aria-label":e("header.githubFeedback"),icon:(0,w.jsx)(hs,{}),onClick:()=>{window.open("https://github.com/MichengAI/dsh-automation/issues","_blank","noreferrer")},children:e("header.githubFeedback")})]})]}),(0,w.jsx)("p",{children:e("header.lead")})]}),(0,w.jsxs)("div",{className:"dsh-st-toolbar",children:[(0,w.jsx)(ie.Input,{className:"dsh-st-search",value:c,placeholder:e("search.placeholder"),onChange:k=>g(k.target.value)}),(0,w.jsx)(ie.Button,{variant:"outline",icon:(0,w.jsx)(ms,{}),onClick:()=>{Fs(e("chat.prompt")),r?.()},children:e("action.chatCreate")}),(0,w.jsx)(ie.Button,{variant:"primary",icon:(0,w.jsx)(vn,{}),disabled:oe===""||ae.length===0,onClick:()=>ye(),children:e("action.create")}),(0,w.jsx)(ie.Button,{className:"dsh-st-row-icon",variant:"outline",size:"sm",icon:(0,w.jsx)(cs,{}),"aria-label":e("section.refresh"),style:Yn,onClick:()=>{s.refresh()}})]})]}),(0,w.jsx)("div",{className:"dsh-st-banner",role:"note",children:(0,w.jsxs)("span",{children:[(0,w.jsx)(ps,{}),e("banner.wake")]})}),(0,w.jsxs)("section",{className:"dsh-st-examples",children:[(0,w.jsx)("div",{className:"dsh-st-examples-head",children:(0,w.jsx)("h2",{children:e("examples.title")})}),(0,w.jsx)("div",{className:"dsh-st-example-row",children:Fr.map((k,d)=>(0,w.jsxs)("button",{type:"button",className:"dsh-st-example",disabled:oe===""||ae.length===0,onClick:()=>ye({name:e(`examples.${d+1}.title`),prompt:e(`examples.${d+1}.body`),scheduleKind:k.scheduleKind,time:k.time,weekdays:k.weekdays}),children:[(0,w.jsx)("strong",{children:e(`examples.${d+1}.title`)}),(0,w.jsx)("p",{children:e(`examples.${d+1}.body`)}),(0,w.jsxs)("span",{className:"dsh-st-chip",children:[(0,w.jsx)(Ne,{size:14}),e(`examples.${d+1}.chip`)]})]},k.name))})]}),M!==void 0&&(0,w.jsx)("p",{className:"dsh-st-error",children:M}),(o.phase==="idle"||o.phase==="loading"&&L===void 0)&&(0,w.jsx)("p",{className:"dsh-st-muted",children:e("loading")}),o.phase==="error"&&L===void 0&&(0,w.jsxs)("div",{className:"dsh-st-empty",children:[(0,w.jsx)("h3",{children:e("error.title")}),(0,w.jsx)("p",{children:o.error}),(0,w.jsx)(ie.Button,{variant:"primary",onClick:()=>{s.refresh()},children:e("error.retry")})]}),(0,w.jsxs)("div",{className:"dsh-st-tabs",children:[(0,w.jsx)(ie.SegmentedTabs,{className:"dsh-st-settings-tabs",label:e("tab"),value:a,items:[{value:"mine",id:"dsh-st-tab-mine",panelId:"dsh-st-panel-mine",label:(0,w.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,w.jsx)(Ne,{}),(0,w.jsx)("span",{children:e("tabs.mine")})]})},{value:"runs",id:"dsh-st-tab-runs",panelId:"dsh-st-panel-runs",label:(0,w.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,w.jsx)(ze,{}),(0,w.jsx)("span",{children:e("tabs.runs")})]})}],onChange:l}),a==="mine"&&(0,w.jsx)("div",{className:"dsh-st-sort-wrap",children:(0,w.jsx)(Tn,{t:e,...Cn===void 0?{}:{storage:Cn},storageKey:pn,sortKey:G,sortDirection:ee,onSelect:(k,d)=>{W(k),ce(d)}})}),a==="runs"&&(0,w.jsxs)("div",{className:"dsh-st-filters",children:[(0,w.jsx)(fe,{compact:!0,className:"dsh-st-filter-range",value:se,options:["day","week","month"].map(k=>({value:k,label:e(`history.range.${k}`)})),onChange:k=>re(k)}),(0,w.jsx)(fe,{compact:!0,className:"dsh-st-filter-task",value:z,options:[{value:"all",label:e("history.allTasks")},...(L?.automations??[]).map(k=>({value:k.id,label:k.name}))],onChange:Q}),(0,w.jsx)(fe,{compact:!0,className:"dsh-st-filter-status",value:V,options:[{value:"all",label:e("history.allStatus")},...Rt.map(k=>({value:k,label:e(`status.${k}`)}))],onChange:k=>F(k)})]})]}),a==="mine"&&(me.length===0?(0,w.jsxs)("div",{id:"dsh-st-panel-mine",role:"tabpanel","aria-labelledby":"dsh-st-tab-mine",className:"dsh-st-empty",children:[(0,w.jsx)("h3",{children:e("empty.title")}),(0,w.jsx)("p",{children:e("empty.body")})]}):(0,w.jsx)("div",{id:"dsh-st-panel-mine",role:"tabpanel","aria-labelledby":"dsh-st-tab-mine",className:"dsh-st-grid",children:me.map(k=>(0,w.jsx)(Hr,{item:k,t:e,now:H,busy:S,onEdit:()=>we(k),onToggle:()=>{Z(()=>s.mutateAutomation(k.id,gn(k.status)))},onRun:()=>{Z(()=>s.runNow(k.id))},onDelete:()=>u(k)},k.id))})),a==="runs"&&(ge.length===0?(0,w.jsx)("div",{id:"dsh-st-panel-runs",role:"tabpanel","aria-labelledby":"dsh-st-tab-runs",className:"dsh-st-empty",children:e("runs.empty")}):(0,w.jsx)("div",{id:"dsh-st-panel-runs",role:"tabpanel","aria-labelledby":"dsh-st-tab-runs",className:"dsh-st-timeline",children:ge.map(k=>(0,w.jsxs)("section",{className:"dsh-st-group",children:[(0,w.jsx)("h3",{children:k.label}),k.items.map(d=>(0,w.jsx)(Wr,{run:d,t:e},d.id))]},k.key))})),m&&(0,w.jsx)(Ps,{t:e,permissionT:n,modelT:t,busy:S,workspaces:ue,models:he,modelFailures:L?.modelFailures??[],defaultModel:L?.defaultModel??null,skills:L?.skills??[],permissions:ae,defaultPermission:oe,editing:A!==void 0,...y===void 0?{}:{draft:y},onClose:ne,...i===void 0?{}:{onAddWorkspace:i},onSubmit:async k=>{let d=Tt(k,ue,he,new Date,{allowPastOnce:A!==void 0});await Z(async()=>{A===void 0?await s.createAutomation(d):await s.updateAutomation(A,d),ne()})}},A??"create"),(0,w.jsx)(Ds,{target:p,t:e,busy:S,onCancel:()=>u(void 0),onConfirm:()=>{let k=p;k!==void 0&&Z(async()=>{await s.mutateAutomation(k.id,"delete"),u(void 0)})}})]})}function Hr({item:e,t:n,now:t,busy:s,onEdit:r,onToggle:i,onRun:o,onDelete:a}){let[l,c]=(0,Y.useState)(!1);return(0,w.jsxs)("article",{className:"dsh-st-card",onClick:r,children:[(0,w.jsxs)("div",{className:"dsh-st-card-head",children:[(0,w.jsx)("span",{onClick:g=>g.stopPropagation(),children:(0,w.jsx)(ie.Switch,{checked:e.status==="active",disabled:s,label:e.status==="active"?n("card.pause"):n("card.resume"),onChange:()=>i()})}),(0,w.jsx)("span",{onClick:g=>g.stopPropagation(),children:(0,w.jsx)(ie.Menu,{open:l,onClose:()=>c(!1),align:"end",portal:!0,dense:!0,anchor:(0,w.jsx)(ie.Tooltip,{label:n("card.more"),side:"bottom",delayMs:500,portal:!0,children:(0,w.jsx)("button",{type:"button",className:"dsh-st-row-icon","aria-label":n("card.more"),style:{...Yn,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,border:"1px solid var(--dsw-alias-border-l2, rgba(255,255,255,.15))",borderRadius:"var(--dsw-radius-sm, 6px)",background:"transparent",color:"var(--dsw-alias-label-secondary)",cursor:"pointer"},onClick:()=>c(g=>!g),children:(0,w.jsx)(Xe,{size:16})})}),items:[{id:"run",label:n("menu.run"),disabled:s},{id:"edit",label:n("menu.edit"),disabled:s},{id:"delete",label:n("menu.delete"),danger:!0,disabled:s}],onSelect:g=>{c(!1),g==="run"&&o(),g==="edit"&&r(),g==="delete"&&a()}})})]}),(0,w.jsx)("h3",{children:e.name}),(0,w.jsx)("p",{children:e.prompt}),(0,w.jsxs)("div",{className:"dsh-st-card-foot",children:[(0,w.jsxs)("span",{className:"dsh-st-chip",children:[(0,w.jsx)(Ne,{size:14}),ln(e.schedule,n)]}),(0,w.jsx)("span",{children:e.nextRunAt===void 0?n("stats.noneScheduled"):n("history.nextApprox",{when:cn(e.nextRunAt,t,n)})})]})]})}function Wr({run:e,t:n}){let t=Ct(e.startedAt,e.finishedAt);return(0,w.jsxs)("article",{className:`dsh-st-run is-${e.status}`,children:[(0,w.jsx)("strong",{children:e.automationName}),(0,w.jsxs)("p",{children:[(0,w.jsx)("span",{children:Nt(e.startedAt??e.scheduledFor)}),t!==void 0&&(0,w.jsx)("span",{children:t}),(0,w.jsx)("span",{children:wt(e.trigger,n)})]})]})}var Be="dsh-automation",Xs={tab:"Scheduled tasks","sidebar.tab":"Scheduled","sidebar.tabs":"Workspace views","sidebar.tasksTab":"Tasks","sidebar.channelsTab":"Channels","sidebar.views":"Scheduled views","sidebar.viewOverview":"Task overview","sidebar.empty":"No scheduled runs yet.","sidebar.tasksEmpty":"No web tasks yet.","sidebar.ungrouped":"Ungrouped","sidebar.section":"Scheduled","sidebar.workspaces":"Workspaces","sidebar.search":"Search","sidebar.sessions":"Sessions","sidebar.searchSessions":"Search session names","sidebar.clearSearch":"Clear search","sidebar.filter":"View options","sidebar.groupBy":"Group by","sidebar.groupWorkspace":"WorkSpace","sidebar.groupWorkspaceTree":"Workspace Tree","sidebar.groupList":"In one list","sidebar.sortBy":"Order by","sidebar.sortManual":"Manual","sidebar.sortTime":"Last updated","sidebar.filterBy":"Filter sessions","sidebar.hideArchived":"Hide archived","sidebar.showArchived":"All conversations (show archived)","sidebar.onlyArchived":"Archived only","header.lead":"Plan automatic tasks, or trigger them by hand. Describe the recurring work in any chat to create it quickly.","header.githubProject":"GitHub","header.githubFeedback":"Issues","examples.title":"Recommended examples","examples.1.title":"Daily regression check","examples.1.body":"Create a scheduled task that runs every day and inspects new test failures.","examples.1.chip":"Every day 09:00","examples.2.title":"Weekly dependency review","examples.2.body":"Create a scheduled task that runs every Monday and reports outdated or risky dependencies.","examples.2.chip":"Monday 10:00","examples.3.title":"Weekday morning briefing","examples.3.body":"Create a scheduled task that runs on weekdays and summarizes overnight changes.","examples.3.chip":"Weekdays 08:00","chat.hint":"In any conversation, describe the recurring work and ask the Agent to call automation_create.","chat.prompt":"I want to create a scheduled task that runs every [interval] and does [the actual task]","menu.run":"Run task","menu.edit":"Edit task","menu.delete":"Delete task","session.rename":"Rename","session.fork":"Fork session","session.archive":"Archive session","session.unarchive":"Restore","session.copySessionId":"Copy Session ID","session.moreActions":"More actions for {title}","session.groupActions":"Actions for {name}","session.taskSettings":"Task settings","session.archiveGroup":"Archive all conversations","session.archiveGroupConfirm":"Archive all","session.archiveGroupDescription":"Archive all {count} conversations for \u201C{name}\u201D. Choose Filter \u2192 Show archived to restore them.","session.archiveGroupPending":"Archiving conversations\u2026","session.archiveGroupFailed":"Some conversations could not be archived: {message}","session.archiveGroupClose":"Close","session.archiveGroupCancel":"Cancel","session.unarchiveGroup":"Restore all conversations","session.unarchiveGroupConfirm":"Restore all","session.unarchiveGroupDescription":"Restore all {count} conversations for \u201C{name}\u201D.","session.unarchiveGroupPending":"Restoring conversations\u2026","session.unarchiveGroupFailed":"Some conversations could not be restored: {message}","session.unarchiveGroupClose":"Close","session.unarchiveGroupCancel":"Cancel","session.deleteSession":"Delete session","session.deleteSessionConfirm":"Delete session","session.deleteSessionDescription":"This permanently deletes session \u201C{name}\u201D, its child agents (including any that are still running), and all of its records (conversation, stats, cache). This cannot be undone.","session.deleteSessionPending":"Deleting session\u2026","session.deleteSessionFailed":"Could not delete the session: {message}","session.deleteSessionClose":"Close","session.deleteSessionCancel":"Cancel","session.idle":"Idle","session.runningStatus":"Running","session.completed":"Completed","session.waitingApproval":"Waiting for approval","session.planReview":"Plan to review","session.waitingAnswer":"Waiting for an answer","session.subagentsRunning":"{count} subagents running","session.archived":"Archived","session.delete":"Remove from Scheduled","session.deleteFolder":"Remove folder","session.confirmDeleteFolder":"Remove this folder from Scheduled?","session.confirmDeleteFolderHint":'This only unlists {count} session(s) in "{name}" from Scheduled. Host sessions are not deleted and they stay hidden from Tasks.',"session.confirmDeleteFolderAction":"Remove from Scheduled","history.range.day":"By day","history.range.week":"By week","history.range.month":"By month","history.allTasks":"All tasks","history.allStatus":"All statuses","history.today":"Today","history.yesterday":"Yesterday","history.date":"{date}","history.week":"Week of {date}","history.month":"{month}","history.nextApprox":"Next run in about {when}","time.withinMinute":"about {count} minutes","time.withinHour":"about {count} hours","time.withinDay":"about {count} days","search.placeholder":"Search scheduled tasks...","action.chatCreate":"Create in chat","action.create":"New scheduled task","banner.wake":"Scheduled tasks run only while this computer stays awake.","tabs.mine":"My tasks","tabs.runs":"Run history","sort.by":"Sort","sort.created.asc":"Created time ascending","sort.created.desc":"Created time descending","sort.planned.asc":"Planned time ascending","sort.planned.desc":"Planned time descending","sort.default.save":"Set as default","sort.default.saved":"Default","form.workspace":"Workspace","form.fieldWorkspace":"Workspace","form.fieldModel":"Model","form.providerAccount":"DeepSeek account","form.fieldEffort":"Reasoning","form.fieldPermission":"Permission","form.slashHint":"Type / to insert a skill","form.slashEmpty":"No matching skills","form.addWorkspace":"Add workspace","form.workspaceRequired":"Add a registered workspace before saving.","form.workspaceUnavailable":"This Host cannot create workspaces.","form.addWorkspaceFailed":"Could not add the workspace.","form.workspacePath":"Folder path","form.workspacePathPlaceholder":"D:\\work\\project","form.model":"Model","form.modelSelect":"Select model","form.effort":"Reasoning","form.effort.none":"Default","form.effort.low":"Low","form.effort.medium":"Medium","form.effort.high":"High","form.error.workspace":"Select a workspace.","modal.title":"New scheduled task","modal.edit":"Edit scheduled task","modal.save":"Save","header.eyebrow":"Unattended coding work","header.title":"Automations","header.subtitle":"Schedule standalone, auditable Agent runs for this workspace.","header.create":"New automation","header.closeCreate":"Hide form","scope.workspace":"Workspace","scope.folder":"Working directory","stats.total":"All","stats.active":"Active","stats.next":"Next run","stats.attention":"Needs attention","stats.noneScheduled":"None scheduled","stats.noAttention":"All clear","section.automations":"Workspace automations","section.automationsHint":"Each trigger starts a fresh DSH Session and keeps its own audit record.","section.runs":"Recent runs","section.runsHint":"Latest outcomes for this workspace.","section.refresh":"Refresh","empty.title":"Let recurring coding work run itself","empty.body":"Save a self-contained task, a schedule, and a permission boundary. Every run starts in a new Session.","empty.action":"Create the first automation","runs.empty":"No runs yet. Run one now, or wait for the next scheduled occurrence.","overview.empty":"No scheduled tasks yet. Create one in Settings.","form.title":"Create automation","form.subtitle":"Write a complete, standalone task. Scheduled runs do not inherit this conversation.","form.name":"Name","form.namePlaceholder":"Daily regression triage","form.prompt":"Task prompt","form.promptPlaceholder":"Inspect new test failures, locate the regression, and propose a verified minimal fix\u2026","form.schedule":"Schedule","form.planTime":"Schedule","form.hourly":"Hourly","form.monthly":"Monthly","form.custom":"Every few days","form.intervalHint":"Runs every this many minutes, starting now.","form.customHint":"Runs every this many days at the selected time.","form.atTime":"at","form.minutesShort":"min","form.daysShort":"days","form.monthDay":"Day {day} of month","form.skills":"Skills","form.skillsEmpty":"No skills available","schedule.hourlyAt":"Every hour at :{minute}","schedule.monthlyAt":"Monthly on day {day} \xB7 {time}","schedule.customAt":"Every {count} days \xB7 {time}","form.once":"Does not repeat","form.interval":"Interval","form.daily":"Daily","form.weekly":"Weekly","form.runAt":"Run at","form.every":"Every","form.minutes":"minutes","form.time":"Time","form.days":"Weekdays","form.timeZone":"Time zone","form.maxConcurrentRuns":"Concurrency","form.maxConcurrentRunsHint":"Queued and running executions share this limit. Defaults to 1; when full, scheduled triggers are skipped and manual runs are rejected.","form.error.maxConcurrentRuns":"Enter a positive whole number for concurrent runs.","form.permission":"Permission boundary","permission.readOnly":"Read Only","permission.workspaceWrite":"Workspace Write","permission.fullAccess":"Full access","form.cancel":"Cancel","form.submit":"Create automation","form.submitting":"Creating\u2026","form.error.name":"Enter a name.","form.error.prompt":"Enter a complete, standalone task prompt.","form.error.once":"Choose a valid future date and time.","form.error.interval":"The interval must be between 1 and 43,200 minutes.","form.error.weekdays":"Select at least one weekday.","day.1":"Mon","day.2":"Tue","day.3":"Wed","day.4":"Thu","day.5":"Fri","day.6":"Sat","day.7":"Sun","status.active":"Active","status.paused":"Paused","status.queued":"Queued","status.running":"Running","status.succeeded":"Succeeded","status.failed":"Failed","status.skipped":"Skipped","status.cancelled":"Cancelled","status.interrupted":"Interrupted","card.nextRun":"Next","card.lastRun":"Last","card.never":"Not yet run","schedule.onceAt":"Once \xB7 {time}","schedule.everyMinutes":"Every {count} minutes","schedule.dailyAt":"Daily \xB7 {time}","schedule.weeklyAt":"{days} \xB7 {time}","card.pause":"Pause","card.resume":"Resume","card.runNow":"Run now","card.more":"More actions","card.delete":"Delete","card.confirmDelete":"Delete this automation?","card.confirmDeleteHint":"Run history is kept for audit.","card.confirm":"Delete","card.cancel":"Cancel","run.trigger.schedule":"Scheduled","run.trigger.manual":"Manual","run.openSession":"Session {id}","run.markRead":"Mark reviewed",loading:"Loading automations\u2026","error.title":"Automations could not be loaded","error.retry":"Try again","error.action":"The action failed. Please try again.","error.taskMissing":"This scheduled task no longer exists.","error.offline":"Could not reach the local automation service. Check that DSH is still running and try again.","time.minutes":"{count}m","time.hours":"{count}h","time.days":"{count}d","time.months":"{count}mo","time.years":"{count}y","time.ago":"{text} ago","time.now":"now","session.copy":"Copy","session.copied":"Copied","session.compactApproval":"Approval","session.compactPlan":"Plan review","session.compactAnswer":"Answer","time.minuteAgo":"{count}m ago","time.hourAgo":"{count}h ago","time.dayAgo":"{count}d ago","time.inMinute":"in {count}m","time.inHour":"in {count}h","time.inDay":"in {count}d"},Js={tab:"\u5B9A\u65F6\u4EFB\u52A1","sidebar.tab":"\u5B9A\u65F6","sidebar.tabs":"\u5DE5\u4F5C\u533A\u5206\u7C7B","sidebar.tasksTab":"\u4EFB\u52A1","sidebar.channelsTab":"\u9891\u9053","sidebar.views":"\u5B9A\u65F6\u9875\u89C6\u56FE","sidebar.viewOverview":"\u4EFB\u52A1\u603B\u89C8","sidebar.empty":"\u8FD8\u6CA1\u6709\u5B9A\u65F6\u4EFB\u52A1\u6267\u884C\u8BB0\u5F55\u3002","sidebar.tasksEmpty":"\u6682\u65E0\u7F51\u9875\u4EFB\u52A1","sidebar.ungrouped":"\u672A\u5206\u7EC4","sidebar.section":"\u5B9A\u65F6\u4EFB\u52A1","sidebar.workspaces":"\u5DE5\u4F5C\u533A","sidebar.search":"\u641C\u7D22","sidebar.sessions":"\u4F1A\u8BDD","sidebar.searchSessions":"\u641C\u7D22\u4F1A\u8BDD\u540D\u79F0","sidebar.clearSearch":"\u6E05\u9664\u641C\u7D22","sidebar.filter":"\u89C6\u56FE\u9009\u9879","sidebar.groupBy":"\u5206\u7EC4\u65B9\u5F0F","sidebar.groupWorkspace":"\u6309\u5DE5\u4F5C\u533A","sidebar.groupWorkspaceTree":"\u6309\u5DE5\u4F5C\u533A\u6811","sidebar.groupList":"\u5355\u5217\u8868","sidebar.sortBy":"\u6392\u5E8F\u65B9\u5F0F","sidebar.sortManual":"\u624B\u52A8\u6392\u5E8F","sidebar.sortTime":"\u6700\u8FD1\u66F4\u65B0","sidebar.filterBy":"\u7B5B\u9009\u4F1A\u8BDD","sidebar.hideArchived":"\u9690\u85CF\u5DF2\u5F52\u6863","sidebar.showArchived":"\u5168\u90E8\u5BF9\u8BDD\uFF08\u663E\u793A\u5DF2\u5F52\u6863\uFF09","sidebar.onlyArchived":"\u4EC5\u663E\u793A\u5DF2\u5F52\u6863","header.lead":"\u6309\u8BA1\u5212\u81EA\u52A8\u6267\u884C\u4EFB\u52A1\uFF0C\u4E5F\u53EF\u968F\u65F6\u624B\u52A8\u89E6\u53D1\u3002\u5728\u4EFB\u610F\u5BF9\u8BDD\u4E2D\u63CF\u8FF0\u4F60\u60F3\u5B9A\u671F\u505A\u7684\u4E8B\uFF0C\u5373\u53EF\u5FEB\u901F\u521B\u5EFA","header.githubProject":"GitHub","header.githubFeedback":"\u95EE\u9898\u53CD\u9988","examples.title":"\u63A8\u8350\u6848\u4F8B","examples.1.title":"\u6BCF\u65E5\u56DE\u5F52\u68C0\u67E5","examples.1.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5929\u3011\u6267\u884C\u3010\u68C0\u67E5\u65B0\u589E\u6D4B\u8BD5\u5931\u8D25\u5E76\u7ED9\u51FA\u6700\u5C0F\u4FEE\u590D\u3011\u3002","examples.1.chip":"\u6BCF\u5929 09:00","examples.2.title":"\u6BCF\u5468\u4F9D\u8D56\u5DE1\u68C0","examples.2.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5468\u4E00\u3011\u6267\u884C\u3010\u68C0\u67E5\u8FC7\u671F\u6216\u6709\u98CE\u9669\u7684\u4F9D\u8D56\u5E76\u7ED9\u51FA\u5904\u7406\u5EFA\u8BAE\u3011\u3002","examples.2.chip":"\u6BCF\u5468\u4E00 10:00","examples.3.title":"\u5DE5\u4F5C\u65E5\u65E9\u62A5","examples.3.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5DE5\u4F5C\u65E5\u3011\u6267\u884C\u3010\u6C47\u603B\u6628\u591C\u4ED3\u5E93\u53D8\u66F4\u5E76\u7ED9\u51FA\u4ECA\u65E5\u5173\u6CE8\u70B9\u3011\u3002","examples.3.chip":"\u5DE5\u4F5C\u65E5 08:00","chat.hint":"\u5728\u4EFB\u610F\u5BF9\u8BDD\u4E2D\u63CF\u8FF0\u4F60\u60F3\u5B9A\u671F\u505A\u7684\u4E8B\uFF0C\u5E76\u8BA9 Agent \u8C03\u7528 automation_create\u3002","chat.prompt":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u65F6\u95F4\u95F4\u9694\u3011\u6267\u884C\u3010\u5177\u4F53\u4EFB\u52A1\u3011","menu.run":"\u6267\u884C\u4EFB\u52A1","menu.edit":"\u7F16\u8F91\u4EFB\u52A1","menu.delete":"\u5220\u9664\u4EFB\u52A1","session.rename":"\u91CD\u547D\u540D","session.fork":"\u5206\u53C9\u4F1A\u8BDD","session.archive":"\u5F52\u6863\u4F1A\u8BDD","session.unarchive":"\u6062\u590D","session.copySessionId":"\u590D\u5236 Session ID","session.moreActions":"\u201C{title}\u201D\u7684\u66F4\u591A\u64CD\u4F5C","session.groupActions":"\u201C{name}\u201D\u7684\u4EFB\u52A1\u64CD\u4F5C","session.taskSettings":"\u4EFB\u52A1\u8BBE\u7F6E","session.archiveGroup":"\u5F52\u6863\u6574\u7EC4\u4F1A\u8BDD","session.archiveGroupConfirm":"\u786E\u8BA4\u5F52\u6863","session.archiveGroupDescription":"\u5C06\u5F52\u6863\u201C{name}\u201D\u4E0B\u7684 {count} \u4E2A\u4F1A\u8BDD\u3002\u53EF\u5728\u7B5B\u9009\u4E2D\u9009\u62E9\u201C\u663E\u793A\u5DF2\u5F52\u6863\u201D\u540E\u6062\u590D\u3002","session.archiveGroupPending":"\u6B63\u5728\u5F52\u6863\u6574\u7EC4\u4F1A\u8BDD\u2026","session.archiveGroupFailed":"\u90E8\u5206\u4F1A\u8BDD\u5F52\u6863\u5931\u8D25\uFF1A{message}","session.archiveGroupClose":"\u5173\u95ED","session.archiveGroupCancel":"\u53D6\u6D88","session.unarchiveGroup":"\u6062\u590D\u6574\u7EC4\u4F1A\u8BDD","session.unarchiveGroupConfirm":"\u786E\u8BA4\u6062\u590D","session.unarchiveGroupDescription":"\u5C06\u6062\u590D\u201C{name}\u201D\u4E0B\u7684 {count} \u4E2A\u4F1A\u8BDD\u3002","session.unarchiveGroupPending":"\u6B63\u5728\u6062\u590D\u6574\u7EC4\u4F1A\u8BDD\u2026","session.unarchiveGroupFailed":"\u90E8\u5206\u4F1A\u8BDD\u6062\u590D\u5931\u8D25\uFF1A{message}","session.unarchiveGroupClose":"\u5173\u95ED","session.unarchiveGroupCancel":"\u53D6\u6D88","session.deleteSession":"\u5220\u9664\u4F1A\u8BDD","session.deleteSessionConfirm":"\u5220\u9664\u4F1A\u8BDD","session.deleteSessionDescription":"\u5C06\u6C38\u4E45\u5220\u9664\u4F1A\u8BDD\u201C{name}\u201D\u53CA\u5176\u5B50\u4EE3\u7406\uFF08\u542B\u6B63\u5728\u8FD0\u884C\u7684\uFF09\u548C\u5168\u90E8\u8BB0\u5F55\uFF08\u5BF9\u8BDD\u5185\u5BB9\u3001\u7EDF\u8BA1\u3001\u7F13\u5B58\uFF09\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002","session.deleteSessionPending":"\u6B63\u5728\u5220\u9664\u4F1A\u8BDD\u2026","session.deleteSessionFailed":"\u5220\u9664\u4F1A\u8BDD\u5931\u8D25\uFF1A{message}","session.deleteSessionClose":"\u5173\u95ED","session.deleteSessionCancel":"\u53D6\u6D88","session.idle":"\u7A7A\u95F2","session.runningStatus":"\u8FDB\u884C\u4E2D","session.completed":"\u5DF2\u5B8C\u6210","session.waitingApproval":"\u7B49\u5F85\u5BA1\u6279","session.planReview":"\u8BA1\u5212\u5F85\u5BA1","session.waitingAnswer":"\u7B49\u5F85\u56DE\u7B54","session.subagentsRunning":"{count} \u4E2A\u5B50\u4EE3\u7406\u8FD0\u884C\u4E2D","session.archived":"\u5DF2\u5F52\u6863","session.delete":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664","session.deleteFolder":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664\u6587\u4EF6\u5939","session.confirmDeleteFolder":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664\u8FD9\u4E2A\u6587\u4EF6\u5939\uFF1F","session.confirmDeleteFolderHint":"\u53EA\u4F1A\u628A\u300C{name}\u300D\u4E0B\u7684 {count} \u6761\u4F1A\u8BDD\u4ECE\u5B9A\u65F6\u9875\u6458\u6389\uFF0C\u4E0D\u4F1A\u5220\u9664\u5BBF\u4E3B Session\u3002\u4EFB\u52A1\u9875\u672C\u6765\u4E5F\u4E0D\u5C55\u793A\u8FD9\u4E9B\u81EA\u52A8\u5316\u4F1A\u8BDD\u3002","session.confirmDeleteFolderAction":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664","history.range.day":"\u6309\u5929","history.range.week":"\u6309\u5468","history.range.month":"\u6309\u6708","history.allTasks":"\u5168\u90E8\u4EFB\u52A1","history.allStatus":"\u5168\u90E8\u72B6\u6001","history.today":"\u4ECA\u5929","history.yesterday":"\u6628\u5929","history.date":"{date}","history.week":"{date} \u5F53\u5468","history.month":"{month}","history.nextApprox":"\u4E0B\u6B21\u6267\u884C \u5927\u7EA6 {when}","time.withinMinute":"{count} \u5206\u949F\u5185","time.withinHour":"{count} \u5C0F\u65F6\u5185","time.withinDay":"{count} \u5929\u5185","search.placeholder":"\u641C\u7D22\u5B9A\u65F6\u4EFB\u52A1...","action.chatCreate":"\u901A\u8FC7\u5BF9\u8BDD\u521B\u5EFA","action.create":"\u65B0\u5EFA\u5B9A\u65F6\u4EFB\u52A1","banner.wake":"\u5B9A\u65F6\u4EFB\u52A1\u4EC5\u5728\u7535\u8111\u4FDD\u6301\u5524\u9192\u65F6\u8FD0\u884C","tabs.mine":"\u6211\u7684\u5B9A\u65F6\u4EFB\u52A1","tabs.runs":"\u6267\u884C\u8BB0\u5F55","sort.by":"\u6392\u5E8F","sort.created.asc":"\u6309\u521B\u5EFA\u65F6\u95F4\u5347\u5E8F","sort.created.desc":"\u6309\u521B\u5EFA\u65F6\u95F4\u5012\u5E8F","sort.planned.asc":"\u6309\u8BA1\u5212\u65F6\u95F4\u5347\u5E8F","sort.planned.desc":"\u6309\u8BA1\u5212\u65F6\u95F4\u5012\u5E8F","sort.default.save":"\u8BBE\u4E3A\u9ED8\u8BA4","sort.default.saved":"\u9ED8\u8BA4","form.workspace":"\u5DE5\u4F5C\u76EE\u5F55","form.fieldWorkspace":"\u5DE5\u4F5C\u533A","form.fieldModel":"\u6A21\u578B","form.providerAccount":"DeepSeek \u8D26\u53F7","form.fieldEffort":"\u63A8\u7406\u7B49\u7EA7","form.fieldPermission":"\u6743\u9650","form.slashHint":"\u8F93\u5165 / \u53EC\u56DE\u6280\u80FD","form.slashEmpty":"\u6CA1\u6709\u5339\u914D\u7684\u6280\u80FD","form.addWorkspace":"\u6DFB\u52A0\u5DE5\u4F5C\u533A","form.workspaceRequired":"\u8BF7\u5148\u6DFB\u52A0\u5DF2\u767B\u8BB0\u7684\u5DE5\u4F5C\u533A\uFF0C\u5426\u5219\u65E0\u6CD5\u4FDD\u5B58\u3002","form.workspaceUnavailable":"\u5F53\u524D\u5BBF\u4E3B\u4E0D\u80FD\u65B0\u5EFA\u5DE5\u4F5C\u533A\u3002","form.addWorkspaceFailed":"\u6DFB\u52A0\u5DE5\u4F5C\u533A\u5931\u8D25\u3002","form.workspacePath":"\u76EE\u5F55\u8DEF\u5F84","form.workspacePathPlaceholder":"D:\\work\\project","form.model":"\u6A21\u578B","form.modelSelect":"\u9009\u62E9\u6A21\u578B","form.effort":"\u63A8\u7406\u7B49\u7EA7","form.effort.none":"\u9ED8\u8BA4","form.effort.low":"Low","form.effort.medium":"Medium","form.effort.high":"High","form.error.workspace":"\u8BF7\u9009\u62E9\u5DE5\u4F5C\u533A\u3002","modal.title":"\u65B0\u5EFA\u5B9A\u65F6\u4EFB\u52A1","modal.edit":"\u7F16\u8F91\u5B9A\u65F6\u4EFB\u52A1","modal.save":"\u4FDD\u5B58","header.eyebrow":"\u81EA\u4E3B\u7F16\u7801\u4EFB\u52A1","header.title":"\u81EA\u52A8\u5316","header.subtitle":"\u4E3A\u5F53\u524D\u5DE5\u4F5C\u533A\u5B89\u6392\u72EC\u7ACB\u3001\u53EF\u5BA1\u8BA1\u7684 Agent \u8FD0\u884C\u3002","header.create":"\u65B0\u5EFA\u81EA\u52A8\u5316","header.closeCreate":"\u6536\u8D77\u8868\u5355","scope.workspace":"\u5DE5\u4F5C\u533A","scope.folder":"\u5DE5\u4F5C\u76EE\u5F55","stats.total":"\u5168\u90E8","stats.active":"\u5DF2\u542F\u7528","stats.next":"\u4E0B\u6B21\u8FD0\u884C","stats.attention":"\u9700\u8981\u5173\u6CE8","stats.noneScheduled":"\u6682\u65E0\u8BA1\u5212","stats.noAttention":"\u4E00\u5207\u6B63\u5E38","section.automations":"\u5DE5\u4F5C\u533A\u81EA\u52A8\u5316","section.automationsHint":"\u6BCF\u6B21\u89E6\u53D1\u90FD\u4F1A\u521B\u5EFA\u4E00\u4E2A\u5168\u65B0\u7684 DSH Session\uFF0C\u5E76\u4FDD\u7559\u72EC\u7ACB\u5BA1\u8BA1\u8BB0\u5F55\u3002","section.runs":"\u6700\u8FD1\u8FD0\u884C","section.runsHint":"\u5F53\u524D\u5DE5\u4F5C\u533A\u6700\u8FD1\u7684\u6267\u884C\u72B6\u6001\u3002","section.refresh":"\u5237\u65B0","empty.title":"\u8BA9\u91CD\u590D\u7684\u7F16\u7801\u5DE5\u4F5C\u81EA\u52A8\u8FD0\u884C","empty.body":"\u8BBE\u7F6E\u4E00\u4E2A\u76EE\u6807\u660E\u786E\u7684\u4EFB\u52A1\u3001\u8FD0\u884C\u65F6\u95F4\u548C\u6743\u9650\u8FB9\u754C\u3002\u6BCF\u6B21\u8FD0\u884C\u90FD\u4ECE\u5168\u65B0 Session \u5F00\u59CB\u3002","empty.action":"\u521B\u5EFA\u7B2C\u4E00\u4E2A\u81EA\u52A8\u5316","runs.empty":"\u8FD8\u6CA1\u6709\u8FD0\u884C\u8BB0\u5F55\u3002\u4F60\u53EF\u4EE5\u7ACB\u5373\u8FD0\u884C\u4E00\u6B21\uFF0C\u6216\u7B49\u5F85\u8BA1\u5212\u89E6\u53D1\u3002","overview.empty":"\u6682\u65E0\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u53EF\u5230\u8BBE\u7F6E\u9875\u521B\u5EFA\u3002","form.title":"\u521B\u5EFA\u81EA\u52A8\u5316","form.subtitle":"\u8BF7\u5199\u5B8C\u6574\u3001\u72EC\u7ACB\u7684\u4EFB\u52A1\u8BF4\u660E\uFF1A\u5B9A\u65F6\u8FD0\u884C\u4E0D\u4F1A\u7EE7\u627F\u5F53\u524D\u5BF9\u8BDD\u3002","form.name":"\u540D\u79F0","form.namePlaceholder":"\u6BCF\u65E5\u56DE\u5F52\u6D4B\u8BD5\u5206\u8BCA","form.prompt":"\u4EFB\u52A1\u6307\u4EE4","form.promptPlaceholder":"\u68C0\u67E5\u65B0\u589E\u6D4B\u8BD5\u5931\u8D25\uFF0C\u5B9A\u4F4D\u56DE\u5F52\u539F\u56E0\uFF0C\u5E76\u7ED9\u51FA\u7ECF\u8FC7\u9A8C\u8BC1\u7684\u6700\u5C0F\u4FEE\u590D\u65B9\u6848\u2026\u2026","form.schedule":"\u8FD0\u884C\u8BA1\u5212","form.planTime":"\u8BA1\u5212\u65F6\u95F4","form.hourly":"\u6BCF\u5C0F\u65F6","form.monthly":"\u6BCF\u6708","form.custom":"\u6BCF\u9694\u51E0\u5929","form.intervalHint":"\u4ECE\u73B0\u5728\u8D77\uFF0C\u6BCF\u9694\u8FD9\u4E48\u591A\u5206\u949F\u8FD0\u884C\u4E00\u6B21\u3002","form.customHint":"\u6BCF\u9694\u8FD9\u4E48\u591A\u5929\uFF0C\u5728\u6240\u9009\u65F6\u95F4\u8FD0\u884C\u4E00\u6B21\u3002","form.atTime":"\u4E8E","form.minutesShort":"\u5206","form.daysShort":"\u5929","form.monthDay":"\u6BCF\u6708\u7B2C {day} \u5929","form.skills":"\u6280\u80FD","form.skillsEmpty":"\u6682\u65E0\u53EF\u7528\u6280\u80FD","schedule.hourlyAt":"\u6BCF\u5C0F\u65F6 :{minute}","schedule.monthlyAt":"\u6BCF\u6708 {day} \u65E5 \xB7 {time}","schedule.customAt":"\u6BCF {count} \u5929 \xB7 {time}","form.once":"\u4E0D\u91CD\u590D","form.interval":"\u95F4\u9694","form.daily":"\u6BCF\u5929","form.weekly":"\u6BCF\u5468","form.runAt":"\u8FD0\u884C\u65F6\u95F4","form.every":"\u6BCF\u9694","form.minutes":"\u5206\u949F","form.time":"\u65F6\u95F4","form.days":"\u661F\u671F","form.timeZone":"\u65F6\u533A","form.maxConcurrentRuns":"\u5E76\u53D1\u6570\u91CF","form.maxConcurrentRunsHint":"\u540C\u4E00\u4EFB\u52A1\u7684\u6392\u961F\u53CA\u8FD0\u884C\u6B21\u6570\u5171\u7528\u6B64\u4E0A\u9650\uFF0C\u9ED8\u8BA4 1\uFF1B\u6EE1\u989D\u65F6\u8DF3\u8FC7\u5F53\u6B21\u5B9A\u65F6\u89E6\u53D1\uFF0C\u624B\u52A8\u8FD0\u884C\u5C06\u88AB\u62D2\u7EDD\u3002","form.error.maxConcurrentRuns":"\u5E76\u53D1\u6570\u91CF\u5FC5\u987B\u4E3A\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\u3002","form.permission":"\u6743\u9650\u8FB9\u754C","permission.readOnly":"\u53EA\u8BFB","permission.workspaceWrite":"\u5DE5\u4F5C\u533A\u5199\u5165","permission.fullAccess":"\u5B8C\u5168\u8BBF\u95EE","form.cancel":"\u53D6\u6D88","form.submit":"\u521B\u5EFA\u81EA\u52A8\u5316","form.submitting":"\u521B\u5EFA\u4E2D\u2026","form.error.name":"\u8BF7\u8F93\u5165\u540D\u79F0\u3002","form.error.prompt":"\u8BF7\u8F93\u5165\u5B8C\u6574\u3001\u72EC\u7ACB\u7684\u4EFB\u52A1\u6307\u4EE4\u3002","form.error.once":"\u8BF7\u9009\u62E9\u6709\u6548\u7684\u672A\u6765\u65E5\u671F\u548C\u65F6\u95F4\u3002","form.error.interval":"\u8FD0\u884C\u95F4\u9694\u5FC5\u987B\u5728 1 \u5230 43,200 \u5206\u949F\u4E4B\u95F4\u3002","form.error.weekdays":"\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u5929\u3002","day.1":"\u5468\u4E00","day.2":"\u5468\u4E8C","day.3":"\u5468\u4E09","day.4":"\u5468\u56DB","day.5":"\u5468\u4E94","day.6":"\u5468\u516D","day.7":"\u5468\u65E5","status.active":"\u5DF2\u542F\u7528","status.paused":"\u5DF2\u6682\u505C","status.queued":"\u6392\u961F\u4E2D","status.running":"\u8FD0\u884C\u4E2D","status.succeeded":"\u5DF2\u5B8C\u6210","status.failed":"\u5931\u8D25","status.skipped":"\u5DF2\u8DF3\u8FC7","status.cancelled":"\u5DF2\u53D6\u6D88","status.interrupted":"\u5DF2\u4E2D\u65AD","card.nextRun":"\u4E0B\u6B21","card.lastRun":"\u6700\u8FD1","card.never":"\u5C1A\u672A\u8FD0\u884C","schedule.onceAt":"\u5355\u6B21 \xB7 {time}","schedule.everyMinutes":"\u6BCF {count} \u5206\u949F","schedule.dailyAt":"\u6BCF\u5929 \xB7 {time}","schedule.weeklyAt":"{days} \xB7 {time}","card.pause":"\u6682\u505C","card.resume":"\u6062\u590D","card.runNow":"\u7ACB\u5373\u8FD0\u884C","card.more":"\u66F4\u591A\u64CD\u4F5C","card.delete":"\u5220\u9664","card.confirmDelete":"\u786E\u8BA4\u5220\u9664\u8FD9\u4E2A\u81EA\u52A8\u5316\uFF1F","card.confirmDeleteHint":"\u8FD0\u884C\u5386\u53F2\u4F1A\u4FDD\u7559\u7528\u4E8E\u5BA1\u8BA1\u3002","card.confirm":"\u786E\u8BA4\u5220\u9664","card.cancel":"\u53D6\u6D88","run.trigger.schedule":"\u5B9A\u65F6\u89E6\u53D1","run.trigger.manual":"\u624B\u52A8\u89E6\u53D1","run.openSession":"Session {id}","run.markRead":"\u6807\u8BB0\u5DF2\u5904\u7406",loading:"\u6B63\u5728\u52A0\u8F7D\u81EA\u52A8\u5316\u2026","error.title":"\u65E0\u6CD5\u52A0\u8F7D\u81EA\u52A8\u5316","error.retry":"\u91CD\u8BD5","error.action":"\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002","error.taskMissing":"\u8BE5\u5B9A\u65F6\u4EFB\u52A1\u5DF2\u4E0D\u5B58\u5728\u3002","error.offline":"\u65E0\u6CD5\u8FDE\u63A5\u672C\u673A\u81EA\u52A8\u5316\u670D\u52A1\uFF0C\u8BF7\u786E\u8BA4 DSH \u4ECD\u5728\u8FD0\u884C\u540E\u91CD\u8BD5\u3002","time.minutes":"{count}\u5206\u949F","time.hours":"{count}\u5C0F\u65F6","time.days":"{count}\u5929","time.months":"{count}\u4E2A\u6708","time.years":"{count}\u5E74","time.ago":"{text}\u524D","time.now":"\u521A\u521A","session.copy":"\u590D\u5236","session.copied":"\u5DF2\u590D\u5236","session.compactApproval":"\u5F85\u5BA1\u6279","session.compactPlan":"\u8BA1\u5212\u5F85\u5BA1","session.compactAnswer":"\u5F85\u56DE\u7B54","time.minuteAgo":"{count} \u5206\u949F\u524D","time.hourAgo":"{count} \u5C0F\u65F6\u524D","time.dayAgo":"{count} \u5929\u524D","time.inMinute":"{count} \u5206\u949F\u540E","time.inHour":"{count} \u5C0F\u65F6\u540E","time.inDay":"{count} \u5929\u540E"};var Ys="__dshNativeTabs";function Qs(e){let n=new Map,t=[],s=new Set,r=[],i=()=>{r=[...n.values()].sort((a,l)=>(a.order??0)-(l.order??0))},o=()=>{for(let a of s)a()};return{version:1,officialTree:e,sessionFilters:t,getTabs(){return r},subscribe(a){return s.add(a),()=>{s.delete(a)}},insert(a){if(a.id==="")return()=>{};let l=n.get(a.id);return n.set(a.id,a),l!==a&&(i(),o()),()=>{n.get(a.id)===a&&(n.delete(a.id),i(),o())}},addSessionFilter(a){return t.push(a),o(),()=>{let l=t.indexOf(a);l>=0&&t.splice(l,1),o()}}}}function dt(e){if(e==null||typeof e!="object"&&typeof e!="function")return;let n=e[Ys];if(!(n==null||typeof n!="object"))return typeof n.insert=="function"?n:void 0}function lt(e,n){try{e[Ys]=n}catch{}return n}function eo(e){let n=e;return dt(e)??dt(n?.component)}function no(e){if(e==null)return!1;let n=e;return n.__dshNativeTabHost===!0||n.__imConnectWrapped===!0?!0:dt(e)!==void 0}var _r="@michengai/dsh-archive-manager";function ct(e){return e?.querySelector(`[data-plugin="${_r}"]`)!=null}function $e(e){return typeof e=="function"?e:void 0}function Nn(e){let n=e??{},t=$e(n.renameSession),s=$e(n.archiveSession),r=$e(n.unarchiveSession),i=$e(n.deleteSession),o=$e(n.forkSession),a=$e(n.notifyArchivedNotOpenable);return{...t===void 0?{}:{renameSession:t},...s===void 0?{}:{archiveSession:s},...r===void 0?{}:{unarchiveSession:r},...i===void 0?{}:{deleteSession:i},...o===void 0?{}:{forkSession:o},...a===void 0?{}:{notifyArchivedNotOpenable:a}}}function to(e,n){return e&&n!==void 0}function so(e){let n=["rename","fork"];return e.archived?e.canUnarchive&&n.push("unarchive"):n.push("archive"),e.canDelete&&n.push("delete-session"),n}function oo(e,n){return n!==null&&e.includes(n)}function ro(e,n){return e&&!n}async function io(e,n){for(let t of e)await n(t)}async function ao(e,n){for(let t of e)await n(t)}var P=require("react"),ko=require("react-dom"),K=require("@deepseek-ai/dsh-client-ui-primitives");function co(e,n,t,s){if(e===void 0)return null;try{return e(n,t,s)??null}catch(r){if(!zr(r))throw r;return null}}function zr(e){return typeof e!="object"||e===null?!1:"name"in e&&e.name==="SlotOwnershipError"?!0:(e instanceof Error?e.message:"").includes("not declared by this entry")}function uo(e,n,t){let r=e.right+8,i=e.top+n.height>t.height-8?Math.max(8,t.height-n.height-8):Math.max(8,e.top);return{position:"fixed",zIndex:4100,left:`${Math.round(r)}px`,top:`${Math.round(i)}px`}}function po(e,n){let t=e.runningSubagentCount??0,s=t===0?void 0:{state:"ongoing",label:n("session.subagentsRunning",{count:t})},r;e.pendingKind==="approval"?r={state:"warning",label:n("session.waitingApproval"),trailing:n("session.compactApproval")}:e.pendingKind==="plan-review"?r={state:"warning",label:n("session.planReview"),trailing:n("session.compactPlan")}:e.pendingKind==="question"&&(r={state:"warning",label:n("session.waitingAnswer"),trailing:n("session.compactAnswer")});let i;r!==void 0?i=s===void 0?[r]:[r,s]:e.running?i=s===void 0?[{state:"ongoing",label:n("session.runningStatus")}]:[{state:"ongoing",label:n("session.runningStatus")},s]:s!==void 0?i=[s]:e.completed===!0?i=[{state:"done",label:n("session.completed")}]:i=[{state:"idle",label:n("session.idle")}];let o=i.filter(a=>!(e.archived&&(a.state==="done"||a.state==="idle")));return e.archived&&o.push({state:"archived",label:n("session.archived")}),o}function mo(e,n){let t=Date.parse(e||"");if(!Number.isFinite(t))return;let s=6e4,r=36e5,i=864e5,o=Math.max(0,n-t);return o<s?{unit:"now",count:0}:o<r?{unit:"minutes",count:Math.floor(o/s)}:o<i?{unit:"hours",count:Math.floor(o/r)}:o<30*i?{unit:"days",count:Math.floor(o/i)}:o<365*i?{unit:"months",count:Math.floor(o/(30*i))}:{unit:"years",count:Math.floor(o/(365*i))}}function fo(e,n){return e.unit==="now"?n("time.now"):e.unit==="minutes"?n("time.minutes",{count:e.count}):e.unit==="hours"?n("time.hours",{count:e.count}):e.unit==="days"?n("time.days",{count:e.count}):e.unit==="months"?n("time.months",{count:e.count}):n("time.years",{count:e.count})}function lo(e,n,t){e.scrollLeft=n,n>0?e.dataset.scrolled="":delete e.dataset.scrolled,n<t?e.dataset.clipped="":delete e.dataset.clipped}function Gr(e){e.scrollLeft=0,delete e.dataset.scrolled,delete e.dataset.clipped}function ho(e,n){if(e===null)return;let t=e.scrollWidth-e.clientWidth;if(t<=8)return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){lo(e,t,t);return}cancelAnimationFrame(n.id);let s,r=0,i=o=>{r+=s===void 0?0:(o-s)*.03,s=o,lo(e,Math.min(r,t),t),r<t&&(n.id=requestAnimationFrame(i))};n.id=requestAnimationFrame(i)}function ut(e,n){cancelAnimationFrame(n.id),e!==null&&Gr(e)}function go(e,n,t=Date.now()){let s=mo(e,t);return s===void 0?"":fo(s,n)}function yo(e,n,t=Date.now()){let s=mo(e,t);return s===void 0?"":s.unit==="now"?n("time.now"):n("time.ago",{text:fo(s,n)})}var Ee=require("react");var En=require("@deepseek-ai/dsh-client-ui-primitives");var $=require("react/jsx-runtime"),Rn=typeof window>"u"?void 0:window.localStorage;function Mn({t:e,view:n,onChange:t}){return(0,$.jsx)(En.SegmentedTabs,{className:"dsh-st-rail-views",label:e("sidebar.views"),value:n,items:[{value:"runs",id:"dsh-st-rail-view-runs",panelId:"dsh-st-rail-panel-runs",label:(0,$.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,$.jsx)(ze,{}),(0,$.jsx)("span",{children:e("tabs.runs")})]})},{value:"overview",id:"dsh-st-rail-view-overview",panelId:"dsh-st-rail-panel-overview",label:(0,$.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,$.jsx)(kn,{}),(0,$.jsx)("span",{children:e("sidebar.viewOverview")})]})}],onChange:t})}function Ln({t:e,automations:n,serverNow:t,openTaskSettings:s,onToggleAutomation:r}){let[i,o]=(0,Ee.useState)(()=>Ce(Rn,mn)?.key??"planned"),[a,l]=(0,Ee.useState)(()=>Ce(Rn,mn)?.direction??"asc"),[c,g]=(0,Ee.useState)(()=>new Set),m=(0,Ee.useMemo)(()=>new Date(t??Date.now()),[t]),x=(0,Ee.useMemo)(()=>{let p=un(n,i,a);return Ut(p)},[n,a,i]),A=(0,Ee.useMemo)(()=>new Map(n.map(p=>[p.id,ln(p.schedule,e)])),[n,e]),f=(p,u)=>{r===void 0||c.has(p)||(g(y=>new Set(y).add(p)),Promise.resolve(r(p,u)).catch(y=>{console.warn("[dsh-automation] \u5207\u6362\u4EFB\u52A1\u72B6\u6001\u5931\u8D25",y)}).finally(()=>{g(y=>{let h=new Set(y);return h.delete(p),h})}))};return(0,$.jsxs)("div",{className:"dsh-st-overview",children:[(0,$.jsxs)("div",{className:"dsh-st-overview-head",children:[(0,$.jsxs)("div",{className:"dsh-st-overview-title",children:[(0,$.jsx)("strong",{children:e("sidebar.viewOverview")}),(0,$.jsx)("span",{"aria-label":`${x.length}`,children:x.length})]}),(0,$.jsx)(Tn,{t:e,iconOnly:!0,className:"dsh-st-overview-sort",...Rn===void 0?{}:{storage:Rn},storageKey:mn,sortKey:i,sortDirection:a,onSelect:(p,u)=>{o(p),l(u)}})]}),x.length===0?(0,$.jsx)("div",{className:"dsh-st-rail-empty",children:e("overview.empty")}):x.map(p=>(0,$.jsx)(Ur,{t:e,row:p,now:m,scheduleSummary:A.get(p.id)??"",toggleDisabled:r===void 0||c.has(p.id),onToggleAutomation:f,...s===void 0?{}:{openTaskSettings:s}},p.id))]})}function Ur({t:e,row:n,now:t,scheduleSummary:s,openTaskSettings:r,toggleDisabled:i,onToggleAutomation:o}){let a=n.status!=="active",l=n.nextRunAt===void 0?e("stats.noneScheduled"):cn(n.nextRunAt,t,e),c=n.nextRunAt===void 0?e("stats.noneScheduled"):It(n.nextRunAt,t,e),g=`${e("stats.next")}: ${l}`,m=e(a?"card.resume":"card.pause");return(0,$.jsxs)("div",{className:`dsh-st-overview-row${a?" is-paused":""}`,children:[(0,$.jsxs)("button",{type:"button",className:"dsh-st-overview-open",disabled:r===void 0,onClick:()=>{r?.({automationId:n.id,name:n.name,sessionIds:[]})},children:[(0,$.jsxs)("span",{className:"dsh-st-overview-copy",children:[(0,$.jsx)("span",{className:"dsh-st-overview-name",children:n.name}),s!==""&&(0,$.jsxs)("span",{className:"dsh-st-overview-schedule",children:[(0,$.jsx)(us,{width:14,height:14}),(0,$.jsx)("span",{children:s})]})]}),(0,$.jsx)("span",{className:"dsh-st-overview-next",title:g,"aria-label":g,children:(0,$.jsx)("strong",{children:c})})]}),(0,$.jsx)("span",{className:"dsh-st-overview-toggle",title:m,children:(0,$.jsx)(En.Switch,{checked:!a,disabled:i,label:m,onChange:()=>{o?.(n.id,gn(n.status))}})})]})}var Oe=require("react"),Ve=require("@deepseek-ai/dsh-client-ui-primitives");function vo(e){return e?11:14}var j=require("react/jsx-runtime");function bo({t:e,query:n,sort:t,groupMode:s,archivedFilter:r="default",onQueryChange:i,onSortChange:o,onGroupModeChange:a,onArchivedFilterChange:l}){let[c,g]=(0,Oe.useState)(n.trim()!==""),[m,x]=(0,Oe.useState)(!1),A=(0,Oe.useRef)(null),f=vo(c);(0,Oe.useEffect)(()=>{c&&A.current?.focus()},[c]);let p=()=>{x(!1),g(!0)},u=()=>{i(""),g(!1)},y=[{type:"label",id:"group-by",text:e("sidebar.groupBy")},{id:"workspace",label:e("sidebar.groupWorkspace"),icon:(0,j.jsx)(Sn,{})},{id:"workspace-tree",label:e("sidebar.groupWorkspaceTree"),icon:(0,j.jsx)(kn,{})},{id:"flat",label:e("sidebar.groupList"),icon:(0,j.jsx)(ze,{})},{type:"separator",id:"order-by-separator"},{type:"label",id:"order-by",text:e("sidebar.sortBy")},{id:"updated",label:e("sidebar.sortTime"),icon:(0,j.jsx)(Ne,{})},...l!==void 0?[{type:"separator",id:"archived-filter-separator"},{type:"label",id:"filter-by",text:e("sidebar.filterBy")},{id:"hide-archived",label:e("sidebar.hideArchived"),icon:(0,j.jsx)(As,{})},{id:"show-archived",label:e("sidebar.showArchived"),icon:(0,j.jsx)(_e,{})},{id:"only-archived",label:e("sidebar.onlyArchived"),icon:(0,j.jsx)(Ts,{})}]:[]],h=[s==="list"?"flat":s,"updated",r==="show"?"show-archived":r==="only"?"only-archived":"hide-archived"];return(0,j.jsxs)("div",{className:c?"dsh-st-n-toolbar is-search":"dsh-st-n-toolbar",children:[(0,j.jsx)("span",{className:"dsh-st-n-head-label",children:e(s==="list"?"sidebar.sessions":"sidebar.workspaces")}),(0,j.jsx)("div",{className:"dsh-st-n-search-slot",children:(0,j.jsxs)("div",{className:"dsh-st-n-search",onClick:p,children:[(0,j.jsx)(Ve.Tooltip,{label:e("sidebar.search"),side:"bottom",delayMs:500,disabled:c,children:(0,j.jsx)("button",{type:"button",className:"dsh-st-n-search-btn","aria-label":e("sidebar.search"),"aria-expanded":c,onClick:p,children:(0,j.jsx)(bs,{size:f})})}),(0,j.jsx)("input",{ref:A,className:"dsh-st-n-search-input",value:n,placeholder:e("sidebar.searchSessions"),"aria-label":e("sidebar.searchSessions"),tabIndex:c?0:-1,"aria-hidden":!c,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Escape"&&u()}}),c&&(0,j.jsx)(Ve.Tooltip,{label:e("sidebar.clearSearch"),side:"bottom",delayMs:500,children:(0,j.jsx)("button",{type:"button",className:"dsh-st-n-search-clear","aria-label":e("sidebar.clearSearch"),onClick:S=>{S.stopPropagation(),u()},children:(0,j.jsx)(ws,{size:14})})})]})}),(0,j.jsx)("div",{className:"dsh-st-n-head-acts",children:(0,j.jsx)(Ve.Menu,{open:m,onClose:()=>{x(!1)},items:y,selectedIds:h,align:"end",dense:!0,portal:!0,onSelect:S=>{(S==="workspace"||S==="workspace-tree")&&a(S),S==="flat"&&a("list"),S==="updated"&&o("time"),S==="hide-archived"&&l?.("default"),S==="show-archived"&&l?.("show"),S==="only-archived"&&l?.("only"),x(!1)},anchor:(0,j.jsx)(Ve.Tooltip,{label:e("sidebar.filter"),side:"bottom",delayMs:500,disabled:m,children:(0,j.jsx)("button",{type:"button",className:m?"dsh-st-n-head-btn is-on":"dsh-st-n-head-btn","aria-label":e("sidebar.filter"),"aria-expanded":m,onClick:()=>x(S=>!S),children:(0,j.jsx)(wn,{size:16})})})})})]})}var v=require("react/jsx-runtime"),wo={},So=[];function Pn(e){let{t:n,runtime:t,openSession:s,useSessions:r,useWorkspaces:i,renameSession:o,archiveSession:a,unarchiveSession:l,deleteSession:c,forkSession:g,notifyArchivedNotOpenable:m,openTaskSettings:x,renderSlot:A,useSessionStatus:f}=e,p=(0,P.useSyncExternalStore)(t.source.subscribe,t.source.getSnapshot,t.source.getSnapshot),u=r?r(C=>je(C)):null,y=r?r(C=>C.byId??wo):wo,h=i?i(C=>C.archivedSessionIds??[]):[],S=i?i(C=>C.items??So):So,N=f?f(C=>C):void 0,M=r?r(C=>C.projectionsBySession):void 0,[_,se]=(0,P.useState)({}),[re,z]=(0,P.useState)(),[Q,V]=(0,P.useState)(),[F,G]=(0,P.useState)(),[W,ee]=(0,P.useState)(!1),[ce,I]=(0,P.useState)(),[R,H]=(0,P.useState)(),[L,ue]=(0,P.useState)(!1),[he,ae]=(0,P.useState)(),[oe,me]=(0,P.useState)(),[ke,ge]=(0,P.useState)(!1),[Z,ne]=(0,P.useState)(),[ye,we]=(0,P.useState)(()=>typeof document<"u"&&ct(document)),[k,d]=(0,P.useState)("default"),[T,B]=(0,P.useState)(""),[Ie,zo]=(0,P.useState)("time"),[xe,Go]=(0,P.useState)("workspace"),[ht,Uo]=(0,P.useState)("runs"),Wn=(0,P.useRef)(null),Me=(0,P.useMemo)(()=>new Set(h),[h]),_n=(0,P.useMemo)(()=>{let C=p.snapshot;if(C===void 0)return[];let q=new Map(C.automations.map(ve=>[ve.id,ve.timeZone]));return hn(C.automations,C.runs).map(ve=>({...ve,sessions:ve.sessions.filter(Ae=>Bt(Ae.id,Me,k)).map(Ae=>{let Te=C.runs.find(nn=>nn.sessionId===Ae.id);return{...Ae,title:qe(Te&&(Te.startedAt||Te.scheduledFor)||"",q.get(ve.id)),updatedAt:Te&&(Te.startedAt||Te.scheduledFor)||"",running:Ae.running||y[Ae.id]?.running===!0}})})).filter(ve=>ve.sessions.length>0)},[Me,k,y,p.snapshot]);(0,P.useEffect)(()=>{if(!yn(u,p.snapshot?.runs)){Wn.current=null;return}Wn.current!==u&&(Wn.current=u,t.refresh().catch(()=>{}))},[t,u,p.snapshot?.runs]);let zn=(0,P.useMemo)(()=>{let C=xe==="workspace-tree"?ds(_n.flatMap(q=>q.sessions.map(ve=>({...ve,automationId:q.id}))),S,n("sidebar.ungrouped")):_n;return ls(C.map(q=>({...q,name:q.name})),T,Ie,xe)},[xe,_n,T,Ie,n,S]);(0,P.useEffect)(()=>{if(typeof document>"u"||typeof MutationObserver>"u")return;let C=()=>{we(ct(document))};C();let q=new MutationObserver(C);return q.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{q.disconnect()}},[]);let Bo=ye&&a!==void 0,$o=to(ye,c),gt=l!==void 0,Vo=()=>{if(F===void 0||a===void 0||W)return;let C=F;ee(!0),I(void 0),io(C.sessionIds,a).then(()=>{G(void 0)}).catch(q=>{I(q instanceof Error?q.message:n("error.action"))}).finally(()=>{ee(!1)})},Ko=()=>{if(R===void 0||l===void 0||L)return;let C=R;ue(!0),ae(void 0),ao(C.sessionIds,l).then(()=>{H(void 0)}).catch(q=>{ae(q instanceof Error?q.message:n("error.action"))}).finally(()=>{ue(!1)})},qo=()=>{if(oe===void 0||c===void 0||ke)return;let C=oe;ge(!0),ne(void 0),Promise.resolve(c(C.id)).then(()=>{me(void 0)}).catch(q=>{ne(q instanceof Error?q.message:n("error.action"))}).finally(()=>{ge(!1)})};return(0,v.jsxs)("div",{className:"dsh-st-n",children:[(0,v.jsx)(Mn,{t:n,view:ht,onChange:Uo}),ht==="overview"?p.snapshot===void 0?(0,v.jsx)("div",{className:"dsh-st-n-empty",children:p.phase==="loading"?n("loading"):n("overview.empty")}):(0,v.jsx)(Ln,{t:n,automations:p.snapshot.automations,onToggleAutomation:(C,q)=>t.mutateAutomation(C,q),...x===void 0?{}:{openTaskSettings:x},...p.snapshot.serverNow===void 0?{}:{serverNow:p.snapshot.serverNow}}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(bo,{t:n,query:T,sort:Ie,groupMode:xe,archivedFilter:k,onQueryChange:B,onSortChange:zo,onGroupModeChange:Go,onArchivedFilterChange:d}),(0,v.jsx)("div",{className:"dsh-st-n-list-area",children:(0,v.jsxs)("div",{className:"dsh-st-n-tree",role:"tree",children:[p.phase==="loading"&&zn.length===0&&(0,v.jsx)("div",{className:"dsh-st-n-empty",children:n("loading")}),zn.length===0&&p.phase!=="loading"&&(0,v.jsx)("div",{className:"dsh-st-n-empty",children:n("sidebar.empty")}),zn.map(C=>{let q=_[C.id]!==!0,ve=oo(C.sessions.map(E=>E.id),u),Ae="depth"in C?C.depth:0,Te=[...new Set(C.sessions.flatMap(E=>"automationId"in E&&typeof E.automationId=="string"?[E.automationId]:[]))],nn=xe==="workspace-tree"&&Te.length===1?p.snapshot?.automations.find(E=>E.id===Te[0]):void 0,Gn=xe==="workspace-tree"?nn?.id:C.id,jo=xe==="workspace-tree"?nn?.name:C.name,yt=C.sessions.filter(E=>!Me.has(E.id)).map(E=>E.id),vt=C.sessions.filter(E=>Me.has(E.id)).map(E=>E.id),Zo=Bo&&yt.length>0,Xo=gt&&vt.length>0;return(0,v.jsxs)("div",{className:"dsh-st-n-group",style:Ae>0?{"--dsh-workspace-indent":`${Ae*12}px`}:void 0,children:[xe!=="list"&&(0,v.jsx)(Br,{t:n,id:C.id,name:C.name,sessionIds:C.sessions.map(E=>E.id),expanded:q,hasCurrentSession:ve,menuOpen:Q===C.id,canArchiveGroup:Zo,canUnarchiveGroup:Xo,showTaskSettings:Gn!==void 0,onToggle:()=>se(E=>({...E,[C.id]:q})),onMenuChange:E=>{z(void 0),V(E?C.id:void 0)},onTaskSettings:()=>{Gn!==void 0&&x?.({automationId:Gn,name:jo??C.name,sessionIds:C.sessions.map(E=>E.id)})},onArchiveGroup:()=>{I(void 0),G({id:C.id,name:C.name,sessionIds:yt})},onUnarchiveGroup:()=>{ae(void 0),H({id:C.id,name:C.name,sessionIds:vt})}}),(xe==="list"||q)&&C.sessions.map(E=>(0,v.jsx)($r,{t:n,flat:xe==="list",id:E.id,title:E.title,hoverTitle:String(y[E.id]?.displayTitle??y[E.id]?.title??C.name),updatedAt:E.updatedAt,running:E.running,archived:Me.has(E.id),selected:u===E.id,menuOpen:re===E.id,canDelete:$o,canUnarchive:gt,hoverStatuses:po({running:E.running||N?.get(E.id)?.running===!0,archived:Me.has(E.id),completed:N?.get(E.id)?.completionUnread===!0,...N?.get(E.id)?.pendingInteraction?.kind===void 0?{}:{pendingKind:N.get(E.id)?.pendingInteraction?.kind??""},runningSubagentCount:(M?.[E.id]?.values?.subagentCatalog??[]).filter(tn=>tn.id!==void 0&&N?.get(tn.id)?.running===!0).length},n),...A===void 0?{}:{renderSlot:A},onMenuChange:tn=>{V(void 0),z(tn?E.id:void 0)},onOpen:()=>{if(z(void 0),Me.has(E.id)){m?.();return}s?.(E.id)},onDeleteSession:()=>{ne(void 0),me({id:E.id,title:String(y[E.id]?.displayTitle??y[E.id]?.title??E.title)})},...o===void 0?{}:{renameSession:o},...a===void 0?{}:{archiveSession:a},...l===void 0?{}:{unarchiveSession:l},...g===void 0?{}:{forkSession:g}},E.id))]},C.id===""?"ungrouped":C.id)})]})})]}),(0,v.jsx)(K.Modal,{open:F!==void 0,onClose:()=>{W||(G(void 0),I(void 0))},closeLabel:n("session.archiveGroupClose"),title:n("session.archiveGroup"),...F===void 0?{}:{description:n("session.archiveGroupDescription",{name:F.name,count:F.sessionIds.length})},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(K.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:W,onClick:()=>{G(void 0),I(void 0)},children:n("session.archiveGroupCancel")}),(0,v.jsx)(K.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:W,onClick:Vo,children:n("session.archiveGroupConfirm")})]}),children:W||ce!==void 0?(0,v.jsxs)(v.Fragment,{children:[W&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.archiveGroupPending")}),ce!==void 0&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.archiveGroupFailed",{message:ce})})]}):void 0}),(0,v.jsx)(K.Modal,{open:R!==void 0,onClose:()=>{L||(H(void 0),ae(void 0))},closeLabel:n("session.unarchiveGroupClose"),title:n("session.unarchiveGroup"),...R===void 0?{}:{description:n("session.unarchiveGroupDescription",{name:R.name,count:R.sessionIds.length})},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(K.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:L,onClick:()=>{H(void 0),ae(void 0)},children:n("session.unarchiveGroupCancel")}),(0,v.jsx)(K.Button,{variant:"primary",className:"dsh-st-modal-action",disabled:L,onClick:Ko,children:n("session.unarchiveGroupConfirm")})]}),children:L||he!==void 0?(0,v.jsxs)(v.Fragment,{children:[L&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.unarchiveGroupPending")}),he!==void 0&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.unarchiveGroupFailed",{message:he})})]}):void 0}),(0,v.jsx)(K.Modal,{open:oe!==void 0,onClose:()=>{ke||(me(void 0),ne(void 0))},closeLabel:n("session.deleteSessionClose"),title:n("session.deleteSession"),...oe===void 0?{}:{description:n("session.deleteSessionDescription",{name:oe.title})},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(K.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:ke,onClick:()=>{me(void 0),ne(void 0)},children:n("session.deleteSessionCancel")}),(0,v.jsx)(K.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:ke,onClick:qo,children:n("session.deleteSessionConfirm")})]}),children:ke||Z!==void 0?(0,v.jsxs)(v.Fragment,{children:[ke&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.deleteSessionPending")}),Z!==void 0&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.deleteSessionFailed",{message:Z})})]}):void 0})]})}function Br(e){let{t:n,id:t,name:s,expanded:r,hasCurrentSession:i,menuOpen:o,canArchiveGroup:a,canUnarchiveGroup:l,showTaskSettings:c,onToggle:g,onMenuChange:m,onTaskSettings:x,onArchiveGroup:A,onUnarchiveGroup:f}=e,p=[...c?[{id:"task-settings",label:n("session.taskSettings"),icon:(0,v.jsx)(gs,{size:16})}]:[],...a?[...c?[{type:"separator",id:"archive-separator"}]:[],{id:"archive-group",label:n("session.archiveGroup"),icon:(0,v.jsx)(_e,{size:16}),danger:!0}]:[],...l?[...c&&!a?[{type:"separator",id:"unarchive-separator"}]:[],{id:"unarchive-group",label:n("session.unarchiveGroup"),icon:(0,v.jsx)(Xn,{size:16})}]:[]],u="dsh-st-n-row"+(i?" has-current-session":"")+(o?" is-menu":"");return(0,v.jsxs)("div",{className:u,role:"treeitem","aria-expanded":r,"data-n-group":t,onClick:g,children:[(0,v.jsx)("span",{className:"dsh-st-n-slot dsh-st-n-folder",children:r?(0,v.jsx)(Ss,{size:16}):(0,v.jsx)(Sn,{size:16})}),(0,v.jsx)("span",{className:"dsh-st-n-slot dsh-st-n-chevron",children:(0,v.jsx)(ks,{size:14,className:"dsh-st-n-arrow"+(r?" is-open":"")})}),(0,v.jsx)("span",{className:"dsh-st-n-project-text",children:(0,v.jsx)("span",{className:"dsh-st-n-title",children:s})}),(0,v.jsx)("span",{className:"dsh-st-n-acts",children:(0,v.jsx)(K.Menu,{open:o,onClose:()=>{m(!1)},items:p,onSelect:y=>{m(!1),y==="task-settings"&&x(),y==="archive-group"&&A(),y==="unarchive-group"&&f?.()},portal:!0,closeOnPointerLeave:!0,anchor:(0,v.jsx)(K.Tooltip,{label:n("session.groupActions",{name:s}),side:"bottom",delayMs:500,portal:!0,children:(0,v.jsx)("button",{type:"button",className:"dsh-st-n-ico","aria-label":n("session.groupActions",{name:s}),onMouseDown:y=>{y.stopPropagation()},onClick:y=>{y.stopPropagation(),m(!o)},children:(0,v.jsx)(Xe,{size:16})})})})})]})}function $r(e){let{t:n,flat:t,id:s,title:r,hoverTitle:i,updatedAt:o,running:a,archived:l,selected:c,menuOpen:g,canDelete:m,canUnarchive:x,hoverStatuses:A,renderSlot:f,onMenuChange:p,onOpen:u,onDeleteSession:y,renameSession:h,archiveSession:S,unarchiveSession:N,forkSession:M}=e,_=ro(t,a),se=(0,P.useRef)(null),re=(0,P.useRef)(null),[z,Q]=(0,P.useState)(!1),[V,F]=(0,P.useState)({}),G=(0,P.useRef)(void 0),W=(0,P.useRef)(null),ee=(0,P.useRef)({id:0});(0,P.useEffect)(()=>()=>{ut(W.current,ee.current)},[]);let[ce,I]=(0,P.useState)(!1),[R,H]=(0,P.useState)(r);(0,P.useEffect)(()=>{H(r)},[r]),(0,P.useEffect)(()=>{if(typeof K.HoverCard=="function"||!z||g)return;let d=()=>{let T=se.current?.getBoundingClientRect(),B=re.current;if(T===void 0)return;let Ie=B===null?{width:220,height:96}:{width:B.offsetWidth,height:B.offsetHeight};F(uo({right:T.right,top:T.top},Ie,{width:window.innerWidth,height:window.innerHeight}))};return d(),window.addEventListener("resize",d),document.addEventListener("scroll",d,!0),()=>{window.removeEventListener("resize",d),document.removeEventListener("scroll",d,!0)}},[z,g,r,o,a]),(0,P.useEffect)(()=>()=>{G.current!==void 0&&window.clearTimeout(G.current)},[]);let L=d=>{Promise.resolve(d()).catch(()=>{})},ue=()=>{typeof K.HoverCard=="function"||g||(G.current!==void 0&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>Q(!0),500))},he=()=>{G.current!==void 0&&window.clearTimeout(G.current),Q(!1)},ae="dsh-st-n-sess"+(c?" is-on":"")+(g?" is-menu":"")+(_?" is-flat-idle":"")+(l?" is-archived":"");if(ce)return(0,v.jsx)("div",{className:ae,ref:se,children:(0,v.jsx)("input",{className:"dsh-st-n-rename",value:R,autoFocus:!0,"aria-label":n("session.rename"),onChange:d=>H(d.target.value),onClick:d=>d.stopPropagation(),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),I(!1),R.trim()!==""&&R.trim()!==r&&L(()=>h?.(s,R.trim()))),d.key==="Escape"&&(d.preventDefault(),I(!1),H(r))},onBlur:()=>{I(!1),R.trim()!==""&&R.trim()!==r&&L(()=>h?.(s,R.trim()))}})});let oe=(i??r).trim()||r,me=f!==void 0?["pin","rename","fork","archive","session-id","archive-manager.delete-session"].map(d=>f("sidebar.workspaces.session.menu.item",{sessionId:s,displayTitle:oe},{hookContext:[g,T=>p(T)],only:d})).filter(Boolean):void 0,ge=me!==void 0&&me.some(Boolean)?l&&m?[{id:"delete-session",label:n("session.deleteSession"),icon:(0,v.jsx)(Zn,{}),danger:!0}]:[]:[...so({canDelete:m,archived:l,canUnarchive:x}).map(d=>d==="rename"?{id:d,label:n("session.rename"),icon:(0,v.jsx)(vs,{})}:d==="fork"?{id:d,label:n("session.fork"),icon:(0,v.jsx)(ys,{})}:d==="archive"?{id:d,label:n("session.archive"),icon:(0,v.jsx)(_e,{size:16})}:d==="unarchive"?{id:d,label:n("session.unarchive"),icon:(0,v.jsx)(Xn,{size:16})}:{id:d,label:n("session.deleteSession"),icon:(0,v.jsx)(Zn,{}),danger:!0}),{id:"session-id",label:n("session.copySessionId"),icon:(0,v.jsx)(xs,{size:16})}],Z=A.find(d=>d.state!=="archived"),ne=!l&&Z!==void 0&&Z.state!=="idle",ye=Z?.trailing,we=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"dsh-st-n-hover-title",children:oe}),(0,v.jsx)("div",{className:"dsh-st-n-hover-time",children:yo(o,n)}),A.map(d=>(0,v.jsxs)("div",{className:"dsh-st-n-hover-state",children:[d.state==="archived"?(0,v.jsx)(_e,{size:14}):(0,v.jsx)(K.StateDot,{state:d.state==="ongoing"?"ongoing":d.state==="warning"?"warning":d.state==="done"?"done":"idle",size:10}),d.label]},d.label))]}),k=(0,v.jsxs)("div",{className:ae,ref:se,role:"treeitem",tabIndex:0,"aria-selected":c,"data-n-menu-root":s,onClick:u,onMouseEnter:()=>{ho(W.current,ee.current),ue()},onMouseLeave:()=>{ut(W.current,ee.current),he()},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),u())},onContextMenu:d=>{d.preventDefault(),d.stopPropagation(),he(),p(!0)},children:[!_&&(0,v.jsx)("span",{className:"dsh-st-n-slot",children:ne&&Z!==void 0?(0,v.jsx)(K.StateDot,{state:Z.state==="ongoing"?"ongoing":Z.state==="warning"?"warning":"done",size:10}):a?(0,v.jsx)(K.StateDot,{state:"ongoing",size:10}):null}),(0,v.jsx)("span",{ref:W,className:"dsh-st-n-title",onDoubleClick:d=>{h!==void 0&&(d.stopPropagation(),I(!0))},children:r}),(0,v.jsx)("span",{className:"dsh-st-n-time","aria-hidden":ye===void 0?void 0:!0,children:ye??go(o,n)}),(0,v.jsxs)("span",{className:"dsh-st-n-acts",children:[me===void 0&&l&&x&&(0,v.jsx)("button",{type:"button",className:"dsh-st-n-restore",onMouseDown:d=>{d.stopPropagation()},onClick:d=>{d.stopPropagation(),L(()=>N?.(s))},children:n("session.unarchive")}),(0,v.jsx)(K.Menu,{open:g,onClose:()=>{p(!1)},items:ge,onSelect:d=>{p(!1),d==="rename"&&I(!0),d==="fork"&&L(()=>M?.(s)),d==="archive"&&L(()=>S?.(s)),d==="unarchive"&&L(()=>N?.(s)),d==="session-id"&&navigator.clipboard?.writeText(s),d==="delete-session"&&y?.()},portal:!0,closeOnPointerLeave:!0,anchor:(0,v.jsx)(K.Tooltip,{label:n("session.moreActions",{title:r}),side:"bottom",delayMs:500,portal:!0,children:(0,v.jsx)("button",{type:"button",className:"dsh-st-n-ico","aria-label":n("session.moreActions",{title:r}),onMouseDown:d=>{d.stopPropagation()},onClick:d=>{d.stopPropagation(),he(),p(!g)},children:(0,v.jsx)(Xe,{size:16})})}),children:me}),co(f,"sidebar.workspaces.session.row.action",{sessionId:s,displayTitle:oe},{only:"archive"})]}),typeof K.HoverCard!="function"&&z&&!g&&typeof document<"u"&&(0,ko.createPortal)((0,v.jsx)("div",{ref:re,className:"dsh-st-n-hover",style:V,onMouseEnter:ue,onMouseLeave:he,children:we}),document.body)]});return typeof K.HoverCard!="function"?k:(0,v.jsx)(K.HoverCard,{anchor:k,content:we,openDelayMs:800,disabled:g,copyText:oe,copyLabel:n("session.copy"),copiedLabel:n("session.copied")})}var U=require("react"),To=require("@deepseek-ai/dsh-client-ui-primitives");var O=require("react/jsx-runtime"),xo=[],Ao=e=>()=>{},pt=class extends U.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(n){console.warn("[dsh-automation] official workspace tree crashed",n)}render(){return this.state.failed?this.props.fallback:this.props.children}};function Io({t:e,runtime:n,openSession:t,openTaskSettings:s,view:r,showViewSwitch:i=!0}){let o=(0,U.useSyncExternalStore)(n.source.subscribe,n.source.getSnapshot,n.source.getSnapshot),[a,l]=(0,U.useState)({}),[c,g]=(0,U.useState)("runs"),m=r??c,x=o.snapshot,A=(0,U.useMemo)(()=>x===void 0?[]:hn(x.automations,x.runs),[x]);return(0,O.jsxs)("div",{className:"dsh-st-rail",children:[i&&(0,O.jsx)(Mn,{t:e,view:m,onChange:g}),m==="overview"?x===void 0?(0,O.jsx)("div",{className:"dsh-st-rail-empty",children:o.phase==="loading"?e("loading"):e("overview.empty")}):(0,O.jsx)(Ln,{t:e,automations:x.automations,onToggleAutomation:(f,p)=>n.mutateAutomation(f,p),...s===void 0?{}:{openTaskSettings:s},...x.serverNow===void 0?{}:{serverNow:x.serverNow}}):(0,O.jsxs)(O.Fragment,{children:[o.phase==="loading"&&A.length===0&&(0,O.jsx)("div",{className:"dsh-st-rail-empty",children:e("loading")}),A.length===0&&o.phase!=="loading"&&(0,O.jsx)("div",{className:"dsh-st-rail-empty",children:e("sidebar.empty")}),A.map(f=>(0,O.jsxs)("section",{className:"dsh-st-rail-group",children:[(0,O.jsxs)("button",{type:"button",className:"dsh-st-rail-head",onClick:()=>l(p=>({...p,[f.id]:!p[f.id]})),children:[(0,O.jsx)("span",{className:"dsh-st-rail-folder",children:(0,O.jsx)(Ne,{size:16})}),(0,O.jsx)("span",{className:"dsh-st-rail-title",children:f.name})]}),a[f.id]!==!0&&f.sessions.map(p=>(0,O.jsxs)("button",{type:"button",className:"dsh-st-rail-session",onClick:()=>t?.(p.id),children:[(0,O.jsx)("span",{children:p.label}),p.running&&(0,O.jsx)(To.StateDot,{state:"ongoing",size:10})]},p.id))]},f.id))]})]})}function Co({t:e,runtime:n,officialTree:t,hostProps:s,openSession:r,openTaskSettings:i,useSessions:o,useWorkspaces:a,renderSlot:l,hasChannels:c,subscribeChannels:g,tabRegistry:m,wide:x}){let A=t,[f,p]=(0,U.useState)(()=>{try{return Kt(window.localStorage.getItem(qn))}catch{return"tasks"}}),u=(0,U.useSyncExternalStore)(m?.subscribe??Ao,()=>m?.getTabs()??xo,()=>xo),y=(0,U.useSyncExternalStore)(g??Ao,()=>{try{return c?.()===!0}catch{return!1}},()=>!1),h=o?.(I=>je(I)),S=(0,U.useSyncExternalStore)(n.source.subscribe,n.source.getSnapshot,n.source.getSnapshot),N=(0,U.useMemo)(()=>$t(S.snapshot?.runs),[S.snapshot]),M=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!yn(h,S.snapshot?.runs)){M.current=null;return}M.current!==h&&(M.current=h??null,n.refresh().catch(()=>{}))},[S.snapshot?.runs,h,n]);let _=(0,U.useCallback)((I,R)=>o===void 0?I({ids:[],byId:{}}):o(H=>I(Qt(H,N)),R),[o,N]),se=(0,U.useCallback)((I,R)=>a===void 0?I({items:[],archivedSessionIds:[]}):a(H=>I(os(H,N)),R),[a,N]);(0,U.useEffect)(()=>{try{window.localStorage.setItem(qn,f)}catch{}},[f]),(0,U.useEffect)(()=>{let I=R=>{let H=R.target instanceof Element?R.target.closest("button"):null;if(H===null)return;let L=`${H.textContent??""} ${H.getAttribute("aria-label")??""}`;/新会话|新建任务|New chat|New session/i.test(L)&&p("tasks")};return document.addEventListener("click",I,!0),()=>document.removeEventListener("click",I,!0)},[]);let re=(0,U.useRef)(h),z=(0,U.useRef)(!1);(0,U.useEffect)(()=>{let I=Xt(h??void 0,N);if(!z.current){z.current=!0,re.current=h,I==="tasks"&&p("tasks");return}let R=re.current;if(re.current=h,!qt(R,h))return;let H=u.map(ue=>ue.id);I==="tasks"&&p("tasks"),I==="channels"&&(y||H.includes("channels"))&&p("channels");let L=u.find(ue=>h!=null&&ue.matchSession?.(String(h))===!0);L!==void 0&&L.id!=="schedule"&&p(L.id)},[h,y,u,N]);let Q={...s??{},...x===void 0?{}:{wide:x}},V={...Q,...o===void 0?{}:{useSessions:_},...a===void 0?{}:{useWorkspaces:se}},F=I=>A===void 0?(0,O.jsx)(Vr,{t:e,...r===void 0?{}:{openSession:r},...o===void 0?{}:{useSessions:_},...a===void 0?{}:{useWorkspaces:a}}):(0,O.jsx)(pt,{fallback:(0,U.createElement)(A,Q),children:(0,U.createElement)(A,I)});if(x===!1)return(0,O.jsx)(O.Fragment,{children:F(V)});let G=u.filter(I=>I.id!=="schedule"),W=Zt({tab:f,channelsReady:y,extraTabIds:jt({extraTabIds:G.map(I=>I.id),channelsReady:y})}),ee=u.find(I=>I.id==="schedule"),ce=ee===void 0?(0,O.jsx)(Pn,{t:e,runtime:n,...r===void 0?{}:{openSession:r},...i===void 0?{}:{openTaskSettings:i},...o===void 0?{}:{useSessions:o},...a===void 0?{}:{useWorkspaces:a},...l===void 0?{}:{renderSlot:l},...Nn(s),...typeof s?.useSessionStatus=="function"?{useSessionStatus:s.useSessionStatus}:{}}):ee.render({...s??{},openSession:r,open:r,useSessions:o,wide:!0});return(0,O.jsxs)("div",{className:"dsh-st-shell-rail",children:[(0,O.jsxs)("div",{className:"dsh-st-shell-tabs",role:"tablist","aria-label":e("sidebar.tabs"),children:[(0,O.jsx)("button",{type:"button",role:"tab","aria-selected":W==="tasks",className:W==="tasks"?"is-on":void 0,onClick:()=>p("tasks"),children:e("sidebar.tasksTab")}),G.map(I=>(0,O.jsx)("button",{type:"button",role:"tab","aria-selected":W===I.id,className:W===I.id?"is-on":void 0,onClick:()=>p(I.id),children:I.label},I.id)),y&&G.every(I=>I.id!=="channels")&&(0,O.jsx)("button",{type:"button",role:"tab","aria-selected":W==="channels",className:W==="channels"?"is-on":void 0,onClick:()=>p("channels"),children:e("sidebar.channelsTab")}),(0,O.jsx)("button",{type:"button",role:"tab","aria-selected":W==="schedule",className:W==="schedule"?"is-on":void 0,onClick:()=>p("schedule"),children:e("sidebar.tab")})]}),W==="schedule"?(0,O.jsx)("div",{className:"dsh-st-shell-body",children:ce}):G.find(I=>I.id===W)!==void 0?(0,O.jsx)("div",{className:"dsh-st-shell-body",children:G.find(I=>I.id===W)?.render({...s??{},openSession:r,open:r,useSessions:o,wide:!0})}):W==="channels"?(0,O.jsx)("div",{className:"dsh-st-shell-body",children:l?.("sidebar.channels",{...s??{},openSession:r,open:r,useSessions:o,wide:!0,skin:"native"})}):(0,O.jsx)("div",{className:"dsh-st-official-tree",children:F(V)})]})}function Vr({t:e,openSession:n,useSessions:t,useWorkspaces:s}){let r=t===void 0?{ids:[],byId:{}}:t(l=>l??{ids:[],byId:{}}),i=s===void 0?void 0:s(l=>l??{items:[],archivedSessionIds:[]}),o=Vt(r,i,e("sidebar.ungrouped")),a=je(r);return o.length===0?(0,O.jsx)("div",{className:"dsh-st-rail-empty",children:e("sidebar.tasksEmpty")}):(0,O.jsx)("div",{className:"dsh-st-rail",children:o.map(l=>(0,O.jsxs)("section",{className:"dsh-st-rail-group",children:[(0,O.jsx)("div",{className:"dsh-st-rail-head is-static",children:(0,O.jsx)("span",{className:"dsh-st-rail-title",children:l.label})}),l.sessions.map(c=>(0,O.jsx)("button",{type:"button",className:`dsh-st-rail-session${a===c.id?" is-on":""}`,onClick:()=>{c.id!==void 0&&n?.(c.id)},children:(0,O.jsx)("span",{children:c.title||c.id})},c.id))]},l.id||"ungrouped"))})}var No="dsh-automation-styles",On="@michengai/dsh-automation",Ro=`
|
|
3
|
+
"use strict";var Qo=Object.create;var an=Object.defineProperty;var er=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,sr=Object.prototype.hasOwnProperty;var or=(e,n)=>{for(var t in n)an(e,t,{get:n[t],enumerable:!0})},xt=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of nr(n))!sr.call(e,r)&&r!==t&&an(e,r,{get:()=>n[r],enumerable:!(s=er(n,r))||s.enumerable});return e};var dn=(e,n,t)=>(t=e!=null?Qo(tr(e)):{},xt(n||!e||!e.__esModule?an(t,"default",{value:e,enumerable:!0}):t,e)),rr=e=>xt(an({},"__esModule",{value:!0}),e);var bi={};or(bi,{apply:()=>gi,inject:()=>li,name:()=>di});module.exports=rr(bi);var He=require("react");var ee=require("react");function kt(e,n){return n(`run.trigger.${e}`)}var ce=class extends Error{constructor(t){super(t);this.key=t}},ir=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function un(e){return`/${ir.test(e.name)?e.name:e.id}`}function ar(e,n,t){let s=n.startsWith("/")?n:`/${n}`,r=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(^|\\s)${r}(?=\\s|$)`).test(e))return{text:e,caret:Math.min(Math.max(t,0),e.length)};let i=Math.min(Math.max(t,0),e.length),o=e.slice(0,i),a=e.slice(i),c=`${o.length>0&&!/\s$/.test(o)?" ":""}${s} `;return{text:o+c+a,caret:o.length+c.length}}function $n(e,n){let t=Math.min(Math.max(n,0),e.length),s=/(?:^|\s)\/([^\s/]*)$/.exec(e.slice(0,t));if(s===null)return;let r=s[1]??"";return{start:t-r.length-1,query:r}}function Tt(e,n){let t=n.trim().toLowerCase();return t===""?[...e]:e.filter(s=>s.id.toLowerCase().includes(t)||s.name.toLowerCase().includes(t))}function At(e,n,t){let s=$n(e,n),r=t.startsWith("/")?t:`/${t}`;return s===void 0?ar(e,r,n):{text:`${e.slice(0,s.start)}${r} ${e.slice(n)}`,caret:s.start+r.length+1}}function It(e,n){let t=new Set(n.map(o=>un(o).slice(1))),s=[],r=/(^|\s)(\/[a-z0-9]+(?:-[a-z0-9]+)*)(?=\s|$)/gi,i=0;for(let o of e.matchAll(r)){let a=o[1]??"",l=o[2]??"",c=(o.index??0)+a.length;t.has(l.slice(1))&&(c>i&&s.push({kind:"text",text:e.slice(i,c)}),s.push({kind:"skill",text:l}),i=c+l.length)}return(i<e.length||s.length===0)&&s.push({kind:"text",text:e.slice(i)}),s}function Ct(e=new Date){let n=new Date(e.getTime()+36e5);n.setMinutes(0,0,0);let t=n.getTimezoneOffset()*6e4;return new Date(n.getTime()-t).toISOString().slice(0,16)}function Kn(e=new Date,n=[],t,s=""){return{name:"",prompt:"",scheduleKind:"daily",onceAt:Ct(e),everyMinutes:"60",maxConcurrentRuns:"1",intervalAnchor:"",time:"09:00",weekdays:[1,2,3,4,5],hourlyMinute:"00",monthDay:"1",customDays:"2",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone||"Asia/Shanghai",permission:s,workspaceId:n[0]?.id??"",modelKey:t==null?"default":`${t.provider}::${t.model}`,reasoningEffort:t?.reasoning?.defaultEffort??"none",skills:[]}}function Nt(e,n,t,s=new Date,r={}){let i=Number(e.maxConcurrentRuns);if(!Number.isSafeInteger(i)||i<1)throw new ce("form.error.maxConcurrentRuns");let o=e.name.trim(),a=e.prompt.trim();if(o==="")throw new ce("form.error.name");if(a==="")throw new ce("form.error.prompt");let l=n.find(m=>m.id===e.workspaceId);if(l===void 0)throw new ce("form.error.workspace");let c;switch(e.scheduleKind){case"once":{let m=new Date(e.onceAt);if(!Number.isFinite(m.getTime())||r.allowPastOnce!==!0&&m.getTime()<=s.getTime())throw new ce("form.error.once");c={kind:"once",at:m.toISOString(),timeZone:e.timeZone};break}case"interval":{let m=Number(e.everyMinutes);if(!Number.isInteger(m)||m<1||m>43200)throw new ce("form.error.interval");c={kind:"interval",everyMinutes:m,anchor:e.intervalAnchor.trim()||s.toISOString(),timeZone:e.timeZone};break}case"daily":c={kind:"daily",time:e.time,timeZone:e.timeZone};break;case"weekly":if(e.weekdays.length===0)throw new ce("form.error.weekdays");c={kind:"weekly",time:e.time,weekdays:[...e.weekdays].sort((m,T)=>m-T),timeZone:e.timeZone};break;case"hourly":{let m=Number(e.hourlyMinute);if(!Number.isInteger(m)||m<0||m>59)throw new ce("form.error.interval");c={kind:"hourly",minute:m,timeZone:e.timeZone};break}case"monthly":{let m=Number(e.monthDay);if(!Number.isInteger(m)||m<1||m>31)throw new ce("form.error.interval");c={kind:"monthly",day:m,time:e.time,timeZone:e.timeZone};break}case"custom":{let m=Number(e.customDays);if(!Number.isInteger(m)||m<1)throw new ce("form.error.interval");c={kind:"custom",everyDays:m,time:e.time,timeZone:e.timeZone};break}}let y=t.find(m=>`${m.provider}::${m.model}`===e.modelKey);return{name:o,prompt:a,schedule:c,timeZone:e.timeZone,permission:e.permission,maxConcurrentRuns:i,workspaceId:l.id,cwd:l.path,...y===void 0?{provider:null,model:null}:{provider:y.provider,model:y.model},reasoningEffort:e.reasoningEffort==="none"?null:e.reasoningEffort}}function Rt(e,n,t){let s=Date.parse(e);if(!Number.isFinite(s))return e;let r=Math.round((s-n.getTime())/6e4),i=Math.abs(r);if(i<1)return t("time.now");let o=r>0;if(i<60)return t(o?"time.inMinute":"time.minuteAgo",{count:i});let a=Math.round(i/60);if(a<24)return t(o?"time.inHour":"time.hourAgo",{count:a});let l=Math.round(a/24);return t(o?"time.inDay":"time.dayAgo",{count:l})}function pn(e,n){switch(e.kind){case"once":return n("schedule.onceAt",{time:new Date(e.at).toLocaleString()});case"interval":return n("schedule.everyMinutes",{count:e.everyMinutes});case"daily":return n("schedule.dailyAt",{time:e.time});case"weekly":{let t=e.weekdays.map(s=>n(`day.${s}`)).join("\u3001");return n("schedule.weeklyAt",{days:t,time:e.time})}case"hourly":return n("schedule.hourlyAt",{minute:String(e.minute).padStart(2,"0")});case"monthly":return n("schedule.monthlyAt",{day:e.day,time:e.time});case"custom":return n("schedule.customAt",{count:e.everyDays,time:e.time})}}function mn(e,n,t){let s=Date.parse(e)-n.getTime();if(!Number.isFinite(s)||s<=0)return t("time.now");let r=Math.max(1,Math.ceil(s/6e4));if(r<60)return t("time.withinMinute",{count:r});let i=Math.ceil(r/60);return i<24?t("time.withinHour",{count:i}):t("time.withinDay",{count:Math.ceil(i/24)})}function Et(e,n){if(e===void 0||n===void 0)return;let t=(Date.parse(n)-Date.parse(e))/1e3;if(!(!Number.isFinite(t)||t<0))return`${t.toFixed(1)}s`}function Mt(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}var Lt=["succeeded","failed","interrupted","running","queued","skipped","cancelled"];function ln(e){let n=Date.parse(e);return Number.isFinite(n)?n:0}function fn(e,n,t){let s=t==="asc"?1:-1;return e.slice().sort((r,i)=>{if(n==="planned"){let a=r.nextRunAt,l=i.nextRunAt;if(a===void 0||l===void 0)return a===void 0&&l===void 0?r.name.localeCompare(i.name)||r.id.localeCompare(i.id):a===void 0?1:-1;let c=ln(a)-ln(l);return c!==0?c*s:r.name.localeCompare(i.name)||r.id.localeCompare(i.id)}let o=ln(r.createdAt)-ln(i.createdAt);return o!==0?o*s:r.id.localeCompare(i.id)})}var hn="dsh-automation.sort-default.settings",gn="dsh-automation.sort-default.overview";function Ne(e,n){if(e!==void 0)try{let t=e.getItem(n);if(t===null)return;let s=JSON.parse(t);return s.key!=="created"&&s.key!=="planned"||s.direction!=="asc"&&s.direction!=="desc"?void 0:{key:s.key,direction:s.direction}}catch{return}}function Pt(e,n,t,s){e.setItem(n,JSON.stringify({key:t,direction:s}))}function Dt(e,n,t,s){let r=new Map;for(let i of e){let o=new Date(i.finishedAt??i.startedAt??i.scheduledFor);if(Number.isNaN(o.getTime()))continue;let a;if(n==="month")a=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}`;else if(n==="week"){let c=dr(o);a=cn(c)}else a=cn(o);let l=r.get(a)??[];l.push(i),r.set(a,l)}return[...r.entries()].map(([i,o])=>({key:i,label:o[0]===void 0?i:n==="month"?s("history.month",{month:i.replace("-","/")}):n==="week"?s("history.week",{date:i.slice(5).replace("-","/")}):i===cn(t)?s("history.today"):i===cn(new Date(t.getTime()-864e5))?s("history.yesterday"):s("history.date",{date:i.slice(5).replace("-","/")}),items:o}))}function cn(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function dr(e){let n=new Date(e),t=n.getDay(),s=t===0?6:t-1;return n.setHours(0,0,0,0),n.setDate(n.getDate()-s),n}function Ot(e,n=[],t,s=e.permission){let r=Kn(new Date,n,t,s),i=e.schedule,o=e.provider&&e.model?`${e.provider}::${e.model}`:"default",a={...r,name:e.name,prompt:e.prompt,permission:e.permission,maxConcurrentRuns:String(e.maxConcurrentRuns??1),workspaceId:e.workspaceId??r.workspaceId,modelKey:o,reasoningEffort:e.reasoningEffort??"none",timeZone:e.timeZone||i.timeZone||r.timeZone};switch(i.kind){case"once":return{...a,scheduleKind:"once",onceAt:lr(i.at)};case"interval":return{...a,scheduleKind:"interval",everyMinutes:String(i.everyMinutes),intervalAnchor:i.anchor??""};case"hourly":return{...a,scheduleKind:"hourly",hourlyMinute:String(i.minute).padStart(2,"0")};case"daily":return{...a,scheduleKind:"daily",time:i.time};case"weekly":return{...a,scheduleKind:"weekly",time:i.time,weekdays:[...i.weekdays]};case"monthly":return{...a,scheduleKind:"monthly",time:i.time,monthDay:String(i.day)};case"custom":return{...a,scheduleKind:"custom",time:i.time,customDays:String(i.everyDays)}}}function lr(e){let n=new Date(e);if(Number.isNaN(n.getTime()))return Ct();let t=n.getTimezoneOffset()*6e4;return new Date(n.getTime()-t).toISOString().slice(0,16)}var qe=class extends Error{code="workspace/picker-unavailable";constructor(){super("workspace picker unavailable"),this.name="WorkspacePickerUnavailableError"}};function Le(e,n){if(!(e===null||typeof e!="object"&&typeof e!="function"))return Reflect.get(e,n)}function yn(e,n){if(e===null||typeof e!="object")return;let t;try{t=Reflect.get(e,"reflect")}catch{t=void 0}let s=Le(t,"get");if(typeof s=="function")try{let i=s.call(t,n);if(i!==void 0)return i}catch{}let r=Le(e,"get");if(typeof r=="function")try{let i=r.call(e,n);if(i!==void 0)return i}catch{return}if(typeof s!="function")try{return Le(e,n)}catch{return}}function Ft(e){if(typeof e=="string"&&e.trim()!=="")return e;if(e===null||typeof e!="object"||Reflect.get(e,"canceled")===!0)return;let n=Reflect.get(e,"path");if(typeof n=="string"&&n.trim()!=="")return n;let t=Reflect.get(e,"filePaths"),s=Array.isArray(t)?t[0]:void 0;return typeof s=="string"&&s.trim()!==""?s:void 0}async function Ht(e){let n=Le(e,"pickDirectory");if(typeof n=="function")return{picked:Ft(await n.call(e))}}async function jn(e,n){let t=yn(e,"workspaces"),s=Le(t,"create");if(typeof s!="function")return!1;try{return await s.call(t,{path:n}),!0}catch{return!1}}async function qn(e){let n;try{n=Reflect.get(globalThis,"__DSH_DIRECTORY_PICKER__")}catch{n=void 0}let t=Le(n,"pick");if(typeof t=="function")return Ft(await t.call(n));for(let s of["uiWorkspace","dialog","workspaces"]){let r=await Ht(yn(e,s));if(r!==void 0)return r.picked}try{let s=await Ht(Le(e,"workspaces"));if(s!==void 0)return s.picked}catch{}throw new qe}var cr={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"},Wt=new Map;function ur(e){let n=Wt.get(e);if(n!==void 0)return n;let t=new Intl.DateTimeFormat("en-CA",{...cr,timeZone:e});return Wt.set(e,t),t}function Ze(e,n){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;if(n===void 0){let s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,r=`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`;return`${s} ${r}`}try{let s=ur(n).formatToParts(t),r=y=>s.find(m=>m.type===y)?.value,[i,o,a,l,c]=["year","month","day","hour","minute"].map(y=>r(y));return[i,o,a,l,c].some(y=>y===void 0)?e:`${i}-${o}-${a} ${l}:${c}`}catch{return e}}var We="dsh-automation-session-",Xn="dsh-automation.sidebar-tab";function vn(e,n){let t=new Map,s=new Map;for(let o of e)t.set(o.id,o.name),o.timeZone!==void 0&&s.set(o.id,o.timeZone);for(let o of n){let a=(o.automationName||"").trim();a!==""&&a!==o.automationId&&!t.has(o.automationId)&&t.set(o.automationId,a)}let r=[],i=new Set;for(let o of e)i.has(o.id)||(r.push(o.id),i.add(o.id));for(let o of n)o.sessionId===void 0||o.sessionId===""||i.has(o.automationId)||(r.push(o.automationId),i.add(o.automationId));return r.map(o=>{let a=t.get(o)??o;return{id:o,name:a,sessions:n.filter(l=>l.automationId===o&&l.sessionId!==void 0&&l.sessionId!=="").slice().sort((l,c)=>Date.parse(c.startedAt??c.scheduledFor)-Date.parse(l.startedAt??l.scheduledFor)).map(l=>({id:l.sessionId,running:l.status==="running"||l.status==="queued",label:Ze(l.startedAt??l.scheduledFor,s.get(o))+" - "+a}))}}).filter(o=>o.sessions.length>0)}function bn(e){return e==="active"?"pause":"resume"}function $t(e){return e.map(n=>({id:n.id,name:n.name,status:n.status,...n.nextRunAt===void 0?{}:{nextRunAt:n.nextRunAt}}))}function Kt(e,n,t){if(e===void 0||e==="")return!1;let s=n.has(e);return t==="only"?s:t==="show"?!0:!s}function wn(e,n){return e==null||e===""||!e.startsWith(We)?!1:!(n??[]).some(t=>t.sessionId===e)}function jt(e){let n=new Set;for(let t of e??[]){let s=t.sessionId;typeof s=="string"&&s!==""&&n.add(s)}return n}var pr=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/;function Jn(e,n,t=new Set){if(e.startsWith(We)||t.has(e))return!0;let s=String(n?.title??n?.displayTitle??"");return pr.test(s)}function _t(e,n=new Set){if(e===void 0||e.blank===!0||e.origin==="im"||e.origin==="subagent")return!1;let t=e.id??"";return!(t.startsWith("im:")||Jn(t,e,n))}function qt(e,n,t,s=new Set){let r=e.byId??{},i=new Set(n?.archivedSessionIds??[]),o=new Set,a=[];for(let c of n?.items??[]){let y=(c.sessionIds??[]).map(m=>r[m]).filter(m=>m!==void 0&&m.id!==void 0&&_t(m,s)&&!i.has(m.id));for(let m of y)m.id!==void 0&&o.add(m.id);y.length>0&&a.push({id:c.workspaceId??c.id??c.path??c.title??"workspace",label:c.title||c.path||t,sessions:y})}let l=(e.ids??[]).map(c=>r[c]).filter(c=>c!==void 0&&c.id!==void 0&&!o.has(c.id)&&_t(c,s)&&!i.has(c.id));return l.length>0&&a.push({id:"",label:t,sessions:l}),a}function Zt(e){return e==="channels"||e==="schedule"||e==="tasks"?e:"tasks"}function Xt(e,n){let t=e??"",s=n??"";return s!==""&&t!==s}function Jt(e){let n=["tasks"];for(let t of e.extraTabIds)t===""||t==="tasks"||t==="schedule"||n.includes(t)||n.push(t);return e.channelsReady&&!n.includes("channels")&&n.push("channels"),n.push("schedule"),n}function Yt(e){return e.extraTabIds.includes(e.tab)?e.tab:e.tab==="channels"&&e.channelsReady?"channels":"tasks"}function Qt(e,n){if(!(e==null||e===""))return(n!==void 0?n.has(e):e.startsWith(We))?"schedule":e.startsWith("im:")?"channels":"tasks"}function mr(e){return/dsh-codex-ui|michengai-codex-ui|michengai\.codexUi|codex-ui/i.test(String(e??""))}function fr(e){let n=e;return String(n?.options?.locale??n?.options?.id??n?.options?.name??n?.options?.registrant??n?.component?.displayName??n?.component?.name??n?.id??n?.name??"")}function es(e){return(e??[]).some(n=>mr(fr(n)))}var zt=new WeakMap,Gt=new WeakMap;function ns(e){return e.size===0?"":[...e].sort().join("\0")}function ts(e,n=new Set){let t=e??{ids:[],byId:{}},s=ns(n);if(typeof t=="object"&&t!==null){let a=zt.get(t);if(a!==void 0&&a.key===s)return a.result}let r=(t.ids??[]).filter(a=>{let l=String(a);return!l.startsWith("im:")&&!Jn(l,t.byId?.[l],n)}),o=r.length===(t.ids??[]).length?t:{...t,ids:r,byId:Object.fromEntries(r.map(a=>[a,t.byId?.[a]]).filter(a=>a[1]!==void 0))};return typeof t=="object"&&t!==null&&zt.set(t,{key:s,result:o}),o}function Xe(e){let n=e?.byId??{};for(let[t,s]of Object.entries(n))if((s?.retainedBy?.mainView??0)>0){let r=s.id?.trim();return r!==void 0&&r!==""?r:t}return null}function hr(e){if(e===null||typeof e!="object")return;let n=e.openSession;if(typeof n=="function")return{openSession:t=>{n.call(e,t)}}}function ss(e){let n=hr(yn(e,"uiWorkspace"));return{...n===void 0?{}:{uiWorkspace:n}}}function os(e){return typeof e.uiWorkspace?.openSession=="function"}function rs(e,n){if(typeof e.uiWorkspace?.openSession=="function"){e.uiWorkspace.openSession(n);return}throw new Error("no client session opener")}function Vt(e,n,t){if(e==="")return!1;let s=e.startsWith(We)||e.startsWith("im:")?[n,t]:[t,n];for(let r of s)if(typeof r=="function")try{return r(e),!0}catch{}return!1}async function is(e){let n=e.id.trim();return n===""?!1:(await e.adopt?.(n).catch(()=>{}),!(e.listed?.(n)===!0)&&e.refresh!==void 0&&await e.refresh().catch(()=>{}),Vt(n,e.openRuntime,e.openHost)?!0:(e.refresh!==void 0&&await e.refresh().catch(()=>{}),Vt(n,e.openRuntime,e.openHost)))}function gr(e,n=new Set){return e.startsWith("im:")||Jn(e,void 0,n)}function as(e,n=new Set){let t=e??{items:[],archivedSessionIds:[]},s=ns(n);if(typeof t=="object"&&t!==null){let a=Gt.get(t);if(a!==void 0&&a.key===s)return a.result}let r=!1,i=(t.items??[]).map(a=>{let l=(a.sessionIds??[]).filter(c=>!gr(String(c),n));return l.length!==(a.sessionIds??[]).length?(r=!0,{...a,sessionIds:l}):a}),o=r?{...t,items:i}:t;return typeof t=="object"&&t!==null&&Gt.set(t,{key:s,result:o}),o}function ds(e){return e==null||typeof e!="function"&&typeof e!="object"?{}:e}function yr(e){return ds(e).__dshAutomationWrapped===!0}function ls(e){let n=new Set,t=e;for(;t!=null&&!n.has(t);){n.add(t);let s=ds(t),r=s.__dshAutomationOriginal??s.__imConnectOriginal;if(r!==void 0&&r!==t){t=r;continue}return s.__dshAutomationWrapped===!0||s.__imConnectWrapped===!0?void 0:t}}function vr(e){let n=e,t=String(n?.options?.id??""),s=String(n?.component?.displayName??n?.component?.name??"");return t==="dsh-automation-native-switcher"||t==="dsh-automation-wrap-bump"||s==="AutomationNativeWorkspaceShell"||s==="AutomationWrapBump"||yr(n?.component)}function cs(e){for(let n of e)if(n?.component!==void 0&&!vr(n))return n}function Fe(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function Ut(e,n){let t=Fe(e),s,r=-1;for(let i of n){let o=Fe(i);o.length>r&&t!==o&&t.startsWith(`${o}/`)&&(s=i,r=o.length)}return s}function us(e,n,t){let s=new Map;for(let u of n)for(let g of u.sessionIds??[])s.set(g,u);let r=new Map,i=[];for(let u of e){let g=u.id===void 0?void 0:s.get(u.id),h=g?.workspaceId??g?.id??g?.path;if(g===void 0||h===void 0||h===""){i.push(u);continue}let S=r.get(h)??[];S.push(u),r.set(h,S)}let o=new Map;for(let u of n)u.path!==void 0&&u.path!==""&&o.set(Fe(u.path),u);let a=new Map;for(let u of n){let g=u.workspaceId??u.id??u.path;if(g===void 0||g===""||!r.has(g))continue;a.set(g,u);let h=u.path,S=new Set;for(;h!==void 0&&h!==""&&!S.has(h);){S.add(h);let R=Ut(h,[...o.keys()]);if(R===void 0)break;let L=o.get(Fe(R)),H=L?.workspaceId??L?.id??L?.path;if(L===void 0||H===void 0||H==="")break;a.set(H,L),h=L.path}}let l=[...a.values()],c=l.map(u=>u.path).filter(u=>u!==void 0&&u!==""),y=u=>u.workspaceId??u.id??u.path??"",m=new Map,T=[];for(let u of l){let g=u.path===void 0?void 0:Ut(u.path,c),h=g===void 0?void 0:l.find(R=>R.path!==void 0&&Fe(R.path)===Fe(g)),S=h===void 0?void 0:y(h);if(h===void 0||S===void 0||S==="")T.push(u);else{let R=m.get(S)??[];R.push(u),m.set(S,R)}}let A=(u,g)=>(u.title||u.path||"").localeCompare(g.title||g.path||""),f=[],p=(u,g)=>{let h=y(u),S=r.get(h)??[];f.push({id:h,name:u.title||u.path||t,depth:g,keep:S.length===0,sessions:S});for(let R of(m.get(h)??[]).sort(A))p(R,g+1)};for(let u of T.sort(A))p(u,0);return i.length>0&&f.push({id:"",name:t,depth:0,sessions:i}),f}function ps(e,n,t,s="workspace"){let r=n.trim().toLocaleLowerCase(),i=e.map(o=>{if(r===""||o.name.toLocaleLowerCase().includes(r))return o;let a=o.sessions.filter(l=>`${l.title??""} ${l.label??""}`.toLocaleLowerCase().includes(r));return{...o,sessions:a}}).filter(o=>o.sessions.length>0||r===""&&o.keep===!0||r!==""&&o.name.toLocaleLowerCase().includes(r));if(s==="list"){let o=i.flatMap(a=>[...a.sessions]);return t==="time"&&o.sort((a,l)=>Zn(l)-Zn(a)),o.length===0?[]:[{...i[0],name:"",sessions:o}]}return s==="workspace-tree"||t==="manual"?i:[...i].sort((o,a)=>Bt(a)-Bt(o))}function Zn(e){let n=Date.parse(e.updatedAt??"");return Number.isFinite(n)?n:0}function Bt(e){let n=0;for(let t of e.sessions){let s=Zn(t);s>n&&(n=s)}return n}var ie=require("react/jsx-runtime");function Je({children:e,...n}){return(0,ie.jsx)("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n,children:e})}function Sn(e){return(0,ie.jsx)(Je,{...e,children:(0,ie.jsx)("path",{d:"M12 5v14M5 12h14"})})}function ms(e){return(0,ie.jsxs)(Je,{...e,children:[(0,ie.jsx)("path",{d:"M19 7v5h-5"}),(0,ie.jsx)("path",{d:"M18.1 15.5A7.5 7.5 0 1 1 19 12"})]})}function fs(e){return(0,ie.jsxs)(Je,{...e,children:[(0,ie.jsx)("rect",{x:"4",y:"5.5",width:"16",height:"14",rx:"2"}),(0,ie.jsx)("path",{d:"M8 3.8v3.4M16 3.8v3.4M4 9.5h16"})]})}function hs(e){return(0,ie.jsxs)(Je,{...e,children:[(0,ie.jsx)("circle",{cx:"12",cy:"12",r:"8.25"}),(0,ie.jsx)("path",{d:"M12 10.4V16"}),(0,ie.jsx)("path",{d:"M12 7.6h.01"})]})}function gs(e){return(0,ie.jsx)(Je,{...e,children:(0,ie.jsx)("path",{d:"M5.5 6.5h13v9.2H9.2L5.5 18.8V6.5Z"})})}function ys(e){return(0,ie.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,"aria-hidden":"true",focusable:"false",...e,children:(0,ie.jsx)("path",{fill:"currentColor",d:"M8 0a8 8 0 0 0-2.53 15.59c.4.074.547-.173.547-.385 0-.19-.007-.693-.01-1.36-2.226.484-2.695-1.073-2.695-1.073-.364-.924-.89-1.17-.89-1.17-.726-.496.055-.486.055-.486.803.056 1.225.824 1.225.824.714 1.223 1.872.87 2.328.665.072-.517.28-.87.508-1.07-1.777-.202-3.645-.888-3.645-3.956 0-.874.31-1.588.823-2.148-.083-.202-.357-1.017.078-2.12 0 0 .672-.215 2.2.82A7.65 7.65 0 0 1 8 4.8c.68.003 1.365.092 2.004.27 1.527-1.035 2.197-.82 2.197-.82.437 1.103.162 1.918.08 2.12.513.56.822 1.274.822 2.148 0 3.076-1.872 3.752-3.654 3.95.288.248.544.735.544 1.482 0 1.07-.01 1.932-.01 2.195 0 .214.144.463.55.384A8.001 8.001 0 0 0 8 0Z"})})}function vs(e){return(0,ie.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...e,children:(0,ie.jsx)("path",{d:"M9.5 2.5 13.5 6.5 6 14H2v-4z"})})}var Pe=require("react"),br=dn(require("@deepseek-ai/dsh-client-ui-primitives"),1);function xn(e,n){return function(s){return e(s)??n(s)}}function Y(e,...n){for(let t of n){let s=e[t];if(typeof s=="function")return s}return function(){return null}}var Q=br;function wr(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 3h4v3H3V3Zm6 1h4M3 10h4v3H3v-3Zm6 1.5h4M7 4.5h2M7 11.5h2",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"}))}function Sr(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"}))}function xr(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 6.5h10v6H3v-6Zm1.2-2.5h7.6L13 6.5H3L4.2 4Zm2.3 5.2 1.3 1.3 2.6-2.6",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"}))}var Ye=Y(Q,"IconEllipsisOutlineRegular"),bs=Y(Q,"IconSettingsOutlineRegular"),_e=Y(Q,"IconArchiveOutlineRegular"),ws=Y(Q,"IconBranchOutlineRegular"),Ss=Y(Q,"IconEditOutlineRegular"),Yn=Y(Q,"IconTrashOutlineRegular"),Mi=Y(Q,"IconCheckOutlineRegular"),Li=Y(Q,"IconChevronDownOutlineRegular"),Pi=Y(Q,"IconListPenOutlineRegular"),xs=Y(Q,"IconSearchOutlineRegular"),ks=Y(Q,"IconCloseFillRegular"),kn=Y(Q,"IconSlidersTwoOutlineRegular"),ze=Y(Q,"IconFolderCloseRegular"),Ts=Y(Q,"IconFolderOpenRegular"),As=Y(Q,"IconTriangleRightFillRegular"),Qn=Y(Q,"IconUnarchiveOutlineRegular"),Tn=xn(Y(Q,"IconWorkspaceTreeOutlineRegular"),wr),Ge=xn(Y(Q,"IconFlatListOutlineRegular"),Sr),Di=Y(Q,"IconChevronsUpDownOutlineRegular"),Ie=Y(Q,"IconClockOutlineRegular"),Is=Y(Q,"IconCopyOutlineRegular"),Cs=Y(Q,"IconArchiveOffOutlineRegular"),Ns=xn(Y(Q,"IconArchiveCheckOutlineRegular"),xr);var le=require("@deepseek-ai/dsh-client-ui-primitives");var et=dn(require("react"),1),Rs=require("@deepseek-ai/dsh-client-ui-primitives"),nt={width:22,minWidth:22,height:22,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"var(--dsw-radius-sm, 8px)"},Es=et.default.forwardRef(function(n,t){let{className:s,rows:r,...i}=n;return et.default.createElement("textarea",{...i,ref:t,className:["dsh-st-textarea",s].filter(Boolean).join(" "),rows:r||4})}),Ve=Rs.Input;function An(e,n){let t=e.target;if(!(t instanceof Element)||t.getAttribute("aria-hidden")!=="true")return;let s=t.parentElement?.querySelector('[role="dialog"]');!(s instanceof HTMLElement)||!s.classList.contains(n)||e.stopPropagation()}var ue=dn(require("react"),1),In=require("@deepseek-ai/dsh-client-ui-primitives");function tt(e){return{id:e.value,label:e.label,...e.disabled!==void 0?{disabled:e.disabled}:{},...e.danger!==void 0?{danger:e.danger}:{}}}function he(e){let[n,t]=ue.useState(!1),s=ue.useRef(null),r=e.options??[];ue.useEffect(()=>{if(!n)return;let c=s.current?.getBoundingClientRect().width??0;return c>0&&document.documentElement.style.setProperty("--dsh-st-menu-width",`${Math.round(c)}px`),()=>{document.documentElement.style.removeProperty("--dsh-st-menu-width")}},[n]),ue.useEffect(()=>{if(!n||typeof window>"u")return;let c=y=>{y.key==="Escape"&&(y.stopPropagation(),t(!1))};return window.addEventListener("keydown",c,!0),()=>{window.removeEventListener("keydown",c,!0)}},[n]);let i=ue.useMemo(()=>e.groups!==void 0&&e.groups.length>0?e.groups.flatMap(c=>[{type:"label",id:`label-${c.id}`,text:c.label},...c.options.map(tt)]):r.map(tt),[r,e.groups]),o=e.footer?.map(tt),a=r.find(c=>c.value===e.value)??e.groups?.flatMap(c=>[...c.options]).find(c=>c.value===e.value),l=a?a.label:e.placeholder??e.label??"";return ue.createElement("div",{ref:s,className:["dsh-st-menu-select-wrap",e.compact===!0?"is-compact":"",e.className].filter(Boolean).join(" ")},ue.createElement(In.Menu,{open:n,onClose:()=>{t(!1)},onSelect:c=>{if(e.footer?.some(y=>y.value===c)===!0){e.onFooter?.(c),t(!1);return}e.onChange(c),t(!1)},selectedId:e.value,align:"start",portal:!0,dense:!0,listClassName:["dsh-st-form-menu",e.listClassName].filter(Boolean).join(" "),...o!==void 0?{footer:o}:{},anchor:ue.createElement(In.Button,{variant:"outline",...e.compact===!0?{size:"sm"}:{},role:"combobox","aria-label":e.label??(typeof l=="string"?l:a?.text)??e.placeholder??"","aria-expanded":n,disabled:e.disabled,className:["dsh-st-menu-select-trigger",n?"is-open":""].filter(Boolean).join(" "),onClick:()=>{e.disabled||t(c=>!c)}},ue.createElement("span",{className:"dsh-st-menu-select-label"},l),ue.createElement("svg",{className:"dsh-st-menu-select-arrow",viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",style:{marginLeft:4,transition:"transform 150ms ease",transform:n?"rotate(180deg)":"none"}},ue.createElement("path",{d:"m4 6 4 4 4-4"}))),items:i}))}var me=require("react");var kr=new Map([["read-only",["permission.readOnly","Read Only"]],["workspace-write",["permission.workspaceWrite","Workspace Write"]],["danger-full-access",["permission.fullAccess","Full access"]]]);function Ms(e,n){let t=kr.get(e.value);return t!==void 0&&(e.name===e.value||e.name===t[1])?n(t[0]):e.name||e.value}function Ls(e,n){return e!==n&&n==="danger-full-access"}var be=require("@deepseek-ai/dsh-client-ui-primitives");var b=require("react/jsx-runtime");function Tr(e,n,t,s){if(e==="deepseek-account"){let r=t("provider.account");return r&&r!=="provider.account"?r:s("form.providerAccount")}return n}function Ar(e,n){return(e==="deepseek-account"?0:e==="deepseek-official"?1:2)-(n==="deepseek-account"?0:n==="deepseek-official"?1:2)}function Ir(e){return(e.provider==="deepseek-account"||e.provider==="deepseek-official")&&e.model==="deepseek-flash"?(0,b.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,b.jsx)("span",{children:e.label}),(0,b.jsx)(be.Tag,{tone:"info",children:"1017"})]}):e.label}var Cr=[1,2,3,4,5,6,7],Nr=["once","interval","hourly","daily","weekly","monthly","custom"],Rr=Array.from({length:24},(e,n)=>String(n).padStart(2,"0")),Os=Array.from({length:60},(e,n)=>String(n).padStart(2,"0"));function Hs({t:e,permissionT:n,modelT:t,busy:s,workspaces:r,models:i,modelFailures:o,defaultModel:a,skills:l,permissions:c,defaultPermission:y,draft:m,editing:T,onClose:A,onSubmit:f,onAddWorkspace:p}){let[u,g]=(0,me.useState)(()=>({...Kn(new Date,r,a,y),...m})),[h,S]=(0,me.useState)(),[R,L]=(0,me.useState)(),[H,ae]=(0,me.useState)(!1),[de,W]=(0,me.useState)(!1),[se,K]=(0,me.useState)(0),[O,z]=(0,me.useState)(0),[_,oe]=(0,me.useState)(),pe=(0,me.useRef)(null),U=(0,me.useRef)(0);(0,me.useEffect)(()=>{let d=B=>{if(B.key==="Escape"&&document.querySelector('[role="menu"]')===null){if(B.preventDefault(),B.stopPropagation(),B.stopImmediatePropagation(),R!==void 0){ae(!1),L(void 0);return}A()}},I=B=>{An(B,"dsh-st-create-dialog")};return window.addEventListener("keydown",d,!0),document.addEventListener("click",I,!0),()=>{window.removeEventListener("keydown",d,!0),document.removeEventListener("click",I,!0)}},[R,A]);let M=d=>{g(I=>({...I,...d})),S(void 0)},G=r.some(d=>d.id===u.workspaceId),x=async()=>{if(!(p===void 0||de)){W(!0),S(void 0),document.activeElement instanceof HTMLElement&&document.activeElement.blur();try{let d=await p();d!==void 0&&M({workspaceId:d})}catch(d){d instanceof qe?S(e("form.workspaceUnavailable")):d instanceof Error&&d.message!==""?S(d.message):S(e("form.addWorkspaceFailed"))}finally{W(!1)}}},V=d=>{if(Ls(u.permission,d)){ae(!1),L(d);return}M({permission:d})},q=async d=>{d?.preventDefault();try{await f(u)}catch(I){if(I instanceof ce){S(e(I.key));return}S(I instanceof Error?I.message:e("error.action"))}},ne=u.onceAt.slice(0,10),te=u.onceAt.slice(11,16)||"09:00",fe=Er(new Date),ge=i.find(d=>`${d.provider}::${d.model}`===u.modelKey)?.reasoning,J=$n(u.prompt,se),re=J===void 0||_===J.query?[]:Tt(l,J.query),ye=Math.min(O,Math.max(re.length-1,0)),we=d=>{U.current=d,K(d)};(0,me.useEffect)(()=>{let d=document.querySelector('.dsh-st-skill-menu [aria-selected="true"]');d instanceof HTMLElement&&d.scrollIntoView({block:"nearest"})},[ye,J?.query]);let k=d=>{let I=At(u.prompt,U.current,un(d));M({prompt:I.text}),oe(void 0),queueMicrotask(()=>{let B=pe.current;B!=null&&(B.focus(),B.setSelectionRange(I.caret,I.caret),we(I.caret))})};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(be.Modal,{open:!0,className:"dsh-st-create-dialog",title:e(T===!0?"modal.edit":"modal.title"),closeLabel:e("form.cancel"),onClose:A,footer:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(be.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:s,onClick:A,children:e("form.cancel")}),(0,b.jsx)(be.Button,{variant:"primary",className:"dsh-st-modal-action",type:"submit",form:"dsh-st-create-form",disabled:s||de||!G,children:e("modal.save")})]}),children:(0,b.jsxs)("form",{id:"dsh-st-create-form",className:"dsh-st-form",onSubmit:d=>{q(d)},children:[(0,b.jsx)("p",{children:e("form.subtitle")}),(0,b.jsxs)("label",{className:"dsh-st-field",children:[e("form.name"),(0,b.jsx)(Ve,{value:u.name,placeholder:e("form.namePlaceholder"),onChange:d=>M({name:d.target.value})})]}),(0,b.jsxs)("div",{className:"dsh-st-plan-row",children:[(0,b.jsxs)("div",{className:"dsh-st-field",children:[e("form.planTime"),(0,b.jsxs)("div",{className:"dsh-st-inline",children:[(0,b.jsx)(he,{value:u.scheduleKind,options:Nr.map(d=>({value:d,label:e(`form.${d}`)})),onChange:d=>M({scheduleKind:d})}),u.scheduleKind==="once"&&(0,b.jsx)(Ve,{type:"date",min:fe,value:ne,onChange:d=>M({onceAt:Ds(`${d.target.value}T${te}`)})}),(u.scheduleKind==="once"||u.scheduleKind==="daily"||u.scheduleKind==="weekly"||u.scheduleKind==="monthly")&&(0,b.jsx)(Ps,{value:u.scheduleKind==="once"?te:u.time,onChange:d=>{u.scheduleKind==="once"?M({onceAt:Ds(`${ne}T${d}`)}):M({time:d})}}),u.scheduleKind==="interval"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.every")}),(0,b.jsxs)("span",{className:"dsh-st-amount",children:[(0,b.jsx)(Ve,{type:"number",min:1,value:u.everyMinutes,onChange:d=>M({everyMinutes:d.target.value})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.minutes")})]})]}),u.scheduleKind==="hourly"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(he,{value:u.hourlyMinute,options:Os.map(d=>({value:d,label:d})),onChange:d=>M({hourlyMinute:d})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.minutesShort")})]}),u.scheduleKind==="monthly"&&(0,b.jsx)(he,{value:u.monthDay,options:Array.from({length:31},(d,I)=>{let B=String(I+1);return{value:B,label:e("form.monthDay",{day:B})}}),onChange:d=>M({monthDay:d})}),u.scheduleKind==="custom"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.every")}),(0,b.jsxs)("span",{className:"dsh-st-amount",children:[(0,b.jsx)(Ve,{type:"number",min:1,value:u.customDays,onChange:d=>M({customDays:d.target.value})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.daysShort")})]}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.atTime")}),(0,b.jsx)(Ps,{value:u.time,onChange:d=>M({time:d})})]})]}),u.scheduleKind==="interval"&&(0,b.jsx)("span",{className:"dsh-st-plan-hint",children:e("form.intervalHint")}),u.scheduleKind==="custom"&&(0,b.jsx)("span",{className:"dsh-st-plan-hint",children:e("form.customHint")})]}),(0,b.jsxs)("label",{className:"dsh-st-field dsh-st-concurrency",title:e("form.maxConcurrentRunsHint"),children:[e("form.maxConcurrentRuns"),(0,b.jsx)(Ve,{type:"number",min:1,step:1,value:u.maxConcurrentRuns,onChange:d=>M({maxConcurrentRuns:d.target.value})})]})]}),u.scheduleKind==="weekly"&&(0,b.jsx)("div",{className:"dsh-st-weekdays",children:Cr.map(d=>(0,b.jsx)(be.Checkbox,{checked:u.weekdays.includes(d),label:e(`day.${d}`),onChange:I=>M({weekdays:I?[...u.weekdays,d]:u.weekdays.filter(B=>B!==d)})},d))}),(0,b.jsxs)("div",{className:"dsh-st-settings",children:[(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldWorkspace")}),r.length===0?(0,b.jsxs)("div",{className:"dsh-st-workspace-empty",children:[(0,b.jsx)(be.Button,{variant:"primary",icon:(0,b.jsx)(Sn,{width:14,height:14}),disabled:de,onClick:()=>{x()},children:e("form.addWorkspace")}),(0,b.jsx)("span",{className:"dsh-st-workspace-note",children:e("form.workspaceRequired")})]}):(0,b.jsx)(he,{value:u.workspaceId,label:e("form.fieldWorkspace"),placeholder:e("form.workspace"),options:r.map(d=>({value:d.id,label:d.title})),footer:[{value:"add-workspace",label:e("form.addWorkspace"),disabled:de}],onFooter:()=>{x()},onChange:d=>M({workspaceId:d})})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldModel")}),(0,b.jsx)(he,{value:u.modelKey,label:e("form.fieldModel"),groups:Array.from(i.reduce((d,I)=>{let B=Tr(I.provider,I.providerLabel,t,e),Ce=d.get(I.provider)??{label:B,options:[]};return Ce.options.push({value:`${I.provider}::${I.model}`,label:Ir(I),text:I.label}),d.set(I.provider,Ce),d},new Map)).sort(([d],[I])=>Ar(d,I)).map(([d,I])=>({id:d,label:I.label,options:I.options})),onChange:d=>{let I=i.find(B=>`${B.provider}::${B.model}`===d);M({modelKey:d,reasoningEffort:I?.reasoning?.defaultEffort??"none"})}})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldEffort")}),(0,b.jsx)(he,{disabled:ge===void 0,value:ge===void 0?"":u.reasoningEffort,label:e("form.fieldEffort"),placeholder:t("effort.providerDefault"),options:ge===void 0?[]:[...ge.defaultEffort===void 0?[{value:"none",label:t("effort.providerDefault")}]:[],...ge.efforts.map(d=>({value:d.id,label:d.name}))],onChange:d=>M({reasoningEffort:d})})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldPermission")}),(0,b.jsx)(he,{value:u.permission,options:c.map(d=>({value:d.value,label:Ms(d,e)})),onChange:d=>V(d)})]})]}),(0,b.jsxs)("div",{className:"dsh-st-field",children:[(0,b.jsxs)("span",{className:"dsh-st-prompt-label",children:[e("form.prompt"),(0,b.jsx)("em",{children:e("form.slashHint")})]}),(0,b.jsxs)("div",{className:"dsh-st-prompt-anchor",children:[J!==void 0&&_!==J.query&&(0,b.jsx)("div",{className:"dsh-st-skill-menu",role:"listbox",children:re.length===0?(0,b.jsx)("p",{children:e("form.slashEmpty")}):re.map((d,I)=>(0,b.jsxs)("button",{type:"button",role:"option","aria-selected":I===ye,onMouseDown:B=>B.preventDefault(),onClick:()=>k(d),children:[(0,b.jsx)("span",{children:d.name}),(0,b.jsx)("code",{children:un(d)})]},d.id))}),(0,b.jsxs)("div",{className:"dsh-st-prompt-card",children:[(0,b.jsx)("div",{className:"dsh-st-prompt-backdrop","aria-hidden":"true",children:It(u.prompt,l).map((d,I)=>d.kind==="skill"?(0,b.jsx)("span",{className:"dsh-st-skill-token",children:d.text},I):(0,b.jsx)("span",{children:d.text},I))}),(0,b.jsx)(Es,{ref:pe,spellCheck:!1,className:"dsh-st-prompt-input",value:u.prompt,placeholder:e("form.promptPlaceholder"),rows:4,onChange:d=>{we(d.target.selectionStart),M({prompt:d.target.value}),oe(void 0)},onSelect:d=>we(d.currentTarget.selectionStart),onScroll:d=>{let I=d.currentTarget.closest(".dsh-st-prompt-card")?.querySelector(".dsh-st-prompt-backdrop");I instanceof HTMLElement&&(I.scrollTop=d.currentTarget.scrollTop)},onKeyDown:d=>{if(J!==void 0){if(d.key==="Escape"){d.preventDefault(),oe(J.query);return}if(re.length!==0){if(d.key==="ArrowDown")d.preventDefault(),z(I=>(Math.min(I,re.length-1)+1)%re.length);else if(d.key==="ArrowUp")d.preventDefault(),z(I=>(Math.min(I,re.length-1)+re.length-1)%re.length);else if(d.key==="Enter"||d.key==="Tab"){d.preventDefault();let I=re[ye];I!==void 0&&k(I)}}}}})]})]})]}),o.map(d=>(0,b.jsx)("p",{className:"dsh-st-error",children:t("warning.groupLoad",{name:d.providerLabel,message:d.message})},d.provider)),h!==void 0&&(0,b.jsx)("p",{className:"dsh-st-error",children:h})]})}),(0,b.jsx)(be.RiskConfirmation,{open:R!==void 0,title:n("confirm.title"),description:n("confirm.description"),acknowledgeLabel:n("confirm.acknowledge"),cancelLabel:n("confirm.cancel"),closeLabel:n("confirm.cancel"),confirmLabel:n("confirm.enable"),acknowledged:H,onAcknowledgedChange:ae,onCancel:()=>{ae(!1),L(void 0)},onConfirm:()=>{!H||R===void 0||(M({permission:R}),ae(!1),L(void 0))}})]})}function Ps({value:e,onChange:n}){let[t,s]=e.split(":");return(0,b.jsxs)("span",{className:"dsh-st-time",children:[(0,b.jsx)(he,{value:t,options:Rr.map(r=>({value:r,label:r})),onChange:r=>n(`${r}:${s}`)}),(0,b.jsx)("span",{className:"dsh-st-time-sep",children:":"}),(0,b.jsx)(he,{value:s,options:Os.map(r=>({value:r,label:r})),onChange:r=>n(`${t}:${r}`)})]})}function Er(e){let n=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-n).toISOString().slice(0,10)}function Ds(e){let n=new Date(e),t=new Date;if(!Number.isFinite(n.getTime())||n.getTime()>t.getTime())return e;let s=new Date(t.getTime()+6e4);s.setSeconds(0,0);let r=s.getTimezoneOffset()*6e4;return new Date(s.getTime()-r).toISOString().slice(0,16)}var Fs=require("react"),Qe=require("@deepseek-ai/dsh-client-ui-primitives");var Re=require("react/jsx-runtime");function Ws({target:e,t:n,busy:t,onCancel:s,onConfirm:r}){return(0,Fs.useEffect)(()=>{if(e===void 0)return;let i=a=>{a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation(),s())},o=a=>{An(a,"dsh-st-delete-dialog")};return window.addEventListener("keydown",i,!0),document.addEventListener("click",o,!0),()=>{window.removeEventListener("keydown",i,!0),document.removeEventListener("click",o,!0)}},[s,e]),(0,Re.jsx)(Qe.Modal,{open:e!==void 0,className:"dsh-st-delete-dialog",title:n("card.confirmDelete"),...e===void 0?{}:{description:`${e.name} ${n("card.confirmDeleteHint")}`},closeLabel:n("card.cancel"),onClose:s,footer:(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)(Qe.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:t,onClick:s,children:n("card.cancel")}),(0,Re.jsx)(Qe.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:t,onClick:r,children:n("card.confirm")})]})})}var en=null,st=new Set;function _s(e){en=e;for(let n of[...st])n(en)}function ot(){let e=en;return en=null,e}function zs(){return en}function Gs(e){return st.add(e),()=>{st.delete(e)}}function Vs(e){let n=document.querySelector("[data-composer-seat] textarea");return n instanceof HTMLTextAreaElement?(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set?.call(n,e),n.dispatchEvent(new InputEvent("input",{bubbles:!0})),n.focus(),!0):!1}function nn(e){if(typeof e!="object"||e===null||!("ok"in e))throw new Error("\u81EA\u52A8\u5316\u4E3B\u673A\u8FD4\u56DE\u4E86\u65E0\u6548\u54CD\u5E94\u3002");let n=e;if(n.ok===!0&&"value"in n)return n.value;if(n.ok===!1&&"error"in n){let t=n.error;throw new Error(t?.message??"\u81EA\u52A8\u5316\u8BF7\u6C42\u5931\u8D25\u3002")}throw new Error("\u81EA\u52A8\u5316\u4E3B\u673A\u8FD4\u56DE\u4E86\u65E0\u6548\u54CD\u5E94\u3002")}var tn="/dsh-automation",Bs=15e3,Mr=2e3,$s=[1,2,4],Us=$s.length+1,Lr=5*60*1e3,Pr=24*60*60*1e3;function Dr(e){return(e??[]).some(n=>n.status==="running"||n.status==="queued")?Mr:Bs}function rt(e,n){return n>0?Dr(e):Bs}function it(e){let n=e instanceof Error?e.message:String(e);return/failed to fetch|networkerror|load failed|network request failed/i.test(n)}function Or(e,n){let t=Date.parse(n),r=(Number.isFinite(t)?t:Date.now())-Pr;return[...new Set(e.filter(i=>{if(i.status==="queued"||i.status==="running")return!0;let o=Date.parse(i.finishedAt??i.startedAt??i.scheduledFor);return Number.isFinite(o)&&o>=r}).map(i=>i.sessionId).filter(i=>i!==void 0&&i!==""))].sort()}function Ks(e,n,t={}){let s=!1,r=0,i=e.source.getSnapshot().phase==="loading",o,a,l=0,c=0,y=0,m,T,A=!1,f=h=>{a=h,l=0,c=r,y=0,m=void 0},p=h=>{let S=e.source.getSnapshot().snapshot,R=h?.list?.getSnapshot();if(S===void 0||R===void 0||h?.refresh===void 0)return;let L=new Set([...R.ids??[],...Object.keys(R.byId??{})]);return Or(S.runs,S.serverNow).filter(H=>!L.has(H)).join("\0")},u=()=>{if(s)return;let h=n();h!==o&&(o=h,f());let S=p(h);if(S===void 0)return;if(S===""){f();return}if(S!==a&&f(S),l>=Us){if((t.now??Date.now)()<y)return;f(S)}if(r<c)return;if(T!==void 0){A=!0;return}let R=l;l+=1;let L=$s[R];c=L===void 0?Number.POSITIVE_INFINITY:r+L,l>=Us&&(y=(t.now??Date.now)()+Lr),T=Promise.resolve().then(async()=>{await h.refresh()}).catch(H=>{!s&&m!==S&&(m=S,console.warn("[dsh-automation] \u5237\u65B0 Host \u4F1A\u8BDD\u5217\u8868\u5931\u8D25",H))}).finally(()=>{T=void 0,!(s||!A)&&(A=!1,u())})},g=e.source.subscribe(()=>{e.source.getSnapshot().phase==="loading"?i=!0:i&&(i=!1,r+=1),u()},{background:!0});return u(),()=>{s=!0,A=!1,g()}}function js(e){let n={phase:"idle"},t,s,r=()=>{},i=new Set,o=new Set,a=()=>{if(s!==void 0&&clearInterval(s),i.size===0){s=void 0;return}s=setInterval(()=>{m().catch(()=>{})},rt(n.snapshot?.runs,o.size))},l=()=>{if(r(),o.size===0)return;let f=()=>{m().catch(()=>{})},p=()=>{document.visibilityState==="visible"&&f()};typeof window<"u"&&window.addEventListener("focus",f),typeof document<"u"&&document.addEventListener("visibilitychange",p),r=()=>{typeof window<"u"&&window.removeEventListener("focus",f),typeof document<"u"&&document.removeEventListener("visibilitychange",p),r=()=>{}}},c=f=>{let p=rt(n.snapshot?.runs,o.size);n=f,i.size>0&&p!==rt(n.snapshot?.runs,o.size)&&a();for(let u of[...i])u()},y={getSnapshot:()=>n,subscribe:(f,p={})=>{let u=i.size>0,g=o.size>0;return i.add(f),p.background!==!0&&o.add(f),(!u||p.background!==!0&&!g)&&queueMicrotask(()=>{i.size>0&&m().catch(()=>{})}),a(),o.size>0&&!g&&l(),()=>{i.delete(f),o.delete(f),i.size===0&&s!==void 0?(clearInterval(s),s=void 0):i.size>0&&a(),o.size===0&&r()}}},m=async()=>{if(t!==void 0)return t;let f=n.snapshot;return c(f===void 0?{phase:"loading"}:{phase:"loading",snapshot:f,...n.refreshedAt===void 0?{}:{refreshedAt:n.refreshedAt}}),t=(async()=>{try{let p=await e.call(tn,"snapshot",{sessionId:"settings"}),u=nn(p);c({phase:"ready",snapshot:u,refreshedAt:Date.now()})}catch(p){let u=p instanceof Error?p.message:String(p);throw c(f===void 0?{phase:"error",error:u}:{phase:"error",snapshot:f,error:u,...n.refreshedAt===void 0?{}:{refreshedAt:n.refreshedAt}}),p}finally{t=void 0}})(),t},T=async(f,p)=>{try{return await e.call(tn,f,p)}catch(u){if(!it(u))throw u;return await e.call(tn,f,p)}},A=async(f,p,u)=>{nn(await T(f,p));let g=()=>{u!==void 0&&n.snapshot!==void 0&&c({phase:"ready",snapshot:u(n.snapshot),refreshedAt:Date.now()})},h=t;g(),h!==void 0&&(await h.catch(()=>{}),g());try{await m()}catch{}};return{source:y,refresh:m,async createAutomation(f){await A("create",{sessionId:"settings",input:f})},async mutateAutomation(f,p){await A("mutate",{sessionId:"settings",automationId:f,mutation:p},p==="delete"?g=>({...g,automations:g.automations.filter(h=>h.id!==f)}):g=>({...g,automations:g.automations.map(h=>h.id===f?{...h,status:p==="pause"?"paused":"active"}:h)}))},async updateAutomation(f,p){await A("update",{sessionId:"settings",automationId:f,input:p})},async runNow(f){await A("run-now",{sessionId:"settings",automationId:f})},async markRunRead(f){await A("mark-read",{sessionId:"settings",runId:f})},async registerWorkspace(f){let p=nn(await e.call(tn,"register-workspace",{path:f}));return await m(),p},async adoptSession(f){nn(await e.call(tn,"adopt-session",{sessionId:f}))},async forgetSession(f){await A("forget-session",{sessionId:f},p=>({...p,runs:p.runs.map(u=>{if(u.sessionId!==f)return u;let{sessionId:g,...h}=u;return h})}))},async forgetAutomationSessions(f){await A("forget-automation-sessions",{automationId:f},p=>({...p,runs:p.runs.map(u=>{if(u.automationId!==f)return u;let{sessionId:g,...h}=u;return h})}))}}}var at=require("react"),Ue=require("@deepseek-ai/dsh-client-ui-primitives");var Se=require("react/jsx-runtime"),Hr=[["created","desc"],["created","asc"],["planned","asc"],["planned","desc"]];function Cn({t:e,storage:n,storageKey:t,sortKey:s,sortDirection:r,onSelect:i,iconOnly:o=!1,className:a}){let[l,c]=(0,at.useState)(!1),[y,m]=(0,at.useState)(()=>Ne(n,t)),T=e(s==="planned"?`sort.planned.${r}`:`sort.created.${r}`),A=y?.key===s&&y.direction===r,f=()=>{n===void 0||A||(Pt(n,t,s,r),m({key:s,direction:r}))},p=[...Hr.map(([g,h])=>({id:`${g}-${h}`,label:e(g==="planned"?`sort.planned.${h}`:`sort.created.${h}`)})),...n===void 0?[]:[{type:"separator",id:"sort-default-sep"},{id:"save-default",label:e(A?"sort.default.saved":"sort.default.save")}]],u=o?(0,Se.jsx)(Ue.Tooltip,{label:T,side:"bottom",delayMs:500,disabled:l,portal:!0,children:(0,Se.jsx)("button",{type:"button",className:l?"dsh-st-n-head-btn is-on":"dsh-st-n-head-btn","aria-label":T,"aria-expanded":l,onClick:()=>c(g=>!g),children:(0,Se.jsx)(kn,{size:16})})}):(0,Se.jsxs)(Ue.Button,{variant:"outline",size:"sm",role:"combobox","aria-label":T,"aria-expanded":l,className:["dsh-st-menu-select-trigger",l?"is-open":""].filter(Boolean).join(" "),onClick:()=>c(g=>!g),children:[(0,Se.jsx)("span",{className:"dsh-st-menu-select-label",children:T}),(0,Se.jsx)("svg",{className:"dsh-st-menu-select-arrow",viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",style:{marginLeft:4,transition:"transform 150ms ease",transform:l?"rotate(180deg)":"none"},children:(0,Se.jsx)("path",{d:"m4 6 4 4 4-4"})})]});return(0,Se.jsx)("div",{className:["dsh-st-menu-select-wrap",a].filter(Boolean).join(" "),style:{display:"inline-flex",verticalAlign:"middle"},children:(0,Se.jsx)(Ue.Menu,{open:l,onClose:()=>c(!1),selectedId:`${s}-${r}`,align:o?"end":"start",portal:!0,dense:!0,anchor:u,items:p,onSelect:g=>{if(g==="save-default"){f(),c(!1);return}let[h,S]=g.split("-");i(h,S),c(!1)}})})}var Nn="dsh-automation:open-task-settings",dt="dsh-automation:pending-task-settings";function lt(e){if(typeof e!="object"||e===null)return;let n=e;if(!(typeof n.name!="string"||n.name.trim()===""||!Array.isArray(n.sessionIds)||n.sessionIds.some(t=>typeof t!="string"))&&!(n.automationId!==void 0&&(typeof n.automationId!="string"||n.automationId.trim()==="")))return{...typeof n.automationId=="string"?{automationId:n.automationId}:{},name:n.name,sessionIds:[...n.sessionIds]}}function Fr(e,n){try{e?.setItem(dt,JSON.stringify(n))}catch{}}function ct(e){typeof window>"u"||(Fr(window.sessionStorage,e),window.dispatchEvent(new CustomEvent(Nn,{detail:e})))}function qs(e){if(e!==void 0)try{let n=e.getItem(dt);return n===null?void 0:lt(JSON.parse(n))}catch{return}}function Zs(e){try{e?.removeItem(dt)}catch{}}function Xs(e,n,t){if(e.automationId!==void 0){let a=n.find(l=>l.id===e.automationId);if(a!==void 0)return a}let s=new Set(e.sessionIds),r=t.find(a=>a.sessionId!==void 0&&s.has(a.sessionId))?.automationId,i=n.find(a=>a.id===r);if(i!==void 0)return i;let o=n.filter(a=>a.name===e.name);return o.length===1?o[0]:void 0}var w=require("react/jsx-runtime");var Rn=typeof window>"u"?void 0:window.localStorage,Js=typeof window>"u"?void 0:window.sessionStorage,Wr=[{name:"\u6BCF\u65E5\u56DE\u5F52\u68C0\u67E5",scheduleKind:"daily",time:"09:00",weekdays:[1,2,3,4,5]},{name:"\u6BCF\u5468\u4F9D\u8D56\u5DE1\u68C0",scheduleKind:"weekly",time:"10:00",weekdays:[1]},{name:"\u5DE5\u4F5C\u65E5\u65E9\u62A5",scheduleKind:"weekly",time:"08:00",weekdays:[1,2,3,4,5]}];function Ys({t:e,permissionT:n,modelT:t,runtime:s,closeSettings:r,addWorkspace:i}){let o=(0,ee.useSyncExternalStore)(s.source.subscribe,s.source.getSnapshot,s.source.getSnapshot),[a,l]=(0,ee.useState)("mine"),[c,y]=(0,ee.useState)(""),[m,T]=(0,ee.useState)(!1),[A,f]=(0,ee.useState)(),[p,u]=(0,ee.useState)(),[g,h]=(0,ee.useState)(),[S,R]=(0,ee.useState)(!1),[L,H]=(0,ee.useState)(),[ae,de]=(0,ee.useState)("day"),[W,se]=(0,ee.useState)("all"),[K,O]=(0,ee.useState)("all"),[z,_]=(0,ee.useState)(()=>Ne(Rn,hn)?.key??"created"),[oe,pe]=(0,ee.useState)(()=>Ne(Rn,hn)?.direction??"desc"),[U,M]=(0,ee.useState)(()=>qs(Js)),G=(0,ee.useMemo)(()=>new Date(o.snapshot?.serverNow??Date.now()),[o.snapshot?.serverNow,o.refreshedAt]),x=o.snapshot,V=x?.workspaces??[],q=x?.models??[],ne=x?.permissions??[],te=x?.defaultPermission??"",fe=fn((x?.automations??[]).filter(k=>c.trim()===""||`${k.name} ${k.prompt}`.toLowerCase().includes(c.trim().toLowerCase())),z,oe),xe=(x?.runs??[]).filter(k=>!(W!=="all"&&k.automationId!==W||K!=="all"&&k.status!==K)),ge=Dt(xe,ae,G,e),J=async k=>{R(!0),H(void 0);try{await k()}catch(d){H(d instanceof ce?e(d.key):it(d)?e("error.offline"):d instanceof Error?d.message:e("error.action"))}finally{R(!1)}},re=()=>{T(!1),h(void 0),f(void 0)},ye=k=>{te===""||ne.length===0||(f(void 0),h(k),T(!0))},we=k=>{f(k.id),h(Ot(k,V,x?.defaultModel??null,x?.defaultPermission??k.permission)),T(!0)};return(0,ee.useEffect)(()=>{if(typeof window>"u")return;let k=d=>{let I=lt(d.detail);I!==void 0&&M(I)};return window.addEventListener(Nn,k),()=>{window.removeEventListener(Nn,k)}},[]),(0,ee.useEffect)(()=>{if(U===void 0||x===void 0)return;let k=Xs(U,x.automations,x.runs);if(Zs(Js),M(void 0),l("mine"),y(""),k===void 0){H(e("error.taskMissing"));return}we(k)},[x,U,e]),(0,w.jsxs)("div",{className:"dsh-st-shell",children:[(0,w.jsxs)("header",{className:"dsh-st-top",children:[(0,w.jsxs)("div",{className:"dsh-st-heading",children:[(0,w.jsxs)("div",{className:"dsh-st-heading-row",children:[(0,w.jsx)("h1",{children:e("tab")}),(0,w.jsxs)("div",{className:"dsh-st-heading-links",children:[(0,w.jsx)(le.Button,{variant:"outline",size:"sm","aria-label":e("header.githubProject"),icon:(0,w.jsx)(ys,{}),onClick:()=>{window.open("https://github.com/MichengAI/dsh-automation","_blank","noreferrer")},children:e("header.githubProject")}),(0,w.jsx)(le.Button,{variant:"outline",size:"sm","aria-label":e("header.githubFeedback"),icon:(0,w.jsx)(vs,{}),onClick:()=>{window.open("https://github.com/MichengAI/dsh-automation/issues","_blank","noreferrer")},children:e("header.githubFeedback")})]})]}),(0,w.jsx)("p",{children:e("header.lead")})]}),(0,w.jsxs)("div",{className:"dsh-st-toolbar",children:[(0,w.jsx)(le.Input,{className:"dsh-st-search",value:c,placeholder:e("search.placeholder"),onChange:k=>y(k.target.value)}),(0,w.jsx)(le.Button,{variant:"outline",icon:(0,w.jsx)(gs,{}),onClick:()=>{_s(e("chat.prompt")),r?.()},children:e("action.chatCreate")}),(0,w.jsx)(le.Button,{variant:"primary",icon:(0,w.jsx)(Sn,{}),disabled:te===""||ne.length===0,onClick:()=>ye(),children:e("action.create")}),(0,w.jsx)(le.Button,{className:"dsh-st-row-icon",variant:"outline",size:"sm",icon:(0,w.jsx)(ms,{}),"aria-label":e("section.refresh"),style:nt,onClick:()=>{s.refresh()}})]})]}),(0,w.jsx)("div",{className:"dsh-st-banner",role:"note",children:(0,w.jsxs)("span",{children:[(0,w.jsx)(hs,{}),e("banner.wake")]})}),(0,w.jsxs)("section",{className:"dsh-st-examples",children:[(0,w.jsx)("div",{className:"dsh-st-examples-head",children:(0,w.jsx)("h2",{children:e("examples.title")})}),(0,w.jsx)("div",{className:"dsh-st-example-row",children:Wr.map((k,d)=>(0,w.jsxs)("button",{type:"button",className:"dsh-st-example",disabled:te===""||ne.length===0,onClick:()=>ye({name:e(`examples.${d+1}.title`),prompt:e(`examples.${d+1}.body`),scheduleKind:k.scheduleKind,time:k.time,weekdays:k.weekdays}),children:[(0,w.jsx)("strong",{children:e(`examples.${d+1}.title`)}),(0,w.jsx)("p",{children:e(`examples.${d+1}.body`)}),(0,w.jsxs)("span",{className:"dsh-st-chip",children:[(0,w.jsx)(Ie,{size:14}),e(`examples.${d+1}.chip`)]})]},k.name))})]}),L!==void 0&&(0,w.jsx)("p",{className:"dsh-st-error",children:L}),(o.phase==="idle"||o.phase==="loading"&&x===void 0)&&(0,w.jsx)("p",{className:"dsh-st-muted",children:e("loading")}),o.phase==="error"&&x===void 0&&(0,w.jsxs)("div",{className:"dsh-st-empty",children:[(0,w.jsx)("h3",{children:e("error.title")}),(0,w.jsx)("p",{children:o.error}),(0,w.jsx)(le.Button,{variant:"primary",onClick:()=>{s.refresh()},children:e("error.retry")})]}),(0,w.jsxs)("div",{className:"dsh-st-tabs",children:[(0,w.jsx)(le.SegmentedTabs,{className:"dsh-st-settings-tabs",label:e("tab"),value:a,items:[{value:"mine",id:"dsh-st-tab-mine",panelId:"dsh-st-panel-mine",label:(0,w.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,w.jsx)(Ie,{}),(0,w.jsx)("span",{children:e("tabs.mine")})]})},{value:"runs",id:"dsh-st-tab-runs",panelId:"dsh-st-panel-runs",label:(0,w.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,w.jsx)(Ge,{}),(0,w.jsx)("span",{children:e("tabs.runs")})]})}],onChange:l}),a==="mine"&&(0,w.jsx)("div",{className:"dsh-st-sort-wrap",children:(0,w.jsx)(Cn,{t:e,...Rn===void 0?{}:{storage:Rn},storageKey:hn,sortKey:z,sortDirection:oe,onSelect:(k,d)=>{_(k),pe(d)}})}),a==="runs"&&(0,w.jsxs)("div",{className:"dsh-st-filters",children:[(0,w.jsx)(he,{compact:!0,className:"dsh-st-filter-range",value:ae,options:["day","week","month"].map(k=>({value:k,label:e(`history.range.${k}`)})),onChange:k=>de(k)}),(0,w.jsx)(he,{compact:!0,className:"dsh-st-filter-task",value:W,options:[{value:"all",label:e("history.allTasks")},...(x?.automations??[]).map(k=>({value:k.id,label:k.name}))],onChange:se}),(0,w.jsx)(he,{compact:!0,className:"dsh-st-filter-status",value:K,options:[{value:"all",label:e("history.allStatus")},...Lt.map(k=>({value:k,label:e(`status.${k}`)}))],onChange:k=>O(k)})]})]}),a==="mine"&&(fe.length===0?(0,w.jsxs)("div",{id:"dsh-st-panel-mine",role:"tabpanel","aria-labelledby":"dsh-st-tab-mine",className:"dsh-st-empty",children:[(0,w.jsx)("h3",{children:e("empty.title")}),(0,w.jsx)("p",{children:e("empty.body")})]}):(0,w.jsx)("div",{id:"dsh-st-panel-mine",role:"tabpanel","aria-labelledby":"dsh-st-tab-mine",className:"dsh-st-grid",children:fe.map(k=>(0,w.jsx)(_r,{item:k,t:e,now:G,busy:S,onEdit:()=>we(k),onToggle:()=>{J(()=>s.mutateAutomation(k.id,bn(k.status)))},onRun:()=>{J(()=>s.runNow(k.id))},onDelete:()=>u(k)},k.id))})),a==="runs"&&(ge.length===0?(0,w.jsx)("div",{id:"dsh-st-panel-runs",role:"tabpanel","aria-labelledby":"dsh-st-tab-runs",className:"dsh-st-empty",children:e("runs.empty")}):(0,w.jsx)("div",{id:"dsh-st-panel-runs",role:"tabpanel","aria-labelledby":"dsh-st-tab-runs",className:"dsh-st-timeline",children:ge.map(k=>(0,w.jsxs)("section",{className:"dsh-st-group",children:[(0,w.jsx)("h3",{children:k.label}),k.items.map(d=>(0,w.jsx)(zr,{run:d,t:e},d.id))]},k.key))})),m&&(0,w.jsx)(Hs,{t:e,permissionT:n,modelT:t,busy:S,workspaces:V,models:q,modelFailures:x?.modelFailures??[],defaultModel:x?.defaultModel??null,skills:x?.skills??[],permissions:ne,defaultPermission:te,editing:A!==void 0,...g===void 0?{}:{draft:g},onClose:re,...i===void 0?{}:{onAddWorkspace:i},onSubmit:async k=>{let d=Nt(k,V,q,new Date,{allowPastOnce:A!==void 0});await J(async()=>{A===void 0?await s.createAutomation(d):await s.updateAutomation(A,d),re()})}},A??"create"),(0,w.jsx)(Ws,{target:p,t:e,busy:S,onCancel:()=>u(void 0),onConfirm:()=>{let k=p;k!==void 0&&J(async()=>{await s.mutateAutomation(k.id,"delete"),u(void 0)})}})]})}function _r({item:e,t:n,now:t,busy:s,onEdit:r,onToggle:i,onRun:o,onDelete:a}){let[l,c]=(0,ee.useState)(!1);return(0,w.jsxs)("article",{className:"dsh-st-card",onClick:r,children:[(0,w.jsxs)("div",{className:"dsh-st-card-head",children:[(0,w.jsx)("span",{onClick:y=>y.stopPropagation(),children:(0,w.jsx)(le.Switch,{checked:e.status==="active",disabled:s,label:e.status==="active"?n("card.pause"):n("card.resume"),onChange:()=>i()})}),(0,w.jsx)("span",{onClick:y=>y.stopPropagation(),children:(0,w.jsx)(le.Menu,{open:l,onClose:()=>c(!1),align:"end",portal:!0,dense:!0,anchor:(0,w.jsx)(le.Tooltip,{label:n("card.more"),side:"bottom",delayMs:500,portal:!0,children:(0,w.jsx)("button",{type:"button",className:"dsh-st-row-icon","aria-label":n("card.more"),style:{...nt,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,border:"1px solid var(--dsw-alias-border-l2, rgba(255,255,255,.15))",borderRadius:"var(--dsw-radius-sm, 6px)",background:"transparent",color:"var(--dsw-alias-label-secondary)",cursor:"pointer"},onClick:()=>c(y=>!y),children:(0,w.jsx)(Ye,{size:16})})}),items:[{id:"run",label:n("menu.run"),disabled:s},{id:"edit",label:n("menu.edit"),disabled:s},{id:"delete",label:n("menu.delete"),danger:!0,disabled:s}],onSelect:y=>{c(!1),y==="run"&&o(),y==="edit"&&r(),y==="delete"&&a()}})})]}),(0,w.jsx)("h3",{children:e.name}),(0,w.jsx)("p",{children:e.prompt}),(0,w.jsxs)("div",{className:"dsh-st-card-foot",children:[(0,w.jsxs)("span",{className:"dsh-st-chip",children:[(0,w.jsx)(Ie,{size:14}),pn(e.schedule,n)]}),(0,w.jsx)("span",{children:e.nextRunAt===void 0?n("stats.noneScheduled"):n("history.nextApprox",{when:mn(e.nextRunAt,t,n)})})]})]})}function zr({run:e,t:n}){let t=Et(e.startedAt,e.finishedAt);return(0,w.jsxs)("article",{className:`dsh-st-run is-${e.status}`,children:[(0,w.jsx)("strong",{children:e.automationName}),(0,w.jsxs)("p",{children:[(0,w.jsx)("span",{children:Mt(e.startedAt??e.scheduledFor)}),t!==void 0&&(0,w.jsx)("span",{children:t}),(0,w.jsx)("span",{children:kt(e.trigger,n)})]})]})}var Be="dsh-automation",Qs={tab:"Scheduled tasks","sidebar.tab":"Scheduled","sidebar.tabs":"Workspace views","sidebar.tasksTab":"Tasks","sidebar.channelsTab":"Channels","sidebar.views":"Scheduled views","sidebar.viewOverview":"Task overview","sidebar.runsTab":"Records","sidebar.overviewTab":"Tasks","sidebar.empty":"No scheduled runs yet.","sidebar.tasksEmpty":"No web tasks yet.","sidebar.ungrouped":"Ungrouped","sidebar.section":"Scheduled","sidebar.workspaces":"Workspaces","sidebar.search":"Search","sidebar.sessions":"Sessions","sidebar.searchSessions":"Search session names","sidebar.clearSearch":"Clear search","sidebar.filter":"View options","sidebar.groupBy":"Group by","sidebar.groupWorkspace":"WorkSpace","sidebar.groupWorkspaceTree":"Workspace Tree","sidebar.groupList":"In one list","sidebar.sortBy":"Order by","sidebar.sortManual":"Manual","sidebar.sortTime":"Last updated","sidebar.filterBy":"Filter sessions","sidebar.hideArchived":"Hide archived","sidebar.showArchived":"All conversations (show archived)","sidebar.onlyArchived":"Archived only","header.lead":"Plan automatic tasks, or trigger them by hand. Describe the recurring work in any chat to create it quickly.","header.githubProject":"GitHub","header.githubFeedback":"Issues","examples.title":"Recommended examples","examples.1.title":"Daily regression check","examples.1.body":"Create a scheduled task that runs every day and inspects new test failures.","examples.1.chip":"Every day 09:00","examples.2.title":"Weekly dependency review","examples.2.body":"Create a scheduled task that runs every Monday and reports outdated or risky dependencies.","examples.2.chip":"Monday 10:00","examples.3.title":"Weekday morning briefing","examples.3.body":"Create a scheduled task that runs on weekdays and summarizes overnight changes.","examples.3.chip":"Weekdays 08:00","chat.hint":"In any conversation, describe the recurring work and ask the Agent to call automation_create.","chat.prompt":"I want to create a scheduled task that runs every [interval] and does [the actual task]","menu.run":"Run task","menu.edit":"Edit task","menu.delete":"Delete task","session.rename":"Rename","session.fork":"Fork session","session.archive":"Archive session","session.unarchive":"Restore","session.copySessionId":"Copy Session ID","session.moreActions":"More actions for {title}","session.groupActions":"Actions for {name}","session.taskSettings":"Task settings","session.archiveGroup":"Archive all conversations","session.archiveGroupConfirm":"Archive all","session.archiveGroupDescription":"Archive all {count} conversations for \u201C{name}\u201D. Choose Filter \u2192 Show archived to restore them.","session.archiveGroupPending":"Archiving conversations\u2026","session.archiveGroupFailed":"Some conversations could not be archived: {message}","session.archiveGroupClose":"Close","session.archiveGroupCancel":"Cancel","session.unarchiveGroup":"Restore all conversations","session.unarchiveGroupConfirm":"Restore all","session.unarchiveGroupDescription":"Restore all {count} conversations for \u201C{name}\u201D.","session.unarchiveGroupPending":"Restoring conversations\u2026","session.unarchiveGroupFailed":"Some conversations could not be restored: {message}","session.unarchiveGroupClose":"Close","session.unarchiveGroupCancel":"Cancel","session.deleteSession":"Delete session","session.deleteSessionConfirm":"Delete session","session.deleteSessionDescription":"This permanently deletes session \u201C{name}\u201D, its child agents (including any that are still running), and all of its records (conversation, stats, cache). This cannot be undone.","session.deleteSessionPending":"Deleting session\u2026","session.deleteSessionFailed":"Could not delete the session: {message}","session.deleteSessionClose":"Close","session.deleteSessionCancel":"Cancel","session.idle":"Idle","session.runningStatus":"Running","session.completed":"Completed","session.waitingApproval":"Waiting for approval","session.planReview":"Plan to review","session.waitingAnswer":"Waiting for an answer","session.subagentsRunning":"{count} subagents running","session.archived":"Archived","session.delete":"Remove from Scheduled","session.deleteFolder":"Remove folder","session.confirmDeleteFolder":"Remove this folder from Scheduled?","session.confirmDeleteFolderHint":'This only unlists {count} session(s) in "{name}" from Scheduled. Host sessions are not deleted and they stay hidden from Tasks.',"session.confirmDeleteFolderAction":"Remove from Scheduled","history.range.day":"By day","history.range.week":"By week","history.range.month":"By month","history.allTasks":"All tasks","history.allStatus":"All statuses","history.today":"Today","history.yesterday":"Yesterday","history.date":"{date}","history.week":"Week of {date}","history.month":"{month}","history.nextApprox":"Next run in about {when}","time.withinMinute":"about {count} minutes","time.withinHour":"about {count} hours","time.withinDay":"about {count} days","search.placeholder":"Search scheduled tasks...","action.chatCreate":"Create in chat","action.create":"New scheduled task","banner.wake":"Scheduled tasks run only while this computer stays awake.","tabs.mine":"My tasks","tabs.runs":"Run history","sort.by":"Sort","sort.created.asc":"Created time ascending","sort.created.desc":"Created time descending","sort.planned.asc":"Planned time ascending","sort.planned.desc":"Planned time descending","sort.default.save":"Set as default","sort.default.saved":"Default","form.workspace":"Workspace","form.fieldWorkspace":"Workspace","form.fieldModel":"Model","form.providerAccount":"DeepSeek account","form.fieldEffort":"Reasoning","form.fieldPermission":"Permission","form.slashHint":"Type / to insert a skill","form.slashEmpty":"No matching skills","form.addWorkspace":"Add workspace","form.workspaceRequired":"Add a registered workspace before saving.","form.workspaceUnavailable":"This Host cannot create workspaces.","form.addWorkspaceFailed":"Could not add the workspace.","form.workspacePath":"Folder path","form.workspacePathPlaceholder":"D:\\work\\project","form.model":"Model","form.modelSelect":"Select model","form.effort":"Reasoning","form.effort.none":"Default","form.effort.low":"Low","form.effort.medium":"Medium","form.effort.high":"High","form.error.workspace":"Select a workspace.","modal.title":"New scheduled task","modal.edit":"Edit scheduled task","modal.save":"Save","header.eyebrow":"Unattended coding work","header.title":"Automations","header.subtitle":"Schedule standalone, auditable Agent runs for this workspace.","header.create":"New automation","header.closeCreate":"Hide form","scope.workspace":"Workspace","scope.folder":"Working directory","stats.total":"All","stats.active":"Active","stats.next":"Next run","stats.attention":"Needs attention","stats.noneScheduled":"None scheduled","stats.noAttention":"All clear","section.automations":"Workspace automations","section.automationsHint":"Each trigger starts a fresh DSH Session and keeps its own audit record.","section.runs":"Recent runs","section.runsHint":"Latest outcomes for this workspace.","section.refresh":"Refresh","empty.title":"Let recurring coding work run itself","empty.body":"Save a self-contained task, a schedule, and a permission boundary. Every run starts in a new Session.","empty.action":"Create the first automation","runs.empty":"No runs yet. Run one now, or wait for the next scheduled occurrence.","overview.empty":"No scheduled tasks yet. Create one in Settings.","form.title":"Create automation","form.subtitle":"Write a complete, standalone task. Scheduled runs do not inherit this conversation.","form.name":"Name","form.namePlaceholder":"Daily regression triage","form.prompt":"Task prompt","form.promptPlaceholder":"Inspect new test failures, locate the regression, and propose a verified minimal fix\u2026","form.schedule":"Schedule","form.planTime":"Schedule","form.hourly":"Hourly","form.monthly":"Monthly","form.custom":"Every few days","form.intervalHint":"Runs every this many minutes, starting now.","form.customHint":"Runs every this many days at the selected time.","form.atTime":"at","form.minutesShort":"min","form.daysShort":"days","form.monthDay":"Day {day} of month","form.skills":"Skills","form.skillsEmpty":"No skills available","schedule.hourlyAt":"Every hour at :{minute}","schedule.monthlyAt":"Monthly on day {day} \xB7 {time}","schedule.customAt":"Every {count} days \xB7 {time}","form.once":"Does not repeat","form.interval":"Interval","form.daily":"Daily","form.weekly":"Weekly","form.runAt":"Run at","form.every":"Every","form.minutes":"minutes","form.time":"Time","form.days":"Weekdays","form.timeZone":"Time zone","form.maxConcurrentRuns":"Concurrency","form.maxConcurrentRunsHint":"Queued and running executions share this limit. Defaults to 1; when full, scheduled triggers are skipped and manual runs are rejected.","form.error.maxConcurrentRuns":"Enter a positive whole number for concurrent runs.","form.permission":"Permission boundary","permission.readOnly":"Read Only","permission.workspaceWrite":"Workspace Write","permission.fullAccess":"Full access","form.cancel":"Cancel","form.submit":"Create automation","form.submitting":"Creating\u2026","form.error.name":"Enter a name.","form.error.prompt":"Enter a complete, standalone task prompt.","form.error.once":"Choose a valid future date and time.","form.error.interval":"The interval must be between 1 and 43,200 minutes.","form.error.weekdays":"Select at least one weekday.","day.1":"Mon","day.2":"Tue","day.3":"Wed","day.4":"Thu","day.5":"Fri","day.6":"Sat","day.7":"Sun","status.active":"Active","status.paused":"Paused","status.queued":"Queued","status.running":"Running","status.succeeded":"Succeeded","status.failed":"Failed","status.skipped":"Skipped","status.cancelled":"Cancelled","status.interrupted":"Interrupted","card.nextRun":"Next","card.lastRun":"Last","card.never":"Not yet run","schedule.onceAt":"Once \xB7 {time}","schedule.everyMinutes":"Every {count} minutes","schedule.dailyAt":"Daily \xB7 {time}","schedule.weeklyAt":"{days} \xB7 {time}","card.pause":"Pause","card.resume":"Resume","card.runNow":"Run now","card.more":"More actions","card.delete":"Delete","card.confirmDelete":"Delete this automation?","card.confirmDeleteHint":"Run history is kept for audit.","card.confirm":"Delete","card.cancel":"Cancel","run.trigger.schedule":"Scheduled","run.trigger.manual":"Manual","run.openSession":"Session {id}","run.markRead":"Mark reviewed",loading:"Loading automations\u2026","error.title":"Automations could not be loaded","error.retry":"Try again","error.action":"The action failed. Please try again.","error.taskMissing":"This scheduled task no longer exists.","error.offline":"Could not reach the local automation service. Check that DSH is still running and try again.","time.minutes":"{count}m","time.hours":"{count}h","time.days":"{count}d","time.months":"{count}mo","time.years":"{count}y","time.ago":"{text} ago","time.now":"now","session.copy":"Copy","session.copied":"Copied","session.compactApproval":"Approval","session.compactPlan":"Plan review","session.compactAnswer":"Answer","time.minuteAgo":"{count}m ago","time.hourAgo":"{count}h ago","time.dayAgo":"{count}d ago","time.inMinute":"in {count}m","time.inHour":"in {count}h","time.inDay":"in {count}d"},eo={tab:"\u5B9A\u65F6\u4EFB\u52A1","sidebar.tab":"\u5B9A\u65F6","sidebar.tabs":"\u5DE5\u4F5C\u533A\u5206\u7C7B","sidebar.tasksTab":"\u4EFB\u52A1","sidebar.channelsTab":"\u9891\u9053","sidebar.views":"\u5B9A\u65F6\u9875\u89C6\u56FE","sidebar.viewOverview":"\u4EFB\u52A1\u603B\u89C8","sidebar.runsTab":"\u8BB0\u5F55","sidebar.overviewTab":"\u4EFB\u52A1","sidebar.empty":"\u8FD8\u6CA1\u6709\u5B9A\u65F6\u4EFB\u52A1\u6267\u884C\u8BB0\u5F55\u3002","sidebar.tasksEmpty":"\u6682\u65E0\u7F51\u9875\u4EFB\u52A1","sidebar.ungrouped":"\u672A\u5206\u7EC4","sidebar.section":"\u5B9A\u65F6\u4EFB\u52A1","sidebar.workspaces":"\u5DE5\u4F5C\u533A","sidebar.search":"\u641C\u7D22","sidebar.sessions":"\u4F1A\u8BDD","sidebar.searchSessions":"\u641C\u7D22\u4F1A\u8BDD\u540D\u79F0","sidebar.clearSearch":"\u6E05\u9664\u641C\u7D22","sidebar.filter":"\u89C6\u56FE\u9009\u9879","sidebar.groupBy":"\u5206\u7EC4\u65B9\u5F0F","sidebar.groupWorkspace":"\u6309\u5DE5\u4F5C\u533A","sidebar.groupWorkspaceTree":"\u6309\u5DE5\u4F5C\u533A\u6811","sidebar.groupList":"\u5355\u5217\u8868","sidebar.sortBy":"\u6392\u5E8F\u65B9\u5F0F","sidebar.sortManual":"\u624B\u52A8\u6392\u5E8F","sidebar.sortTime":"\u6700\u8FD1\u66F4\u65B0","sidebar.filterBy":"\u7B5B\u9009\u4F1A\u8BDD","sidebar.hideArchived":"\u9690\u85CF\u5DF2\u5F52\u6863","sidebar.showArchived":"\u5168\u90E8\u5BF9\u8BDD\uFF08\u663E\u793A\u5DF2\u5F52\u6863\uFF09","sidebar.onlyArchived":"\u4EC5\u663E\u793A\u5DF2\u5F52\u6863","header.lead":"\u6309\u8BA1\u5212\u81EA\u52A8\u6267\u884C\u4EFB\u52A1\uFF0C\u4E5F\u53EF\u968F\u65F6\u624B\u52A8\u89E6\u53D1\u3002\u5728\u4EFB\u610F\u5BF9\u8BDD\u4E2D\u63CF\u8FF0\u4F60\u60F3\u5B9A\u671F\u505A\u7684\u4E8B\uFF0C\u5373\u53EF\u5FEB\u901F\u521B\u5EFA","header.githubProject":"GitHub","header.githubFeedback":"\u95EE\u9898\u53CD\u9988","examples.title":"\u63A8\u8350\u6848\u4F8B","examples.1.title":"\u6BCF\u65E5\u56DE\u5F52\u68C0\u67E5","examples.1.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5929\u3011\u6267\u884C\u3010\u68C0\u67E5\u65B0\u589E\u6D4B\u8BD5\u5931\u8D25\u5E76\u7ED9\u51FA\u6700\u5C0F\u4FEE\u590D\u3011\u3002","examples.1.chip":"\u6BCF\u5929 09:00","examples.2.title":"\u6BCF\u5468\u4F9D\u8D56\u5DE1\u68C0","examples.2.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5468\u4E00\u3011\u6267\u884C\u3010\u68C0\u67E5\u8FC7\u671F\u6216\u6709\u98CE\u9669\u7684\u4F9D\u8D56\u5E76\u7ED9\u51FA\u5904\u7406\u5EFA\u8BAE\u3011\u3002","examples.2.chip":"\u6BCF\u5468\u4E00 10:00","examples.3.title":"\u5DE5\u4F5C\u65E5\u65E9\u62A5","examples.3.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5DE5\u4F5C\u65E5\u3011\u6267\u884C\u3010\u6C47\u603B\u6628\u591C\u4ED3\u5E93\u53D8\u66F4\u5E76\u7ED9\u51FA\u4ECA\u65E5\u5173\u6CE8\u70B9\u3011\u3002","examples.3.chip":"\u5DE5\u4F5C\u65E5 08:00","chat.hint":"\u5728\u4EFB\u610F\u5BF9\u8BDD\u4E2D\u63CF\u8FF0\u4F60\u60F3\u5B9A\u671F\u505A\u7684\u4E8B\uFF0C\u5E76\u8BA9 Agent \u8C03\u7528 automation_create\u3002","chat.prompt":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u65F6\u95F4\u95F4\u9694\u3011\u6267\u884C\u3010\u5177\u4F53\u4EFB\u52A1\u3011","menu.run":"\u6267\u884C\u4EFB\u52A1","menu.edit":"\u7F16\u8F91\u4EFB\u52A1","menu.delete":"\u5220\u9664\u4EFB\u52A1","session.rename":"\u91CD\u547D\u540D","session.fork":"\u5206\u53C9\u4F1A\u8BDD","session.archive":"\u5F52\u6863\u4F1A\u8BDD","session.unarchive":"\u6062\u590D","session.copySessionId":"\u590D\u5236 Session ID","session.moreActions":"\u201C{title}\u201D\u7684\u66F4\u591A\u64CD\u4F5C","session.groupActions":"\u201C{name}\u201D\u7684\u4EFB\u52A1\u64CD\u4F5C","session.taskSettings":"\u4EFB\u52A1\u8BBE\u7F6E","session.archiveGroup":"\u5F52\u6863\u6574\u7EC4\u4F1A\u8BDD","session.archiveGroupConfirm":"\u786E\u8BA4\u5F52\u6863","session.archiveGroupDescription":"\u5C06\u5F52\u6863\u201C{name}\u201D\u4E0B\u7684 {count} \u4E2A\u4F1A\u8BDD\u3002\u53EF\u5728\u7B5B\u9009\u4E2D\u9009\u62E9\u201C\u663E\u793A\u5DF2\u5F52\u6863\u201D\u540E\u6062\u590D\u3002","session.archiveGroupPending":"\u6B63\u5728\u5F52\u6863\u6574\u7EC4\u4F1A\u8BDD\u2026","session.archiveGroupFailed":"\u90E8\u5206\u4F1A\u8BDD\u5F52\u6863\u5931\u8D25\uFF1A{message}","session.archiveGroupClose":"\u5173\u95ED","session.archiveGroupCancel":"\u53D6\u6D88","session.unarchiveGroup":"\u6062\u590D\u6574\u7EC4\u4F1A\u8BDD","session.unarchiveGroupConfirm":"\u786E\u8BA4\u6062\u590D","session.unarchiveGroupDescription":"\u5C06\u6062\u590D\u201C{name}\u201D\u4E0B\u7684 {count} \u4E2A\u4F1A\u8BDD\u3002","session.unarchiveGroupPending":"\u6B63\u5728\u6062\u590D\u6574\u7EC4\u4F1A\u8BDD\u2026","session.unarchiveGroupFailed":"\u90E8\u5206\u4F1A\u8BDD\u6062\u590D\u5931\u8D25\uFF1A{message}","session.unarchiveGroupClose":"\u5173\u95ED","session.unarchiveGroupCancel":"\u53D6\u6D88","session.deleteSession":"\u5220\u9664\u4F1A\u8BDD","session.deleteSessionConfirm":"\u5220\u9664\u4F1A\u8BDD","session.deleteSessionDescription":"\u5C06\u6C38\u4E45\u5220\u9664\u4F1A\u8BDD\u201C{name}\u201D\u53CA\u5176\u5B50\u4EE3\u7406\uFF08\u542B\u6B63\u5728\u8FD0\u884C\u7684\uFF09\u548C\u5168\u90E8\u8BB0\u5F55\uFF08\u5BF9\u8BDD\u5185\u5BB9\u3001\u7EDF\u8BA1\u3001\u7F13\u5B58\uFF09\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002","session.deleteSessionPending":"\u6B63\u5728\u5220\u9664\u4F1A\u8BDD\u2026","session.deleteSessionFailed":"\u5220\u9664\u4F1A\u8BDD\u5931\u8D25\uFF1A{message}","session.deleteSessionClose":"\u5173\u95ED","session.deleteSessionCancel":"\u53D6\u6D88","session.idle":"\u7A7A\u95F2","session.runningStatus":"\u8FDB\u884C\u4E2D","session.completed":"\u5DF2\u5B8C\u6210","session.waitingApproval":"\u7B49\u5F85\u5BA1\u6279","session.planReview":"\u8BA1\u5212\u5F85\u5BA1","session.waitingAnswer":"\u7B49\u5F85\u56DE\u7B54","session.subagentsRunning":"{count} \u4E2A\u5B50\u4EE3\u7406\u8FD0\u884C\u4E2D","session.archived":"\u5DF2\u5F52\u6863","session.delete":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664","session.deleteFolder":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664\u6587\u4EF6\u5939","session.confirmDeleteFolder":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664\u8FD9\u4E2A\u6587\u4EF6\u5939\uFF1F","session.confirmDeleteFolderHint":"\u53EA\u4F1A\u628A\u300C{name}\u300D\u4E0B\u7684 {count} \u6761\u4F1A\u8BDD\u4ECE\u5B9A\u65F6\u9875\u6458\u6389\uFF0C\u4E0D\u4F1A\u5220\u9664\u5BBF\u4E3B Session\u3002\u4EFB\u52A1\u9875\u672C\u6765\u4E5F\u4E0D\u5C55\u793A\u8FD9\u4E9B\u81EA\u52A8\u5316\u4F1A\u8BDD\u3002","session.confirmDeleteFolderAction":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664","history.range.day":"\u6309\u5929","history.range.week":"\u6309\u5468","history.range.month":"\u6309\u6708","history.allTasks":"\u5168\u90E8\u4EFB\u52A1","history.allStatus":"\u5168\u90E8\u72B6\u6001","history.today":"\u4ECA\u5929","history.yesterday":"\u6628\u5929","history.date":"{date}","history.week":"{date} \u5F53\u5468","history.month":"{month}","history.nextApprox":"\u4E0B\u6B21\u6267\u884C \u5927\u7EA6 {when}","time.withinMinute":"{count} \u5206\u949F\u5185","time.withinHour":"{count} \u5C0F\u65F6\u5185","time.withinDay":"{count} \u5929\u5185","search.placeholder":"\u641C\u7D22\u5B9A\u65F6\u4EFB\u52A1...","action.chatCreate":"\u901A\u8FC7\u5BF9\u8BDD\u521B\u5EFA","action.create":"\u65B0\u5EFA\u5B9A\u65F6\u4EFB\u52A1","banner.wake":"\u5B9A\u65F6\u4EFB\u52A1\u4EC5\u5728\u7535\u8111\u4FDD\u6301\u5524\u9192\u65F6\u8FD0\u884C","tabs.mine":"\u6211\u7684\u5B9A\u65F6\u4EFB\u52A1","tabs.runs":"\u6267\u884C\u8BB0\u5F55","sort.by":"\u6392\u5E8F","sort.created.asc":"\u6309\u521B\u5EFA\u65F6\u95F4\u5347\u5E8F","sort.created.desc":"\u6309\u521B\u5EFA\u65F6\u95F4\u5012\u5E8F","sort.planned.asc":"\u6309\u8BA1\u5212\u65F6\u95F4\u5347\u5E8F","sort.planned.desc":"\u6309\u8BA1\u5212\u65F6\u95F4\u5012\u5E8F","sort.default.save":"\u8BBE\u4E3A\u9ED8\u8BA4","sort.default.saved":"\u9ED8\u8BA4","form.workspace":"\u5DE5\u4F5C\u76EE\u5F55","form.fieldWorkspace":"\u5DE5\u4F5C\u533A","form.fieldModel":"\u6A21\u578B","form.providerAccount":"DeepSeek \u8D26\u53F7","form.fieldEffort":"\u63A8\u7406\u7B49\u7EA7","form.fieldPermission":"\u6743\u9650","form.slashHint":"\u8F93\u5165 / \u53EC\u56DE\u6280\u80FD","form.slashEmpty":"\u6CA1\u6709\u5339\u914D\u7684\u6280\u80FD","form.addWorkspace":"\u6DFB\u52A0\u5DE5\u4F5C\u533A","form.workspaceRequired":"\u8BF7\u5148\u6DFB\u52A0\u5DF2\u767B\u8BB0\u7684\u5DE5\u4F5C\u533A\uFF0C\u5426\u5219\u65E0\u6CD5\u4FDD\u5B58\u3002","form.workspaceUnavailable":"\u5F53\u524D\u5BBF\u4E3B\u4E0D\u80FD\u65B0\u5EFA\u5DE5\u4F5C\u533A\u3002","form.addWorkspaceFailed":"\u6DFB\u52A0\u5DE5\u4F5C\u533A\u5931\u8D25\u3002","form.workspacePath":"\u76EE\u5F55\u8DEF\u5F84","form.workspacePathPlaceholder":"D:\\work\\project","form.model":"\u6A21\u578B","form.modelSelect":"\u9009\u62E9\u6A21\u578B","form.effort":"\u63A8\u7406\u7B49\u7EA7","form.effort.none":"\u9ED8\u8BA4","form.effort.low":"Low","form.effort.medium":"Medium","form.effort.high":"High","form.error.workspace":"\u8BF7\u9009\u62E9\u5DE5\u4F5C\u533A\u3002","modal.title":"\u65B0\u5EFA\u5B9A\u65F6\u4EFB\u52A1","modal.edit":"\u7F16\u8F91\u5B9A\u65F6\u4EFB\u52A1","modal.save":"\u4FDD\u5B58","header.eyebrow":"\u81EA\u4E3B\u7F16\u7801\u4EFB\u52A1","header.title":"\u81EA\u52A8\u5316","header.subtitle":"\u4E3A\u5F53\u524D\u5DE5\u4F5C\u533A\u5B89\u6392\u72EC\u7ACB\u3001\u53EF\u5BA1\u8BA1\u7684 Agent \u8FD0\u884C\u3002","header.create":"\u65B0\u5EFA\u81EA\u52A8\u5316","header.closeCreate":"\u6536\u8D77\u8868\u5355","scope.workspace":"\u5DE5\u4F5C\u533A","scope.folder":"\u5DE5\u4F5C\u76EE\u5F55","stats.total":"\u5168\u90E8","stats.active":"\u5DF2\u542F\u7528","stats.next":"\u4E0B\u6B21\u8FD0\u884C","stats.attention":"\u9700\u8981\u5173\u6CE8","stats.noneScheduled":"\u6682\u65E0\u8BA1\u5212","stats.noAttention":"\u4E00\u5207\u6B63\u5E38","section.automations":"\u5DE5\u4F5C\u533A\u81EA\u52A8\u5316","section.automationsHint":"\u6BCF\u6B21\u89E6\u53D1\u90FD\u4F1A\u521B\u5EFA\u4E00\u4E2A\u5168\u65B0\u7684 DSH Session\uFF0C\u5E76\u4FDD\u7559\u72EC\u7ACB\u5BA1\u8BA1\u8BB0\u5F55\u3002","section.runs":"\u6700\u8FD1\u8FD0\u884C","section.runsHint":"\u5F53\u524D\u5DE5\u4F5C\u533A\u6700\u8FD1\u7684\u6267\u884C\u72B6\u6001\u3002","section.refresh":"\u5237\u65B0","empty.title":"\u8BA9\u91CD\u590D\u7684\u7F16\u7801\u5DE5\u4F5C\u81EA\u52A8\u8FD0\u884C","empty.body":"\u8BBE\u7F6E\u4E00\u4E2A\u76EE\u6807\u660E\u786E\u7684\u4EFB\u52A1\u3001\u8FD0\u884C\u65F6\u95F4\u548C\u6743\u9650\u8FB9\u754C\u3002\u6BCF\u6B21\u8FD0\u884C\u90FD\u4ECE\u5168\u65B0 Session \u5F00\u59CB\u3002","empty.action":"\u521B\u5EFA\u7B2C\u4E00\u4E2A\u81EA\u52A8\u5316","runs.empty":"\u8FD8\u6CA1\u6709\u8FD0\u884C\u8BB0\u5F55\u3002\u4F60\u53EF\u4EE5\u7ACB\u5373\u8FD0\u884C\u4E00\u6B21\uFF0C\u6216\u7B49\u5F85\u8BA1\u5212\u89E6\u53D1\u3002","overview.empty":"\u6682\u65E0\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u53EF\u5230\u8BBE\u7F6E\u9875\u521B\u5EFA\u3002","form.title":"\u521B\u5EFA\u81EA\u52A8\u5316","form.subtitle":"\u8BF7\u5199\u5B8C\u6574\u3001\u72EC\u7ACB\u7684\u4EFB\u52A1\u8BF4\u660E\uFF1A\u5B9A\u65F6\u8FD0\u884C\u4E0D\u4F1A\u7EE7\u627F\u5F53\u524D\u5BF9\u8BDD\u3002","form.name":"\u540D\u79F0","form.namePlaceholder":"\u6BCF\u65E5\u56DE\u5F52\u6D4B\u8BD5\u5206\u8BCA","form.prompt":"\u4EFB\u52A1\u6307\u4EE4","form.promptPlaceholder":"\u68C0\u67E5\u65B0\u589E\u6D4B\u8BD5\u5931\u8D25\uFF0C\u5B9A\u4F4D\u56DE\u5F52\u539F\u56E0\uFF0C\u5E76\u7ED9\u51FA\u7ECF\u8FC7\u9A8C\u8BC1\u7684\u6700\u5C0F\u4FEE\u590D\u65B9\u6848\u2026\u2026","form.schedule":"\u8FD0\u884C\u8BA1\u5212","form.planTime":"\u8BA1\u5212\u65F6\u95F4","form.hourly":"\u6BCF\u5C0F\u65F6","form.monthly":"\u6BCF\u6708","form.custom":"\u6BCF\u9694\u51E0\u5929","form.intervalHint":"\u4ECE\u73B0\u5728\u8D77\uFF0C\u6BCF\u9694\u8FD9\u4E48\u591A\u5206\u949F\u8FD0\u884C\u4E00\u6B21\u3002","form.customHint":"\u6BCF\u9694\u8FD9\u4E48\u591A\u5929\uFF0C\u5728\u6240\u9009\u65F6\u95F4\u8FD0\u884C\u4E00\u6B21\u3002","form.atTime":"\u4E8E","form.minutesShort":"\u5206","form.daysShort":"\u5929","form.monthDay":"\u6BCF\u6708\u7B2C {day} \u5929","form.skills":"\u6280\u80FD","form.skillsEmpty":"\u6682\u65E0\u53EF\u7528\u6280\u80FD","schedule.hourlyAt":"\u6BCF\u5C0F\u65F6 :{minute}","schedule.monthlyAt":"\u6BCF\u6708 {day} \u65E5 \xB7 {time}","schedule.customAt":"\u6BCF {count} \u5929 \xB7 {time}","form.once":"\u4E0D\u91CD\u590D","form.interval":"\u95F4\u9694","form.daily":"\u6BCF\u5929","form.weekly":"\u6BCF\u5468","form.runAt":"\u8FD0\u884C\u65F6\u95F4","form.every":"\u6BCF\u9694","form.minutes":"\u5206\u949F","form.time":"\u65F6\u95F4","form.days":"\u661F\u671F","form.timeZone":"\u65F6\u533A","form.maxConcurrentRuns":"\u5E76\u53D1\u6570\u91CF","form.maxConcurrentRunsHint":"\u540C\u4E00\u4EFB\u52A1\u7684\u6392\u961F\u53CA\u8FD0\u884C\u6B21\u6570\u5171\u7528\u6B64\u4E0A\u9650\uFF0C\u9ED8\u8BA4 1\uFF1B\u6EE1\u989D\u65F6\u8DF3\u8FC7\u5F53\u6B21\u5B9A\u65F6\u89E6\u53D1\uFF0C\u624B\u52A8\u8FD0\u884C\u5C06\u88AB\u62D2\u7EDD\u3002","form.error.maxConcurrentRuns":"\u5E76\u53D1\u6570\u91CF\u5FC5\u987B\u4E3A\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\u3002","form.permission":"\u6743\u9650\u8FB9\u754C","permission.readOnly":"\u53EA\u8BFB","permission.workspaceWrite":"\u5DE5\u4F5C\u533A\u5199\u5165","permission.fullAccess":"\u5B8C\u5168\u8BBF\u95EE","form.cancel":"\u53D6\u6D88","form.submit":"\u521B\u5EFA\u81EA\u52A8\u5316","form.submitting":"\u521B\u5EFA\u4E2D\u2026","form.error.name":"\u8BF7\u8F93\u5165\u540D\u79F0\u3002","form.error.prompt":"\u8BF7\u8F93\u5165\u5B8C\u6574\u3001\u72EC\u7ACB\u7684\u4EFB\u52A1\u6307\u4EE4\u3002","form.error.once":"\u8BF7\u9009\u62E9\u6709\u6548\u7684\u672A\u6765\u65E5\u671F\u548C\u65F6\u95F4\u3002","form.error.interval":"\u8FD0\u884C\u95F4\u9694\u5FC5\u987B\u5728 1 \u5230 43,200 \u5206\u949F\u4E4B\u95F4\u3002","form.error.weekdays":"\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u5929\u3002","day.1":"\u5468\u4E00","day.2":"\u5468\u4E8C","day.3":"\u5468\u4E09","day.4":"\u5468\u56DB","day.5":"\u5468\u4E94","day.6":"\u5468\u516D","day.7":"\u5468\u65E5","status.active":"\u5DF2\u542F\u7528","status.paused":"\u5DF2\u6682\u505C","status.queued":"\u6392\u961F\u4E2D","status.running":"\u8FD0\u884C\u4E2D","status.succeeded":"\u5DF2\u5B8C\u6210","status.failed":"\u5931\u8D25","status.skipped":"\u5DF2\u8DF3\u8FC7","status.cancelled":"\u5DF2\u53D6\u6D88","status.interrupted":"\u5DF2\u4E2D\u65AD","card.nextRun":"\u4E0B\u6B21","card.lastRun":"\u6700\u8FD1","card.never":"\u5C1A\u672A\u8FD0\u884C","schedule.onceAt":"\u5355\u6B21 \xB7 {time}","schedule.everyMinutes":"\u6BCF {count} \u5206\u949F","schedule.dailyAt":"\u6BCF\u5929 \xB7 {time}","schedule.weeklyAt":"{days} \xB7 {time}","card.pause":"\u6682\u505C","card.resume":"\u6062\u590D","card.runNow":"\u7ACB\u5373\u8FD0\u884C","card.more":"\u66F4\u591A\u64CD\u4F5C","card.delete":"\u5220\u9664","card.confirmDelete":"\u786E\u8BA4\u5220\u9664\u8FD9\u4E2A\u81EA\u52A8\u5316\uFF1F","card.confirmDeleteHint":"\u8FD0\u884C\u5386\u53F2\u4F1A\u4FDD\u7559\u7528\u4E8E\u5BA1\u8BA1\u3002","card.confirm":"\u786E\u8BA4\u5220\u9664","card.cancel":"\u53D6\u6D88","run.trigger.schedule":"\u5B9A\u65F6\u89E6\u53D1","run.trigger.manual":"\u624B\u52A8\u89E6\u53D1","run.openSession":"Session {id}","run.markRead":"\u6807\u8BB0\u5DF2\u5904\u7406",loading:"\u6B63\u5728\u52A0\u8F7D\u81EA\u52A8\u5316\u2026","error.title":"\u65E0\u6CD5\u52A0\u8F7D\u81EA\u52A8\u5316","error.retry":"\u91CD\u8BD5","error.action":"\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002","error.taskMissing":"\u8BE5\u5B9A\u65F6\u4EFB\u52A1\u5DF2\u4E0D\u5B58\u5728\u3002","error.offline":"\u65E0\u6CD5\u8FDE\u63A5\u672C\u673A\u81EA\u52A8\u5316\u670D\u52A1\uFF0C\u8BF7\u786E\u8BA4 DSH \u4ECD\u5728\u8FD0\u884C\u540E\u91CD\u8BD5\u3002","time.minutes":"{count}\u5206\u949F","time.hours":"{count}\u5C0F\u65F6","time.days":"{count}\u5929","time.months":"{count}\u4E2A\u6708","time.years":"{count}\u5E74","time.ago":"{text}\u524D","time.now":"\u521A\u521A","session.copy":"\u590D\u5236","session.copied":"\u5DF2\u590D\u5236","session.compactApproval":"\u5F85\u5BA1\u6279","session.compactPlan":"\u8BA1\u5212\u5F85\u5BA1","session.compactAnswer":"\u5F85\u56DE\u7B54","time.minuteAgo":"{count} \u5206\u949F\u524D","time.hourAgo":"{count} \u5C0F\u65F6\u524D","time.dayAgo":"{count} \u5929\u524D","time.inMinute":"{count} \u5206\u949F\u540E","time.inHour":"{count} \u5C0F\u65F6\u540E","time.inDay":"{count} \u5929\u540E"};var no="__dshNativeTabs";function to(e){let n=new Map,t=[],s=new Set,r=[],i=()=>{r=[...n.values()].sort((a,l)=>(a.order??0)-(l.order??0))},o=()=>{for(let a of s)a()};return{version:1,officialTree:e,sessionFilters:t,getTabs(){return r},subscribe(a){return s.add(a),()=>{s.delete(a)}},insert(a){if(a.id==="")return()=>{};let l=n.get(a.id);return n.set(a.id,a),l!==a&&(i(),o()),()=>{n.get(a.id)===a&&(n.delete(a.id),i(),o())}},addSessionFilter(a){return t.push(a),o(),()=>{let l=t.indexOf(a);l>=0&&t.splice(l,1),o()}}}}function ut(e){if(e==null||typeof e!="object"&&typeof e!="function")return;let n=e[no];if(!(n==null||typeof n!="object"))return typeof n.insert=="function"?n:void 0}function pt(e,n){try{e[no]=n}catch{}return n}function so(e){let n=e;return ut(e)??ut(n?.component)}function oo(e){if(e==null)return!1;let n=e;return n.__dshNativeTabHost===!0||n.__imConnectWrapped===!0?!0:ut(e)!==void 0}var Gr="@michengai/dsh-archive-manager";function mt(e){return e?.querySelector(`[data-plugin="${Gr}"]`)!=null}function $e(e){return typeof e=="function"?e:void 0}function En(e){let n=e??{},t=$e(n.renameSession),s=$e(n.archiveSession),r=$e(n.unarchiveSession),i=$e(n.deleteSession),o=$e(n.forkSession),a=$e(n.notifyArchivedNotOpenable);return{...t===void 0?{}:{renameSession:t},...s===void 0?{}:{archiveSession:s},...r===void 0?{}:{unarchiveSession:r},...i===void 0?{}:{deleteSession:i},...o===void 0?{}:{forkSession:o},...a===void 0?{}:{notifyArchivedNotOpenable:a}}}function ro(e,n){return e&&n!==void 0}function io(e){let n=["rename","fork"];return e.archived?e.canUnarchive&&n.push("unarchive"):n.push("archive"),e.canDelete&&n.push("delete-session"),n}function ao(e,n){return n!==null&&e.includes(n)}function lo(e,n){return e&&!n}async function co(e,n){for(let t of e)await n(t)}async function uo(e,n){for(let t of e)await n(t)}var P=require("react"),Ao=require("react-dom"),j=require("@deepseek-ai/dsh-client-ui-primitives");function mo(e,n,t,s){if(e===void 0)return null;try{return e(n,t,s)??null}catch(r){if(!Vr(r))throw r;return null}}function Vr(e){return typeof e!="object"||e===null?!1:"name"in e&&e.name==="SlotOwnershipError"?!0:(e instanceof Error?e.message:"").includes("not declared by this entry")}function fo(e,n,t){let r=e.right+8,i=e.top+n.height>t.height-8?Math.max(8,t.height-n.height-8):Math.max(8,e.top);return{position:"fixed",zIndex:4100,left:`${Math.round(r)}px`,top:`${Math.round(i)}px`}}function ho(e,n){let t=e.runningSubagentCount??0,s=t===0?void 0:{state:"ongoing",label:n("session.subagentsRunning",{count:t})},r;e.pendingKind==="approval"?r={state:"warning",label:n("session.waitingApproval"),trailing:n("session.compactApproval")}:e.pendingKind==="plan-review"?r={state:"warning",label:n("session.planReview"),trailing:n("session.compactPlan")}:e.pendingKind==="question"&&(r={state:"warning",label:n("session.waitingAnswer"),trailing:n("session.compactAnswer")});let i;r!==void 0?i=s===void 0?[r]:[r,s]:e.running?i=s===void 0?[{state:"ongoing",label:n("session.runningStatus")}]:[{state:"ongoing",label:n("session.runningStatus")},s]:s!==void 0?i=[s]:e.completed===!0?i=[{state:"done",label:n("session.completed")}]:i=[{state:"idle",label:n("session.idle")}];let o=i.filter(a=>!(e.archived&&(a.state==="done"||a.state==="idle")));return e.archived&&o.push({state:"archived",label:n("session.archived")}),o}function go(e,n){let t=Date.parse(e||"");if(!Number.isFinite(t))return;let s=6e4,r=36e5,i=864e5,o=Math.max(0,n-t);return o<s?{unit:"now",count:0}:o<r?{unit:"minutes",count:Math.floor(o/s)}:o<i?{unit:"hours",count:Math.floor(o/r)}:o<30*i?{unit:"days",count:Math.floor(o/i)}:o<365*i?{unit:"months",count:Math.floor(o/(30*i))}:{unit:"years",count:Math.floor(o/(365*i))}}function yo(e,n){return e.unit==="now"?n("time.now"):e.unit==="minutes"?n("time.minutes",{count:e.count}):e.unit==="hours"?n("time.hours",{count:e.count}):e.unit==="days"?n("time.days",{count:e.count}):e.unit==="months"?n("time.months",{count:e.count}):n("time.years",{count:e.count})}function po(e,n,t){e.scrollLeft=n,n>0?e.dataset.scrolled="":delete e.dataset.scrolled,n<t?e.dataset.clipped="":delete e.dataset.clipped}function Ur(e){e.scrollLeft=0,delete e.dataset.scrolled,delete e.dataset.clipped}function vo(e,n){if(e===null)return;let t=e.scrollWidth-e.clientWidth;if(t<=8)return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){po(e,t,t);return}cancelAnimationFrame(n.id);let s,r=0,i=o=>{r+=s===void 0?0:(o-s)*.03,s=o,po(e,Math.min(r,t),t),r<t&&(n.id=requestAnimationFrame(i))};n.id=requestAnimationFrame(i)}function ft(e,n){cancelAnimationFrame(n.id),e!==null&&Ur(e)}function bo(e,n,t=Date.now()){let s=go(e,t);return s===void 0?"":yo(s,n)}function wo(e,n,t=Date.now()){let s=go(e,t);return s===void 0?"":s.unit==="now"?n("time.now"):n("time.ago",{text:yo(s,n)})}var Ee=require("react");var Ln=require("@deepseek-ai/dsh-client-ui-primitives");var $=require("react/jsx-runtime"),Ke="dsh-st-rail-panel",Mn=typeof window>"u"?void 0:window.localStorage;function Pn({t:e,view:n,onChange:t}){return(0,$.jsx)(Ln.SegmentedTabs,{className:"dsh-st-rail-views",label:e("sidebar.views"),value:n,items:[{value:"runs",id:"dsh-st-rail-view-runs",panelId:Ke,label:(0,$.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:5},children:[(0,$.jsx)(Ge,{size:14}),(0,$.jsx)("span",{children:e("sidebar.runsTab")})]})},{value:"overview",id:"dsh-st-rail-view-overview",panelId:Ke,label:(0,$.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:5},children:[(0,$.jsx)(Tn,{size:14}),(0,$.jsx)("span",{children:e("sidebar.overviewTab")})]})}],onChange:t})}function Dn({t:e,automations:n,serverNow:t,openTaskSettings:s,onToggleAutomation:r}){let[i,o]=(0,Ee.useState)(()=>Ne(Mn,gn)?.key??"planned"),[a,l]=(0,Ee.useState)(()=>Ne(Mn,gn)?.direction??"asc"),[c,y]=(0,Ee.useState)(()=>new Set),m=(0,Ee.useMemo)(()=>new Date(t??Date.now()),[t]),T=(0,Ee.useMemo)(()=>{let p=fn(n,i,a);return $t(p)},[n,a,i]),A=(0,Ee.useMemo)(()=>new Map(n.map(p=>[p.id,pn(p.schedule,e)])),[n,e]),f=(p,u)=>{r===void 0||c.has(p)||(y(g=>new Set(g).add(p)),Promise.resolve(r(p,u)).catch(g=>{console.warn("[dsh-automation] \u5207\u6362\u4EFB\u52A1\u72B6\u6001\u5931\u8D25",g)}).finally(()=>{y(g=>{let h=new Set(g);return h.delete(p),h})}))};return(0,$.jsxs)("div",{className:"dsh-st-overview",children:[(0,$.jsxs)("div",{className:"dsh-st-overview-head",children:[(0,$.jsxs)("div",{className:"dsh-st-overview-title",children:[(0,$.jsx)("strong",{children:e("sidebar.viewOverview")}),(0,$.jsx)("span",{"aria-label":`${T.length}`,children:T.length})]}),(0,$.jsx)(Cn,{t:e,iconOnly:!0,className:"dsh-st-overview-sort",...Mn===void 0?{}:{storage:Mn},storageKey:gn,sortKey:i,sortDirection:a,onSelect:(p,u)=>{o(p),l(u)}})]}),T.length===0?(0,$.jsx)("div",{className:"dsh-st-rail-empty",children:e("overview.empty")}):T.map(p=>(0,$.jsx)(Br,{t:e,row:p,now:m,scheduleSummary:A.get(p.id)??"",toggleDisabled:r===void 0||c.has(p.id),onToggleAutomation:f,...s===void 0?{}:{openTaskSettings:s}},p.id))]})}function Br({t:e,row:n,now:t,scheduleSummary:s,openTaskSettings:r,toggleDisabled:i,onToggleAutomation:o}){let a=n.status!=="active",l=n.nextRunAt===void 0?e("stats.noneScheduled"):mn(n.nextRunAt,t,e),c=n.nextRunAt===void 0?e("stats.noneScheduled"):Rt(n.nextRunAt,t,e),y=`${e("stats.next")}: ${l}`,m=e(a?"card.resume":"card.pause");return(0,$.jsxs)("div",{className:`dsh-st-overview-row${a?" is-paused":""}`,children:[(0,$.jsxs)("button",{type:"button",className:"dsh-st-overview-open",disabled:r===void 0,onClick:()=>{r?.({automationId:n.id,name:n.name,sessionIds:[]})},children:[(0,$.jsxs)("span",{className:"dsh-st-overview-copy",children:[(0,$.jsx)("span",{className:"dsh-st-overview-name",children:n.name}),s!==""&&(0,$.jsxs)("span",{className:"dsh-st-overview-schedule",children:[(0,$.jsx)(fs,{width:14,height:14}),(0,$.jsx)("span",{children:s})]})]}),(0,$.jsx)("span",{className:"dsh-st-overview-next",title:y,"aria-label":y,children:(0,$.jsx)("strong",{children:c})})]}),(0,$.jsx)("span",{className:"dsh-st-overview-toggle",title:m,children:(0,$.jsx)(Ln.Switch,{checked:!a,disabled:i,label:m,onChange:()=>{o?.(n.id,bn(n.status))}})})]})}var De=require("react"),je=require("@deepseek-ai/dsh-client-ui-primitives");function So(e){return e?11:14}var X=require("react/jsx-runtime");function xo({t:e,query:n,sort:t,groupMode:s,archivedFilter:r="default",onQueryChange:i,onSortChange:o,onGroupModeChange:a,onArchivedFilterChange:l}){let[c,y]=(0,De.useState)(n.trim()!==""),[m,T]=(0,De.useState)(!1),A=(0,De.useRef)(null),f=So(c);(0,De.useEffect)(()=>{c&&A.current?.focus()},[c]);let p=()=>{T(!1),y(!0)},u=()=>{i(""),y(!1)},g=[{type:"label",id:"group-by",text:e("sidebar.groupBy")},{id:"workspace",label:e("sidebar.groupWorkspace"),icon:(0,X.jsx)(ze,{})},{id:"workspace-tree",label:e("sidebar.groupWorkspaceTree"),icon:(0,X.jsx)(Tn,{})},{id:"flat",label:e("sidebar.groupList"),icon:(0,X.jsx)(Ge,{})},{type:"separator",id:"order-by-separator"},{type:"label",id:"order-by",text:e("sidebar.sortBy")},{id:"updated",label:e("sidebar.sortTime"),icon:(0,X.jsx)(Ie,{})},...l!==void 0?[{type:"separator",id:"archived-filter-separator"},{type:"label",id:"filter-by",text:e("sidebar.filterBy")},{id:"hide-archived",label:e("sidebar.hideArchived"),icon:(0,X.jsx)(Cs,{})},{id:"show-archived",label:e("sidebar.showArchived"),icon:(0,X.jsx)(_e,{})},{id:"only-archived",label:e("sidebar.onlyArchived"),icon:(0,X.jsx)(Ns,{})}]:[]],h=[s==="list"?"flat":s,"updated",r==="show"?"show-archived":r==="only"?"only-archived":"hide-archived"];return(0,X.jsxs)("div",{className:c?"dsh-st-n-toolbar is-search":"dsh-st-n-toolbar",children:[(0,X.jsx)("span",{className:"dsh-st-n-head-label",children:e(s==="list"?"sidebar.sessions":"sidebar.workspaces")}),(0,X.jsx)("div",{className:"dsh-st-n-search-slot",children:(0,X.jsxs)("div",{className:"dsh-st-n-search",onClick:p,children:[(0,X.jsx)(je.Tooltip,{label:e("sidebar.search"),side:"bottom",delayMs:500,disabled:c,children:(0,X.jsx)("button",{type:"button",className:"dsh-st-n-search-btn","aria-label":e("sidebar.search"),"aria-expanded":c,onClick:p,children:(0,X.jsx)(xs,{size:f})})}),(0,X.jsx)("input",{ref:A,className:"dsh-st-n-search-input",value:n,placeholder:e("sidebar.searchSessions"),"aria-label":e("sidebar.searchSessions"),tabIndex:c?0:-1,"aria-hidden":!c,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Escape"&&u()}}),c&&(0,X.jsx)(je.Tooltip,{label:e("sidebar.clearSearch"),side:"bottom",delayMs:500,children:(0,X.jsx)("button",{type:"button",className:"dsh-st-n-search-clear","aria-label":e("sidebar.clearSearch"),onClick:S=>{S.stopPropagation(),u()},children:(0,X.jsx)(ks,{size:14})})})]})}),(0,X.jsx)("div",{className:"dsh-st-n-head-acts",children:(0,X.jsx)(je.Menu,{open:m,onClose:()=>{T(!1)},items:g,selectedIds:h,align:"end",dense:!0,portal:!0,onSelect:S=>{(S==="workspace"||S==="workspace-tree")&&a(S),S==="flat"&&a("list"),S==="updated"&&o("time"),S==="hide-archived"&&l?.("default"),S==="show-archived"&&l?.("show"),S==="only-archived"&&l?.("only"),T(!1)},anchor:(0,X.jsx)(je.Tooltip,{label:e("sidebar.filter"),side:"bottom",delayMs:500,disabled:m,children:(0,X.jsx)("button",{type:"button",className:m?"dsh-st-n-head-btn is-on":"dsh-st-n-head-btn","aria-label":e("sidebar.filter"),"aria-expanded":m,onClick:()=>T(S=>!S),children:(0,X.jsx)(kn,{size:16})})})})})]})}var v=require("react/jsx-runtime"),ko={},To=[];function On(e){let{t:n,runtime:t,openSession:s,useSessions:r,useWorkspaces:i,renameSession:o,archiveSession:a,unarchiveSession:l,deleteSession:c,forkSession:y,notifyArchivedNotOpenable:m,openTaskSettings:T,renderSlot:A,useSessionStatus:f}=e,p=(0,P.useSyncExternalStore)(t.source.subscribe,t.source.getSnapshot,t.source.getSnapshot),u=r?r(C=>Xe(C)):null,g=r?r(C=>C.byId??ko):ko,h=i?i(C=>C.archivedSessionIds??[]):[],S=i?i(C=>C.items??To):To,R=f?f(C=>C):void 0,L=r?r(C=>C.projectionsBySession):void 0,[H,ae]=(0,P.useState)({}),[de,W]=(0,P.useState)(),[se,K]=(0,P.useState)(),[O,z]=(0,P.useState)(),[_,oe]=(0,P.useState)(!1),[pe,U]=(0,P.useState)(),[M,G]=(0,P.useState)(),[x,V]=(0,P.useState)(!1),[q,ne]=(0,P.useState)(),[te,fe]=(0,P.useState)(),[xe,ge]=(0,P.useState)(!1),[J,re]=(0,P.useState)(),[ye,we]=(0,P.useState)(()=>typeof document<"u"&&mt(document)),[k,d]=(0,P.useState)("default"),[I,B]=(0,P.useState)(""),[Ce,Vo]=(0,P.useState)("time"),[ke,Uo]=(0,P.useState)("workspace"),[vt,Bo]=(0,P.useState)("runs"),Gn=(0,P.useRef)(null),Me=(0,P.useMemo)(()=>new Set(h),[h]),Vn=(0,P.useMemo)(()=>{let C=p.snapshot;if(C===void 0)return[];let Z=new Map(C.automations.map(ve=>[ve.id,ve.timeZone]));return vn(C.automations,C.runs).map(ve=>({...ve,sessions:ve.sessions.filter(Te=>Kt(Te.id,Me,k)).map(Te=>{let Ae=C.runs.find(on=>on.sessionId===Te.id);return{...Te,title:Ze(Ae&&(Ae.startedAt||Ae.scheduledFor)||"",Z.get(ve.id)),updatedAt:Ae&&(Ae.startedAt||Ae.scheduledFor)||"",running:Te.running||g[Te.id]?.running===!0}})})).filter(ve=>ve.sessions.length>0)},[Me,k,g,p.snapshot]);(0,P.useEffect)(()=>{if(!wn(u,p.snapshot?.runs)){Gn.current=null;return}Gn.current!==u&&(Gn.current=u,t.refresh().catch(()=>{}))},[t,u,p.snapshot?.runs]);let Un=(0,P.useMemo)(()=>{let C=ke==="workspace-tree"?us(Vn.flatMap(Z=>Z.sessions.map(ve=>({...ve,automationId:Z.id}))),S,n("sidebar.ungrouped")):Vn;return ps(C.map(Z=>({...Z,name:Z.name})),I,Ce,ke)},[ke,Vn,I,Ce,n,S]);(0,P.useEffect)(()=>{if(typeof document>"u"||typeof MutationObserver>"u")return;let C=()=>{we(mt(document))};C();let Z=new MutationObserver(C);return Z.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{Z.disconnect()}},[]);let $o=ye&&a!==void 0,Ko=ro(ye,c),bt=l!==void 0,jo=()=>{if(O===void 0||a===void 0||_)return;let C=O;oe(!0),U(void 0),co(C.sessionIds,a).then(()=>{z(void 0)}).catch(Z=>{U(Z instanceof Error?Z.message:n("error.action"))}).finally(()=>{oe(!1)})},qo=()=>{if(M===void 0||l===void 0||x)return;let C=M;V(!0),ne(void 0),uo(C.sessionIds,l).then(()=>{G(void 0)}).catch(Z=>{ne(Z instanceof Error?Z.message:n("error.action"))}).finally(()=>{V(!1)})},Zo=()=>{if(te===void 0||c===void 0||xe)return;let C=te;ge(!0),re(void 0),Promise.resolve(c(C.id)).then(()=>{fe(void 0)}).catch(Z=>{re(Z instanceof Error?Z.message:n("error.action"))}).finally(()=>{ge(!1)})};return(0,v.jsxs)("div",{className:"dsh-st-n",children:[(0,v.jsx)("div",{className:"dsh-st-n-views-wrap",children:(0,v.jsx)(Pn,{t:n,view:vt,onChange:Bo})}),(0,v.jsx)("div",{id:Ke,role:"tabpanel",className:"dsh-st-n-view-body",children:vt==="overview"?p.snapshot===void 0?(0,v.jsx)("div",{className:"dsh-st-n-empty",children:p.phase==="loading"?n("loading"):n("overview.empty")}):(0,v.jsx)(Dn,{t:n,automations:p.snapshot.automations,onToggleAutomation:(C,Z)=>t.mutateAutomation(C,Z),...T===void 0?{}:{openTaskSettings:T},...p.snapshot.serverNow===void 0?{}:{serverNow:p.snapshot.serverNow}}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xo,{t:n,query:I,sort:Ce,groupMode:ke,archivedFilter:k,onQueryChange:B,onSortChange:Vo,onGroupModeChange:Uo,onArchivedFilterChange:d}),(0,v.jsx)("div",{className:"dsh-st-n-list-area",children:(0,v.jsxs)("div",{className:"dsh-st-n-tree",role:"tree",children:[p.phase==="loading"&&Un.length===0&&(0,v.jsx)("div",{className:"dsh-st-n-empty",children:n("loading")}),Un.length===0&&p.phase!=="loading"&&(0,v.jsx)("div",{className:"dsh-st-n-empty",children:n("sidebar.empty")}),Un.map(C=>{let Z=H[C.id]!==!0,ve=ao(C.sessions.map(E=>E.id),u),Te="depth"in C?C.depth:0,Ae=[...new Set(C.sessions.flatMap(E=>"automationId"in E&&typeof E.automationId=="string"?[E.automationId]:[]))],on=ke==="workspace-tree"&&Ae.length===1?p.snapshot?.automations.find(E=>E.id===Ae[0]):void 0,Bn=ke==="workspace-tree"?on?.id:C.id,Xo=ke==="workspace-tree"?on?.name:C.name,wt=C.sessions.filter(E=>!Me.has(E.id)).map(E=>E.id),St=C.sessions.filter(E=>Me.has(E.id)).map(E=>E.id),Jo=$o&&wt.length>0,Yo=bt&&St.length>0;return(0,v.jsxs)("div",{className:"dsh-st-n-group",style:Te>0?{"--dsh-workspace-indent":`${Te*12}px`}:void 0,children:[ke!=="list"&&(0,v.jsx)($r,{t:n,id:C.id,name:C.name,sessionIds:C.sessions.map(E=>E.id),expanded:Z,hasCurrentSession:ve,menuOpen:se===C.id,canArchiveGroup:Jo,canUnarchiveGroup:Yo,showTaskSettings:Bn!==void 0,onToggle:()=>ae(E=>({...E,[C.id]:Z})),onMenuChange:E=>{W(void 0),K(E?C.id:void 0)},onTaskSettings:()=>{Bn!==void 0&&T?.({automationId:Bn,name:Xo??C.name,sessionIds:C.sessions.map(E=>E.id)})},onArchiveGroup:()=>{U(void 0),z({id:C.id,name:C.name,sessionIds:wt})},onUnarchiveGroup:()=>{ne(void 0),G({id:C.id,name:C.name,sessionIds:St})}}),(ke==="list"||Z)&&C.sessions.map(E=>(0,v.jsx)(Kr,{t:n,flat:ke==="list",id:E.id,title:E.title,hoverTitle:String(g[E.id]?.displayTitle??g[E.id]?.title??C.name),updatedAt:E.updatedAt,running:E.running,archived:Me.has(E.id),selected:u===E.id,menuOpen:de===E.id,canDelete:Ko,canUnarchive:bt,hoverStatuses:ho({running:E.running||R?.get(E.id)?.running===!0,archived:Me.has(E.id),completed:R?.get(E.id)?.completionUnread===!0,...R?.get(E.id)?.pendingInteraction?.kind===void 0?{}:{pendingKind:R.get(E.id)?.pendingInteraction?.kind??""},runningSubagentCount:(L?.[E.id]?.values?.subagentCatalog??[]).filter(rn=>rn.id!==void 0&&R?.get(rn.id)?.running===!0).length},n),...A===void 0?{}:{renderSlot:A},onMenuChange:rn=>{K(void 0),W(rn?E.id:void 0)},onOpen:()=>{if(W(void 0),Me.has(E.id)){m?.();return}s?.(E.id)},onDeleteSession:()=>{re(void 0),fe({id:E.id,title:String(g[E.id]?.displayTitle??g[E.id]?.title??E.title)})},...o===void 0?{}:{renameSession:o},...a===void 0?{}:{archiveSession:a},...l===void 0?{}:{unarchiveSession:l},...y===void 0?{}:{forkSession:y}},E.id))]},C.id===""?"ungrouped":C.id)})]})})]})}),(0,v.jsx)(j.Modal,{open:O!==void 0,onClose:()=>{_||(z(void 0),U(void 0))},closeLabel:n("session.archiveGroupClose"),title:n("session.archiveGroup"),...O===void 0?{}:{description:n("session.archiveGroupDescription",{name:O.name,count:O.sessionIds.length})},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(j.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:_,onClick:()=>{z(void 0),U(void 0)},children:n("session.archiveGroupCancel")}),(0,v.jsx)(j.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:_,onClick:jo,children:n("session.archiveGroupConfirm")})]}),children:_||pe!==void 0?(0,v.jsxs)(v.Fragment,{children:[_&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.archiveGroupPending")}),pe!==void 0&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.archiveGroupFailed",{message:pe})})]}):void 0}),(0,v.jsx)(j.Modal,{open:M!==void 0,onClose:()=>{x||(G(void 0),ne(void 0))},closeLabel:n("session.unarchiveGroupClose"),title:n("session.unarchiveGroup"),...M===void 0?{}:{description:n("session.unarchiveGroupDescription",{name:M.name,count:M.sessionIds.length})},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(j.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:x,onClick:()=>{G(void 0),ne(void 0)},children:n("session.unarchiveGroupCancel")}),(0,v.jsx)(j.Button,{variant:"primary",className:"dsh-st-modal-action",disabled:x,onClick:qo,children:n("session.unarchiveGroupConfirm")})]}),children:x||q!==void 0?(0,v.jsxs)(v.Fragment,{children:[x&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.unarchiveGroupPending")}),q!==void 0&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.unarchiveGroupFailed",{message:q})})]}):void 0}),(0,v.jsx)(j.Modal,{open:te!==void 0,onClose:()=>{xe||(fe(void 0),re(void 0))},closeLabel:n("session.deleteSessionClose"),title:n("session.deleteSession"),...te===void 0?{}:{description:n("session.deleteSessionDescription",{name:te.title})},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(j.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:xe,onClick:()=>{fe(void 0),re(void 0)},children:n("session.deleteSessionCancel")}),(0,v.jsx)(j.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:xe,onClick:Zo,children:n("session.deleteSessionConfirm")})]}),children:xe||J!==void 0?(0,v.jsxs)(v.Fragment,{children:[xe&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.deleteSessionPending")}),J!==void 0&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.deleteSessionFailed",{message:J})})]}):void 0})]})}function $r(e){let{t:n,id:t,name:s,expanded:r,hasCurrentSession:i,menuOpen:o,canArchiveGroup:a,canUnarchiveGroup:l,showTaskSettings:c,onToggle:y,onMenuChange:m,onTaskSettings:T,onArchiveGroup:A,onUnarchiveGroup:f}=e,p=[...c?[{id:"task-settings",label:n("session.taskSettings"),icon:(0,v.jsx)(bs,{size:16})}]:[],...a?[...c?[{type:"separator",id:"archive-separator"}]:[],{id:"archive-group",label:n("session.archiveGroup"),icon:(0,v.jsx)(_e,{size:16}),danger:!0}]:[],...l?[...c&&!a?[{type:"separator",id:"unarchive-separator"}]:[],{id:"unarchive-group",label:n("session.unarchiveGroup"),icon:(0,v.jsx)(Qn,{size:16})}]:[]],u="dsh-st-n-row"+(i?" has-current-session":"")+(o?" is-menu":"");return(0,v.jsxs)("div",{className:u,role:"treeitem","aria-expanded":r,"data-n-group":t,onClick:y,children:[(0,v.jsx)("span",{className:"dsh-st-n-slot dsh-st-n-folder",children:r?(0,v.jsx)(Ts,{size:16}):(0,v.jsx)(ze,{size:16})}),(0,v.jsx)("span",{className:"dsh-st-n-slot dsh-st-n-chevron",children:(0,v.jsx)(As,{size:14,className:"dsh-st-n-arrow"+(r?" is-open":"")})}),(0,v.jsx)("span",{className:"dsh-st-n-project-text",children:(0,v.jsx)("span",{className:"dsh-st-n-title",children:s})}),(0,v.jsx)("span",{className:"dsh-st-n-acts",children:(0,v.jsx)(j.Menu,{open:o,onClose:()=>{m(!1)},items:p,onSelect:g=>{m(!1),g==="task-settings"&&T(),g==="archive-group"&&A(),g==="unarchive-group"&&f?.()},portal:!0,closeOnPointerLeave:!0,anchor:(0,v.jsx)(j.Tooltip,{label:n("session.groupActions",{name:s}),side:"bottom",delayMs:500,portal:!0,children:(0,v.jsx)("button",{type:"button",className:"dsh-st-n-ico","aria-label":n("session.groupActions",{name:s}),onMouseDown:g=>{g.stopPropagation()},onClick:g=>{g.stopPropagation(),m(!o)},children:(0,v.jsx)(Ye,{size:16})})})})})]})}function Kr(e){let{t:n,flat:t,id:s,title:r,hoverTitle:i,updatedAt:o,running:a,archived:l,selected:c,menuOpen:y,canDelete:m,canUnarchive:T,hoverStatuses:A,renderSlot:f,onMenuChange:p,onOpen:u,onDeleteSession:g,renameSession:h,archiveSession:S,unarchiveSession:R,forkSession:L}=e,H=lo(t,a),ae=(0,P.useRef)(null),de=(0,P.useRef)(null),[W,se]=(0,P.useState)(!1),[K,O]=(0,P.useState)({}),z=(0,P.useRef)(void 0),_=(0,P.useRef)(null),oe=(0,P.useRef)({id:0});(0,P.useEffect)(()=>()=>{ft(_.current,oe.current)},[]);let[pe,U]=(0,P.useState)(!1),[M,G]=(0,P.useState)(r);(0,P.useEffect)(()=>{G(r)},[r]),(0,P.useEffect)(()=>{if(typeof j.HoverCard=="function"||!W||y)return;let d=()=>{let I=ae.current?.getBoundingClientRect(),B=de.current;if(I===void 0)return;let Ce=B===null?{width:220,height:96}:{width:B.offsetWidth,height:B.offsetHeight};O(fo({right:I.right,top:I.top},Ce,{width:window.innerWidth,height:window.innerHeight}))};return d(),window.addEventListener("resize",d),document.addEventListener("scroll",d,!0),()=>{window.removeEventListener("resize",d),document.removeEventListener("scroll",d,!0)}},[W,y,r,o,a]),(0,P.useEffect)(()=>()=>{z.current!==void 0&&window.clearTimeout(z.current)},[]);let x=d=>{Promise.resolve(d()).catch(()=>{})},V=()=>{typeof j.HoverCard=="function"||y||(z.current!==void 0&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>se(!0),500))},q=()=>{z.current!==void 0&&window.clearTimeout(z.current),se(!1)},ne="dsh-st-n-sess"+(c?" is-on":"")+(y?" is-menu":"")+(H?" is-flat-idle":"")+(l?" is-archived":"");if(pe)return(0,v.jsx)("div",{className:ne,ref:ae,children:(0,v.jsx)("input",{className:"dsh-st-n-rename",value:M,autoFocus:!0,"aria-label":n("session.rename"),onChange:d=>G(d.target.value),onClick:d=>d.stopPropagation(),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),U(!1),M.trim()!==""&&M.trim()!==r&&x(()=>h?.(s,M.trim()))),d.key==="Escape"&&(d.preventDefault(),U(!1),G(r))},onBlur:()=>{U(!1),M.trim()!==""&&M.trim()!==r&&x(()=>h?.(s,M.trim()))}})});let te=(i??r).trim()||r,fe=f!==void 0?["pin","rename","fork","archive","session-id","archive-manager.delete-session"].map(d=>f("sidebar.workspaces.session.menu.item",{sessionId:s,displayTitle:te},{hookContext:[y,I=>p(I)],only:d})).filter(Boolean):void 0,ge=fe!==void 0&&fe.some(Boolean)?l&&m?[{id:"delete-session",label:n("session.deleteSession"),icon:(0,v.jsx)(Yn,{}),danger:!0}]:[]:[...io({canDelete:m,archived:l,canUnarchive:T}).map(d=>d==="rename"?{id:d,label:n("session.rename"),icon:(0,v.jsx)(Ss,{})}:d==="fork"?{id:d,label:n("session.fork"),icon:(0,v.jsx)(ws,{})}:d==="archive"?{id:d,label:n("session.archive"),icon:(0,v.jsx)(_e,{size:16})}:d==="unarchive"?{id:d,label:n("session.unarchive"),icon:(0,v.jsx)(Qn,{size:16})}:{id:d,label:n("session.deleteSession"),icon:(0,v.jsx)(Yn,{}),danger:!0}),{id:"session-id",label:n("session.copySessionId"),icon:(0,v.jsx)(Is,{size:16})}],J=A.find(d=>d.state!=="archived"),re=!l&&J!==void 0&&J.state!=="idle",ye=J?.trailing,we=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"dsh-st-n-hover-title",children:te}),(0,v.jsx)("div",{className:"dsh-st-n-hover-time",children:wo(o,n)}),A.map(d=>(0,v.jsxs)("div",{className:"dsh-st-n-hover-state",children:[d.state==="archived"?(0,v.jsx)(_e,{size:14}):(0,v.jsx)(j.StateDot,{state:d.state==="ongoing"?"ongoing":d.state==="warning"?"warning":d.state==="done"?"done":"idle",size:10}),d.label]},d.label))]}),k=(0,v.jsxs)("div",{className:ne,ref:ae,role:"treeitem",tabIndex:0,"aria-selected":c,"data-n-menu-root":s,onClick:u,onMouseEnter:()=>{vo(_.current,oe.current),V()},onMouseLeave:()=>{ft(_.current,oe.current),q()},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),u())},onContextMenu:d=>{d.preventDefault(),d.stopPropagation(),q(),p(!0)},children:[!H&&(0,v.jsx)("span",{className:"dsh-st-n-slot",children:re&&J!==void 0?(0,v.jsx)(j.StateDot,{state:J.state==="ongoing"?"ongoing":J.state==="warning"?"warning":"done",size:10}):a?(0,v.jsx)(j.StateDot,{state:"ongoing",size:10}):null}),(0,v.jsx)("span",{ref:_,className:"dsh-st-n-title",onDoubleClick:d=>{h!==void 0&&(d.stopPropagation(),U(!0))},children:r}),(0,v.jsx)("span",{className:"dsh-st-n-time","aria-hidden":ye===void 0?void 0:!0,children:ye??bo(o,n)}),(0,v.jsxs)("span",{className:"dsh-st-n-acts",children:[fe===void 0&&l&&T&&(0,v.jsx)("button",{type:"button",className:"dsh-st-n-restore",onMouseDown:d=>{d.stopPropagation()},onClick:d=>{d.stopPropagation(),x(()=>R?.(s))},children:n("session.unarchive")}),(0,v.jsx)(j.Menu,{open:y,onClose:()=>{p(!1)},items:ge,onSelect:d=>{p(!1),d==="rename"&&U(!0),d==="fork"&&x(()=>L?.(s)),d==="archive"&&x(()=>S?.(s)),d==="unarchive"&&x(()=>R?.(s)),d==="session-id"&&navigator.clipboard?.writeText(s),d==="delete-session"&&g?.()},portal:!0,closeOnPointerLeave:!0,anchor:(0,v.jsx)(j.Tooltip,{label:n("session.moreActions",{title:r}),side:"bottom",delayMs:500,portal:!0,children:(0,v.jsx)("button",{type:"button",className:"dsh-st-n-ico","aria-label":n("session.moreActions",{title:r}),onMouseDown:d=>{d.stopPropagation()},onClick:d=>{d.stopPropagation(),q(),p(!y)},children:(0,v.jsx)(Ye,{size:16})})}),children:fe}),mo(f,"sidebar.workspaces.session.row.action",{sessionId:s,displayTitle:te},{only:"archive"})]}),typeof j.HoverCard!="function"&&W&&!y&&typeof document<"u"&&(0,Ao.createPortal)((0,v.jsx)("div",{ref:de,className:"dsh-st-n-hover",style:K,onMouseEnter:V,onMouseLeave:q,children:we}),document.body)]});return typeof j.HoverCard!="function"?k:(0,v.jsx)(j.HoverCard,{anchor:k,content:we,openDelayMs:800,disabled:y,copyText:te,copyLabel:n("session.copy"),copiedLabel:n("session.copied")})}var F=require("react"),Hn=require("@deepseek-ai/dsh-client-ui-primitives");var N=require("react/jsx-runtime"),Io=[],Co=e=>()=>{},sn="dsh-st-shell-panel",ht=class extends F.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(n){console.warn("[dsh-automation] official workspace tree crashed",n)}render(){return this.state.failed?this.props.fallback:this.props.children}};function No({t:e,runtime:n,openSession:t,openTaskSettings:s,view:r,showViewSwitch:i=!0}){let o=(0,F.useSyncExternalStore)(n.source.subscribe,n.source.getSnapshot,n.source.getSnapshot),[a,l]=(0,F.useState)({}),[c,y]=(0,F.useState)("runs"),m=r??c,T=o.snapshot,A=(0,F.useMemo)(()=>T===void 0?[]:vn(T.automations,T.runs),[T]);return(0,N.jsxs)("div",{className:"dsh-st-rail",children:[i&&(0,N.jsx)("div",{className:"dsh-st-n-views-wrap",children:(0,N.jsx)(Pn,{t:e,view:m,onChange:y})}),(0,N.jsx)("div",{id:Ke,role:"tabpanel",className:"dsh-st-rail-panel",children:m==="overview"?T===void 0?(0,N.jsx)("div",{className:"dsh-st-rail-empty",children:o.phase==="loading"?e("loading"):e("overview.empty")}):(0,N.jsx)(Dn,{t:e,automations:T.automations,onToggleAutomation:(f,p)=>n.mutateAutomation(f,p),...s===void 0?{}:{openTaskSettings:s},...T.serverNow===void 0?{}:{serverNow:T.serverNow}}):(0,N.jsxs)(N.Fragment,{children:[o.phase==="loading"&&A.length===0&&(0,N.jsx)("div",{className:"dsh-st-rail-empty",children:e("loading")}),A.length===0&&o.phase!=="loading"&&(0,N.jsx)("div",{className:"dsh-st-rail-empty",children:e("sidebar.empty")}),A.map(f=>(0,N.jsxs)("section",{className:"dsh-st-rail-group",children:[(0,N.jsxs)("button",{type:"button",className:"dsh-st-rail-head",onClick:()=>l(p=>({...p,[f.id]:!p[f.id]})),children:[(0,N.jsx)("span",{className:"dsh-st-rail-folder",children:(0,N.jsx)(Ie,{size:16})}),(0,N.jsx)("span",{className:"dsh-st-rail-title",children:f.name})]}),a[f.id]!==!0&&f.sessions.map(p=>(0,N.jsxs)("button",{type:"button",className:"dsh-st-rail-session",onClick:()=>t?.(p.id),children:[(0,N.jsx)("span",{children:p.label}),p.running&&(0,N.jsx)(Hn.StateDot,{state:"ongoing",size:10})]},p.id))]},f.id))]})})]})}function Ro({t:e,runtime:n,officialTree:t,hostProps:s,openSession:r,openTaskSettings:i,useSessions:o,useWorkspaces:a,renderSlot:l,hasChannels:c,subscribeChannels:y,tabRegistry:m,wide:T}){let A=t,[f,p]=(0,F.useState)(()=>{try{return Zt(window.localStorage.getItem(Xn))}catch{return"tasks"}}),u=(0,F.useSyncExternalStore)(m?.subscribe??Co,()=>m?.getTabs()??Io,()=>Io),g=(0,F.useSyncExternalStore)(y??Co,()=>{try{return c?.()===!0}catch{return!1}},()=>!1),h=o?.(x=>Xe(x)),S=(0,F.useSyncExternalStore)(n.source.subscribe,n.source.getSnapshot,n.source.getSnapshot),R=(0,F.useMemo)(()=>jt(S.snapshot?.runs),[S.snapshot]),L=(0,F.useRef)(null);(0,F.useEffect)(()=>{if(!wn(h,S.snapshot?.runs)){L.current=null;return}L.current!==h&&(L.current=h??null,n.refresh().catch(()=>{}))},[S.snapshot?.runs,h,n]);let H=(0,F.useCallback)((x,V)=>o===void 0?x({ids:[],byId:{}}):o(q=>x(ts(q,R)),V),[o,R]),ae=(0,F.useCallback)((x,V)=>a===void 0?x({items:[],archivedSessionIds:[]}):a(q=>x(as(q,R)),V),[a,R]);(0,F.useEffect)(()=>{try{window.localStorage.setItem(Xn,f)}catch{}},[f]),(0,F.useEffect)(()=>{let x=V=>{let q=V.target instanceof Element?V.target.closest("button"):null;if(q===null)return;let ne=`${q.textContent??""} ${q.getAttribute("aria-label")??""}`;/新会话|新建任务|New chat|New session/i.test(ne)&&p("tasks")};return document.addEventListener("click",x,!0),()=>document.removeEventListener("click",x,!0)},[]);let de=(0,F.useRef)(h),W=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let x=Qt(h??void 0,R);if(!W.current){W.current=!0,de.current=h,x==="tasks"&&p("tasks");return}let V=de.current;if(de.current=h,!Xt(V,h))return;let q=u.map(te=>te.id);x==="tasks"&&p("tasks"),x==="channels"&&(g||q.includes("channels"))&&p("channels");let ne=u.find(te=>h!=null&&te.matchSession?.(String(h))===!0);ne!==void 0&&ne.id!=="schedule"&&p(ne.id)},[h,g,u,R]);let se={...s??{},...T===void 0?{}:{wide:T}},K={...se,...o===void 0?{}:{useSessions:H},...a===void 0?{}:{useWorkspaces:ae}},O=x=>A===void 0?(0,N.jsx)(jr,{t:e,...r===void 0?{}:{openSession:r},...o===void 0?{}:{useSessions:H},...a===void 0?{}:{useWorkspaces:a}}):(0,N.jsx)(ht,{fallback:(0,F.createElement)(A,se),children:(0,F.createElement)(A,x)});if(T===!1)return(0,N.jsx)(N.Fragment,{children:O(K)});let z=(0,F.useMemo)(()=>u.filter(x=>x.id!=="schedule"),[u]),_=Yt({tab:f,channelsReady:g,extraTabIds:Jt({extraTabIds:z.map(x=>x.id),channelsReady:g})}),oe=u.find(x=>x.id==="schedule"),pe=oe===void 0?(0,N.jsx)(On,{t:e,runtime:n,...r===void 0?{}:{openSession:r},...i===void 0?{}:{openTaskSettings:i},...o===void 0?{}:{useSessions:o},...a===void 0?{}:{useWorkspaces:a},...l===void 0?{}:{renderSlot:l},...En(s),...typeof s?.useSessionStatus=="function"?{useSessionStatus:s.useSessionStatus}:{}}):oe.render({...s??{},openSession:r,open:r,useSessions:o,wide:!0}),U=(0,F.useMemo)(()=>{let x=[{value:"tasks",id:"dsh-st-tab-tasks",panelId:sn,label:(0,N.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[(0,N.jsx)(ze,{size:14}),(0,N.jsx)("span",{children:e("sidebar.tasksTab")})]})}];for(let V of z){if(V.id==="tasks")continue;let q=V.id==="channels"?(0,N.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[(0,N.jsx)("svg",{viewBox:"0 0 16 16",width:14,height:14,fill:"none","aria-hidden":"true",children:(0,N.jsx)("path",{fill:"currentColor",d:"M2.15 2.9h11.7v8.2H6.42L2.15 13.85V2.9Zm1.4 1.4v6.62l1.78-1.12h7.12V4.3H3.55Z"})}),(0,N.jsx)("span",{children:V.label})]}):V.label;x.push({value:V.id,id:"dsh-st-tab-"+V.id,panelId:sn,label:q})}return g&&z.every(V=>V.id!=="channels")&&x.push({value:"channels",id:"dsh-st-tab-channels",panelId:sn,label:(0,N.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[(0,N.jsx)("svg",{viewBox:"0 0 16 16",width:14,height:14,fill:"none","aria-hidden":"true",children:(0,N.jsx)("path",{fill:"currentColor",d:"M2.15 2.9h11.7v8.2H6.42L2.15 13.85V2.9Zm1.4 1.4v6.62l1.78-1.12h7.12V4.3H3.55Z"})}),(0,N.jsx)("span",{children:e("sidebar.channelsTab")})]})}),x.push({value:"schedule",id:"dsh-st-tab-schedule",panelId:sn,label:(0,N.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[(0,N.jsx)(Ie,{size:14}),(0,N.jsx)("span",{children:e("sidebar.tab")})]})}),x},[g,z,e]),M=_==="schedule"||_==="channels"?void 0:z.find(x=>x.id===_),G=M!==void 0||_==="schedule"||_==="channels"?"dsh-st-shell-body":"dsh-st-official-tree";return(0,N.jsxs)("div",{className:"dsh-st-shell-rail",children:[(0,N.jsx)("div",{className:"dsh-st-shell-tabs-wrap",children:(0,N.jsx)(Hn.SegmentedTabs,{className:"dsh-st-shell-segmented-tabs",label:e("sidebar.tabs"),value:_,onChange:x=>p(x),items:U})}),(0,N.jsx)("div",{id:sn,role:"tabpanel",className:G,children:_==="schedule"?pe:M!==void 0?M.render({...s??{},openSession:r,open:r,useSessions:o,wide:!0}):_==="channels"?l?.("sidebar.channels",{...s??{},openSession:r,open:r,useSessions:o,wide:!0,skin:"native"}):O(K)})]})}function jr({t:e,openSession:n,useSessions:t,useWorkspaces:s}){let r=t===void 0?{ids:[],byId:{}}:t(l=>l??{ids:[],byId:{}}),i=s===void 0?void 0:s(l=>l??{items:[],archivedSessionIds:[]}),o=qt(r,i,e("sidebar.ungrouped")),a=Xe(r);return o.length===0?(0,N.jsx)("div",{className:"dsh-st-rail-empty",children:e("sidebar.tasksEmpty")}):(0,N.jsx)("div",{className:"dsh-st-rail",children:o.map(l=>(0,N.jsxs)("section",{className:"dsh-st-rail-group",children:[(0,N.jsx)("div",{className:"dsh-st-rail-head is-static",children:(0,N.jsx)("span",{className:"dsh-st-rail-title",children:l.label})}),l.sessions.map(c=>(0,N.jsx)("button",{type:"button",className:`dsh-st-rail-session${a===c.id?" is-on":""}`,onClick:()=>{c.id!==void 0&&n?.(c.id)},children:(0,N.jsx)("span",{children:c.title||c.id})},c.id))]},l.id||"ungrouped"))})}var Eo="dsh-automation-styles",Fn="@michengai/dsh-automation",Mo=`
|
|
4
4
|
.dsh-st-shell{container-type:inline-size;min-width:0;box-sizing:border-box;max-width:1080px;width:100%;margin:0 auto;padding:0 0 32px;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family,system-ui)}
|
|
5
5
|
.dsh-st-top{display:flex;flex-direction:column;align-items:stretch;gap:12px;margin-bottom:12px}
|
|
6
6
|
.dsh-st-heading h1,.dsh-st-top h1{margin:0;font-size:24px;line-height:32px;font-weight:600;letter-spacing:-.4px;white-space:nowrap}
|
|
@@ -94,8 +94,19 @@ var module = { exports: {} }; var exports = module.exports;
|
|
|
94
94
|
.dsh-st-composer-left,.dsh-st-composer-right{display:flex;align-items:center;gap:2px;min-width:0}
|
|
95
95
|
.dsh-st-composer-left{flex:1}.dsh-st-composer-right{flex:none}
|
|
96
96
|
@media(max-width:860px){.dsh-st-toolbar{flex-wrap:wrap}.dsh-st-search{flex-basis:100%;max-width:none}.dsh-st-grid,.dsh-st-example-row{grid-template-columns:1fr}.dsh-st-filters{width:100%;margin:8px 0}}
|
|
97
|
-
.dsh-st-
|
|
98
|
-
.dsh-st-
|
|
97
|
+
.dsh-st-n-views-wrap{display:flex;flex:none;margin:2px 0 8px;padding:0;width:100%}
|
|
98
|
+
.dsh-st-n-views-wrap .dsh-st-rail-views{margin:0!important;width:100%!important}
|
|
99
|
+
.dsh-st-n-view-body{display:flex;flex:1;min-width:0;min-height:0;flex-direction:column}
|
|
100
|
+
/* \u4EE5\u4E0B\u4E24\u6BB5\u8986\u76D6\u5BBF\u4E3B SegmentedTabs \u7684\u80F6\u56CA\u5916\u89C2\u3002\u9009\u62E9\u5668\u4F9D\u8D56\u539F\u8BED\u6E32\u67D3\u51FA\u7684\u7ED3\u6784\uFF1A
|
|
101
|
+
\u5BB9\u5668 [role=tablist] \u7684\u9996\u4E2A\u5B50\u5143\u7D20\u662F aria-hidden \u7684\u6ED1\u52A8\u6307\u793A\u5668\uFF0C\u5176\u540E\u624D\u662F\u5404 [role=tab]\u3002
|
|
102
|
+
\u5347\u7EA7 @deepseek-ai/dsh-client-ui-primitives \u65F6\u5FC5\u987B\u590D\u6838\u8BE5\u7ED3\u6784\uFF0C\u5426\u5219\u8FD9\u4E9B\u89C4\u5219\u4F1A\u9759\u9ED8\u5931\u6548\u3002 */
|
|
103
|
+
.dsh-st-rail-views{display:grid!important;width:100%;margin:0!important;padding:2px!important;background:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 3%,transparent)!important;border-radius:8px!important;border:0.5px solid var(--dsw-alias-border-l1,rgba(255,255,255,.05))!important;box-sizing:border-box}
|
|
104
|
+
.dsh-st-rail-views>span[aria-hidden="true"]{inset:2px auto 2px 2px!important;border-radius:6px!important;border:0.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.08))!important;background:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 8%,transparent)!important;border-color:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 12%,transparent)!important;box-shadow:none!important}
|
|
105
|
+
.dsh-st-rail-views [role=tab]{display:inline-flex!important;align-items:center!important;justify-content:center!important;gap:5px!important;width:100%!important;height:26px!important;padding:0 6px!important;font-size:13px!important;line-height:18px!important;border-radius:6px!important;color:var(--dsw-alias-label-secondary,#8b8f98);font-weight:500;text-align:center!important}
|
|
106
|
+
.dsh-st-rail-views [role=tab]>*{display:inline-flex!important;align-items:center!important;justify-content:center!important}
|
|
107
|
+
.dsh-st-rail-views [role=tab]:hover{color:var(--dsw-alias-label-primary,inherit)}
|
|
108
|
+
.dsh-st-rail-views [role=tab][aria-selected=true]{color:var(--dsw-alias-label-primary,inherit)!important;font-weight:600}
|
|
109
|
+
.dsh-st-overview{display:flex;flex-direction:column;flex:1;min-height:0;overflow-y:auto;padding:2px 0 14px}
|
|
99
110
|
.dsh-st-overview-head{display:flex;flex:none;align-items:center;justify-content:space-between;gap:8px;height:36px;min-height:36px;margin-bottom:4px;padding:6px 0}
|
|
100
111
|
.dsh-st-overview-title{display:flex;align-items:baseline;min-width:0;gap:6px;color:var(--dsw-alias-label-tertiary,#81858C)}
|
|
101
112
|
.dsh-st-overview-title strong{font-size:14px;font-weight:400;line-height:20px}
|
|
@@ -127,10 +138,13 @@ var module = { exports: {} }; var exports = module.exports;
|
|
|
127
138
|
.dsh-st-rail-session span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
128
139
|
.dsh-st-run-dot{flex:none;color:var(--dsw-static-deepseek-450,#4c8dff)}.dsh-st-run-dot-cell{fill:currentColor;opacity:.15;animation:dsh-st-run-chase 1s infinite}@keyframes dsh-st-run-chase{0%,12.4%{opacity:1}12.5%,24.9%{opacity:.6}25%,37.4%{opacity:.35}37.5%,100%{opacity:.15}}
|
|
129
140
|
.dsh-st-shell-rail{display:flex;flex-direction:column;min-height:0;flex:1;height:100%;overflow:hidden}
|
|
130
|
-
.dsh-st-shell-tabs{display:flex;
|
|
131
|
-
.dsh-st-shell-tabs
|
|
132
|
-
.dsh-st-shell-tabs
|
|
133
|
-
.dsh-st-shell-tabs
|
|
141
|
+
.dsh-st-shell-tabs-wrap{display:flex;margin:2px var(--dsh-sidebar-inline-padding,12px) 8px 0;padding:0;width:auto}
|
|
142
|
+
.dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs{width:100%;background:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 3%,transparent)!important;border-radius:8px!important;border:0.5px solid var(--dsw-alias-border-l1,rgba(255,255,255,.05))!important;box-sizing:border-box;padding:2px!important}
|
|
143
|
+
.dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs>span[aria-hidden="true"]{inset:2px auto 2px 2px!important;border-radius:6px!important;border:0.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.08))!important;background:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 8%,transparent)!important;border-color:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 12%,transparent)!important;box-shadow:none!important}
|
|
144
|
+
.dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs [role=tab]{display:inline-flex!important;align-items:center!important;justify-content:center!important;gap:5px!important;width:100%!important;height:26px!important;padding:0 6px!important;font-size:13px!important;line-height:18px!important;border-radius:6px!important;color:var(--dsw-alias-label-secondary,#8b8f98);text-align:center!important}
|
|
145
|
+
.dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs [role=tab]>*{display:inline-flex!important;align-items:center!important;justify-content:center!important}
|
|
146
|
+
.dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs [role=tab]:hover{color:var(--dsw-alias-label-primary,inherit)}
|
|
147
|
+
.dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs [role=tab][aria-selected=true]{color:var(--dsw-alias-label-primary,inherit)!important;font-weight:600}
|
|
134
148
|
.dsh-st-shell-body{display:flex;min-height:0;flex:1;overflow:hidden}
|
|
135
149
|
.dsh-st-shell-body>*{min-width:0;flex:1}.dsh-st-official-tree{display:flex;min-height:0;flex:1;overflow:hidden}.dsh-st-official-tree>*{min-width:0;flex:1}
|
|
136
150
|
.dsh-st-rail-head.is-static{cursor:default;font-weight:600}
|
|
@@ -160,7 +174,7 @@ var module = { exports: {} }; var exports = module.exports;
|
|
|
160
174
|
.dsh-st-n-sess .dsh-st-n-title[data-clipped]{mask-image:linear-gradient(270deg,#0000,#000 12px)}
|
|
161
175
|
.dsh-st-n-sess .dsh-st-n-title[data-scrolled][data-clipped]{mask-image:linear-gradient(90deg,#0000,#000 12px calc(100% - 12px),#0000)}
|
|
162
176
|
.dsh-st-create-dialog{width:min(720px,100%) !important;max-height:100%}
|
|
163
|
-
`;function
|
|
177
|
+
`;function Po(){let e=document.getElementById(Eo);if(e instanceof HTMLStyleElement)return e.textContent=Mo,e.setAttribute("data-plugin",Fn),()=>{};let n=document.createElement("style");return n.id=Eo,n.textContent=Mo,n.setAttribute("data-plugin",Fn),document.head.append(n),()=>{n.remove()}}var Lo="michengai-plugin-update-ui";function Do(e){let n=document.getElementById(Lo);if(n instanceof HTMLStyleElement){n.getAttribute("data-plugin")===null&&n.setAttribute("data-plugin",Fn);return}let t=document.createElement("style");t.id=Lo,t.textContent=e,t.setAttribute("data-plugin",Fn),(document.head??document.documentElement).append(t)}function qr(e,n){for(let t of n){let s=t.trim();if(s==="")continue;let r=e.find(i=>i.textContent?.replace(/\s+/g," ").trim()===s);if(r!==void 0)return r}}function Zr(e){return e.find(t=>{let s=`${t.textContent??""} ${t.getAttribute("aria-label")??""}`.trim();return/(^|\s)(设置|settings)(\s|$)/i.test(s)})??(e.length===1?e[0]:void 0)}var Wn,Ho="[data-dcu-settings-trigger]",Oo="[data-dcu-settings-page]",Xr="dcu-settings-open-section";function Jr(e){let n=document.querySelector(Ho);if(n===null)return!1;let t=new CustomEvent(Xr,{detail:{labels:[...e]},cancelable:!0});return!n.dispatchEvent(t)}function Fo(e,n,t){if(typeof document>"u"||typeof window>"u"){t?.();return}if(Jr(e)){n?.();return}let s=[...document.querySelectorAll('button[aria-haspopup="dialog"]')],r=Zr(s),i=document.querySelector(Ho),o=document.querySelector('[role="dialog"]')!==null,a=document.querySelector(Oo)!==null;if(!o&&!a&&r===void 0&&i===null){t?.();return}Wn?.(),!o&&!a&&(i??r)?.click();let l,c=!1,y=new MutationObserver(()=>{A()}),m=()=>{c||(c=!0,y.disconnect(),window.clearTimeout(f),l!==void 0&&window.cancelAnimationFrame(l),Wn===m&&(Wn=void 0))},T=()=>{let p=[...document.querySelectorAll('[role="dialog"] nav button'),...document.querySelectorAll(`${Oo} nav button`)],u=qr(p,e);return u===void 0?!1:(m(),u.click(),n?.(),!0)},A=()=>{c||l!==void 0||(l=window.requestAnimationFrame(()=>{l=void 0,T()}))},f=window.setTimeout(()=>{T()||(m(),t?.())},1500);y.observe(document.body,{childList:!0,subtree:!0}),Wn=m,A()}var D=dn(require("react"),1),gt=require("react-dom/client"),Oe=require("@deepseek-ai/dsh-client-ui-primitives");function Wo(e,n,t){return`dsh plugin${e.trim()===""?"":` --profile ${e.trim()}`} add ${n}@${t} --registry=https://registry.npmjs.org/`}function _o(e,n){return e.key!=="Escape"?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),n(),!0)}var Yr="x-michengai-plugin-update",Qr=`
|
|
164
178
|
.mpi-version{margin-left:8px;color:var(--dsw-alias-label-tertiary,#a0a0a0);font-family:inherit;font-size:12px;font-weight:500;line-height:18px;letter-spacing:0;white-space:nowrap;vertical-align:baseline}.mpi-check-host{display:inline-flex;align-items:center}.mpi-icon{display:inline-flex;flex:0 0 auto;width:16px;height:16px;align-items:center;justify-content:center;pointer-events:none}.mpi-icon svg{display:block;width:16px;height:16px}
|
|
165
179
|
.dsh-st-modal-action{min-width:72px}
|
|
166
180
|
.mpi-intro{margin:0 0 16px;color:var(--dsw-alias-label-secondary,#b9b9b9);font-size:13px;line-height:20px}.mpi-meta{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:8px 18px;margin:0 0 16px;font-size:12px;line-height:18px}.mpi-meta dt{color:var(--dsw-alias-label-secondary,#b9b9b9)}.mpi-meta dd{margin:0}.mpi-mono{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.mpi-latest{display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 10px}.mpi-status{font-size:13px;font-weight:600;line-height:18px}.mpi-status[data-kind=error]{color:var(--dsw-alias-state-error-primary,#ef7272)}.mpi-status[data-kind=success]{color:var(--dsw-alias-state-success-primary,#51b976)}.mpi-status[data-kind=update]{color:#e8b15a !important}.mpi-manual{border-top:0.5px solid var(--dsw-alias-border-l2,#494949);padding-top:16px}.mpi-manual h3{margin:0 0 6px;font-size:14px;line-height:20px}.mpi-manual p{margin:0 0 10px;color:var(--dsw-alias-label-secondary,#b9b9b9);font-size:12px;line-height:18px}.mpi-command{display:flex;align-items:flex-start;gap:8px;border:0.5px solid var(--dsw-alias-border-l2,#494949);border-radius:var(--dsw-radius-lg,16px);padding:10px;background:var(--dsw-alias-bg-layer-1,var(--dsw-alias-interactive-bg-hover,transparent))}.mpi-command code{min-width:0;flex:1;overflow:visible;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px;line-height:18px;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
@@ -169,6 +183,6 @@ var module = { exports: {} }; var exports = module.exports;
|
|
|
169
183
|
@keyframes dsh-st-progress-slide{0%{transform:translateX(-100%)}100%{transform:translateX(300%)}}
|
|
170
184
|
@media (prefers-reduced-motion:reduce){.dsh-st-update-progress-bar{animation:none;width:100%;opacity:.6}}
|
|
171
185
|
@media(max-width:560px){.mpi-meta{grid-template-columns:1fr;gap:2px}.mpi-meta dd{margin-bottom:6px}}
|
|
172
|
-
`,Yr={check:"\u68C0\u67E5\u66F4\u65B0",update:"\u66F4\u65B0",close:"\u5173\u95ED",recheck:"\u91CD\u65B0\u68C0\u67E5",auto:"\u81EA\u52A8\u66F4\u65B0",updating:"\u6B63\u5728\u66F4\u65B0\u2026",copy:"\u590D\u5236\u547D\u4EE4",copied:"\u5DF2\u590D\u5236",copyFailed:"\u590D\u5236\u5931\u8D25",checking:"\u6B63\u5728\u68C0\u67E5\u66F4\u65B0\u2026",latest:"\u5DF2\u662F\u6700\u65B0\u7248\u672C",found:"\u53D1\u73B0\u65B0\u7248\u672C",failed:"\u68C0\u67E5\u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",current:"\u8FD0\u884C\u7248\u672C",latestLabel:"\u6700\u65B0\u7248\u672C",profile:"\u76EE\u6807 profile",unknown:"\u672A\u77E5",manual:"\u624B\u5DE5\u66F4\u65B0",manualHint:"\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u65F6\uFF0C\u53EF\u5728\u5F53\u524D DSH \u7EC8\u7AEF\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\uFF0C\u5B8C\u6210\u540E\u91CD\u542F DSH Web\u3002",manualHintDesktop:"\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u65F6\uFF0C\u8BF7\u5148\u5B8C\u5168\u9000\u51FA DSH Desktop\uFF0C\u518D\u7528 Desktop \u81EA\u5E26\u7684 dsh \u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u3002\u666E\u901A dsh \u4F1A\u62D2\u7EDD desktop profile\u3002",intro:"\u4EC5\u68C0\u67E5\u5E76\u66F4\u65B0\u5F53\u524D\u63D2\u4EF6\uFF0C\u4E0D\u4F1A\u8054\u52A8\u5B89\u88C5\u5176\u4ED6\u63D2\u4EF6\u3002",restart:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u8BF7\u91CD\u542F DSH Web\u3002",restartDesktop:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u8BF7\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u65B0\u6253\u5F00 DSH Desktop\u3002",restarting:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u6B63\u5728\u91CD\u542F DSH Desktop\u2026",unavailable:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u81EA\u52A8\u66F4\u65B0\uFF0C\u8BF7\u4F7F\u7528\u624B\u5DE5\u66F4\u65B0\u547D\u4EE4\u3002"},Qr={check:"Check for updates",update:"Update",close:"Close",recheck:"Check again",auto:"Update automatically",updating:"Updating\u2026",copy:"Copy command",copied:"Copied",copyFailed:"Copy failed",checking:"Checking for updates\u2026",latest:"You are up to date",found:"New version available",failed:"Could not check for updates. Try again later.",current:"Running version",latestLabel:"Latest version",profile:"Target profile",unknown:"Unknown",manual:"Manual update",manualHint:"If automatic update fails, run this command in the current DSH terminal, then restart DSH Web.",manualHintDesktop:"If automatic update fails, fully quit DSH Desktop, then run this command with Desktop's own dsh. A regular dsh rejects the desktop profile.",intro:"Only this plugin is checked and updated. Other plugins are not changed.",restart:"Update complete. Restart DSH Web.",restartDesktop:"Update complete. Fully quit and reopen DSH Desktop.",restarting:"Update complete. Restarting DSH Desktop\u2026",unavailable:"Automatic update is unavailable. Use the manual command."};function Fn(e){return e.toLowerCase().startsWith("en")?Qr:Yr}function ei(e,n,t,s){let r=Fn(e),o=n?.profileName==="desktop"?{...r,manualHint:r.manualHintDesktop,restart:r.restartDesktop}:r,a=t!=="idle",l=o.checking,c="";return t==="checking"?l=o.checking:t==="updating"?l=o.updating:s.type==="error"?(l=s.message||o.failed,c="error"):s.type==="restart"?(l=o.restart,c="success"):s.type==="restarting"?(l=o.restarting,c="success"):n===void 0?l=o.checking:n.latestCheckFailed?(l=o.failed,c="error"):!n.canAutoUpdate&&n.updateAvailable?(l=o.unavailable,c="update"):n.updateAvailable?(l=`${o.found}: v${n.latestVersion??o.unknown}`,c="update"):(l=o.latest,c="success"),{copy:o,busy:a,message:l,kind:c,loading:t==="updating",updateLabel:t==="updating"?o.updating:o.auto,disabled:a||n?.canAutoUpdate!==!0||n.updateAvailable!==!0,currentVersion:n===void 0?o.unknown:`v${n.currentVersion}`,latestVersion:n?.latestVersion===void 0?o.unknown:`v${n.latestVersion}`,profileName:n?.profileName??o.unknown,profileRaw:n?.profileName??"",latestRaw:n?.latestVersion??"latest"}}function ni(e,n,t){let s="idle",r=n,i={type:"status"},o=new Set,a=()=>{for(let c of o)c()},l=c=>{r=c,t?.(c)};return{subscribe(c){return o.add(c),()=>{o.delete(c)}},view(c){return ei(c,r,s,i)},async check(){if(s==="idle"){s="checking",i={type:"status"},a();try{l(await e("GET")),i={type:"status"}}catch(c){i={type:"error",message:c instanceof Error?c.message:""}}finally{s="idle",a()}}},async update(){if(s==="idle"){s="updating",i={type:"status"},a();try{let c=await e("POST");l(c),i={type:c.autoReload===!0?"restarting":"restart"}}catch(c){i={type:"error",message:c instanceof Error?c.message:""}}finally{s="idle",a()}}}}}function ti(){Lo(Jr)}function si(e){if(e===null||typeof e!="object")return!1;let n=e;return typeof n.packageName=="string"&&typeof n.currentVersion=="string"&&typeof n.updateAvailable=="boolean"&&typeof n.profileName=="string"&&typeof n.canAutoUpdate=="boolean"&&typeof n.latestCheckFailed=="boolean"&&(n.latestVersion===void 0||typeof n.latestVersion=="string")}async function Wo(e,n,t){let s=t===void 0?{}:{signal:t},r=await fetch(e,n==="GET"?{cache:"no-store",...s}:{method:"POST",headers:{"content-type":"application/json",[Xr]:"1"},body:"{}",...s}),i=await r.json();if(!r.ok||!si(i))throw new Error(i!==null&&typeof i=="object"&&"error"in i&&typeof i.error=="string"?i.error:Fn(document.documentElement.lang).failed);return i}function oi(e){let n=D.default.useRef(null);return D.default.useLayoutEffect(()=>{n.current?.replaceChildren(e.node)},[e.node]),D.default.createElement("span",{ref:n,className:"mpi-icon","aria-hidden":!0})}function ri(e){let n=D.default.useRef(null),[,t]=D.default.useState(0),[s,r]=D.default.useState("idle");D.default.useEffect(()=>e.flow.subscribe(()=>t(g=>g+1)),[e.flow]),D.default.useEffect(()=>{let g=document.documentElement,m=new MutationObserver(()=>t(x=>x+1));return m.observe(g,{attributes:!0,attributeFilter:["lang"]}),()=>m.disconnect()},[]),D.default.useEffect(()=>{e.flow.check()},[e.flow]),D.default.useEffect(()=>{let g=m=>{Ho(m,e.onClose)};return document.addEventListener("keydown",g,!0),()=>document.removeEventListener("keydown",g,!0)},[e.onClose]);let i=document.documentElement.lang,o=e.flow.view(i),a=i.toLowerCase().startsWith("en")?e.enName:e.zhName,l=Fo(o.profileRaw,e.packageName,o.latestRaw),c=s==="copied"?o.copy.copied:s==="failed"?o.copy.copyFailed:o.copy.copy;return D.default.createElement(De.Modal,{open:!0,className:"dsh-st-update-dialog",title:`${a} ${o.copy.update}`,closeLabel:o.copy.close,onClose:e.onClose,footer:D.default.createElement(D.default.Fragment,null,D.default.createElement(De.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:o.busy,onClick:()=>{e.flow.check()}},o.copy.recheck),D.default.createElement(De.Button,{variant:"primary",className:"dsh-st-modal-action",disabled:o.disabled,onClick:()=>{e.flow.update()}},o.updateLabel))},D.default.createElement("div",{ref:n},D.default.createElement("p",{className:"mpi-intro"},o.copy.intro),D.default.createElement("dl",{className:"mpi-meta"},D.default.createElement("dt",null,o.copy.current),D.default.createElement("dd",null,D.default.createElement("span",{className:"mpi-mono"},o.currentVersion)),D.default.createElement("dt",null,o.copy.latestLabel),D.default.createElement("dd",{className:"mpi-latest"},D.default.createElement("span",{className:"mpi-mono"},o.latestVersion),D.default.createElement("span",{className:"mpi-status",role:"status","data-kind":o.kind,...o.kind==="update"?{style:{color:"#e8b15a"}}:{}},o.message)),D.default.createElement("dt",null,o.copy.profile),D.default.createElement("dd",null,D.default.createElement("span",{className:"mpi-mono"},o.profileName))),o.busy?D.default.createElement("div",{className:"dsh-st-update-progress",role:"progressbar","aria-busy":"true"},D.default.createElement("div",{className:"dsh-st-update-progress-bar"})):null,D.default.createElement("section",{className:"mpi-manual"},D.default.createElement("h3",null,o.copy.manual),D.default.createElement("p",null,o.copy.manualHint),D.default.createElement("div",{className:"mpi-command"},D.default.createElement("code",null,l),D.default.createElement(De.Button,{variant:"outline",size:"sm",disabled:o.busy,onClick:()=>{let g=navigator.clipboard?.writeText(l);if(g===void 0){r("failed");return}g.then(()=>{r("copied"),window.setTimeout(()=>r("idle"),1400)}).catch(()=>r("failed"))}},c)))))}function _o(e){if(typeof document>"u"||document.body===null)return()=>{};ti();let n=new AbortController,t,s,r,i,o,a,l,c=()=>{r?.unmount(),r=void 0,s=void 0,i=void 0},g=()=>{if(r===void 0)return;i===void 0&&(i=e.createIcon("refresh"));let u=i;r.render(D.default.createElement(De.Button,{variant:"outline",size:"sm",onClick:x,icon:D.default.createElement(oi,{node:u})},D.default.createElement("span",{"data-mpi-label":""},Fn(document.documentElement.lang).check)))},m=()=>{a?.unmount(),a=void 0,o?.remove(),o=void 0};function x(){m();let u=document.createElement("div");u.className="mpi-dialog-root",document.body.append(u),o=u;let y=(0,mt.createRoot)(u);a=y,y.render(D.default.createElement(ri,{flow:ni(h=>Wo(e.endpoint,h,n.signal),t,h=>{t=h,A()}),packageName:e.packageName,zhName:e.zhName,enName:e.enName,onClose:m}))}let A=()=>{let u=document.querySelector(e.titleRowSelector);if(u===null)return;let y=u.querySelector("h1,h2");if(y!==null&&t!==void 0){let M=y.querySelector(`.mpi-version[data-package="${e.packageName}"]`);M===null&&(M=document.createElement("span"),M.className="mpi-version",M.dataset.package=e.packageName,y.append(M));let _=`v${t.currentVersion}`;M.textContent!==_&&(M.textContent=_)}s!==void 0&&!s.isConnected&&c();let h=u.querySelector(e.linksSelector);if(h===null)return;let S=h.querySelector(`[data-mpi-check="${e.packageName}"]`);if(S!==null){let M=S.querySelector("[data-mpi-label]");(M===null||M.textContent!==Fn(document.documentElement.lang).check)&&g();return}let N=document.createElement("span");N.dataset.mpiCheck=e.packageName,N.className="mpi-check-host",h.append(N),s=N,r=(0,mt.createRoot)(N),g()},f=async()=>(t=await Wo(e.endpoint,"GET",n.signal),A(),t),p=new MutationObserver(()=>{l===void 0&&(l=window.requestAnimationFrame(()=>{l=void 0,A()}))});return p.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["lang"]}),A(),f().catch(()=>{}),()=>{n.abort(),p.disconnect(),m(),c(),l!==void 0&&window.cancelAnimationFrame(l),document.querySelectorAll(`[data-mpi-check="${e.packageName}"],.mpi-version[data-package="${e.packageName}"]`).forEach(u=>u.remove())}}var ii="dsh-automation-client",ai=["slots","locale","connection","sessions"],di={refresh:["M13.5 5.5V2.5m0 0h-3m3 0-2.1 2.1A5.5 5.5 0 1 0 13.2 12"],download:["M8 2v8m0 0 3-3m-3 3-3-3M3 13v2h10v-2"],copy:["M5 5h8v8H5z","M3 3h8"],close:["m4 4 8 8M12 4 4 12"]};function li(e){let n=document.createElement("span"),t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 16 16"),t.setAttribute("width","16"),t.setAttribute("height","16"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.5"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");for(let s of di[e]){let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",s),t.append(r)}return n.append(t),n}var ci='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-dsh-schedule-icon="1"><path d="M8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14Z"/><path d="M8 4.667V8l2.333 2.333"/></svg>';function ui(e){return typeof e=="function"}function pi(e){return typeof e=="function"}function mi(e){let n=new Set(e().map(i=>i.trim()).filter(i=>i!=="")),t=i=>{let o=(i.textContent??"").replace(/\s+/g," ").trim();if(!n.has(o))return;let a=i.querySelector("svg");a===null||a.getAttribute("data-dsh-schedule-icon")==="1"||(a.outerHTML=ci)},s=i=>{i instanceof HTMLButtonElement&&t(i);for(let o of i.querySelectorAll?.("button")??[])t(o)};s(document);let r=new MutationObserver(i=>{for(let o of i){let l=(o.target instanceof Element?o.target:o.target.parentElement)?.closest("button");l instanceof HTMLButtonElement&&t(l);for(let c of o.addedNodes)c instanceof Element&&s(c)}});return r.observe(document.documentElement,{childList:!0,characterData:!0,subtree:!0}),()=>{r.disconnect()}}function fi(e){e.effect(()=>Mo(),"dsh-automation: styles"),e.effect(()=>e.locale.register(Be,{zh:Js,en:Xs}),"dsh-automation: locale"),e.effect(()=>_o({endpoint:"/api/michengai/dsh-automation/update",packageName:"@michengai/dsh-automation",titleRowSelector:".dsh-st-heading-row",linksSelector:".dsh-st-heading-links",zhName:"\u5B9A\u65F6\u4EFB\u52A1",enName:"Scheduled tasks",createIcon:li}),"dsh-automation: plugin update ui");let n=e.locale.bind(Be),t=e.locale.bind("permission.access"),s=e.locale.bind("model"),r=$s(e.connection.rpc),i=async()=>{let a=await Vn(e);return a===void 0?void 0:(await $n(e,a),(await r.registerWorkspace(a)).id)},o=a=>{at(a),Do([n("tab"),"Scheduled tasks","\u5B9A\u65F6\u4EFB\u52A1"],()=>{at(a)})};e.effect(()=>Bs(r,()=>e.sessions),"dsh-automation: session sync"),e.effect(()=>mi(()=>[n("tab"),"Scheduled tasks","\u5B9A\u65F6\u4EFB\u52A1"]),"dsh-automation: settings icon"),e.slots.inject("settings.section",()=>e.slots.register({name:"settings.section",id:"scheduled-tasks",order:35,locale:Be,label:()=>n("tab"),icon:"schedule",inject:()=>({createWorkspace:a=>$n(e,a.path),pickDirectory:()=>Vn(e),permissionT:t,modelT:s})},function(l){return(0,Fe.createElement)(Zs,{t:n,permissionT:t,modelT:s,runtime:r,...l.close===void 0?{}:{closeSettings:l.close},addWorkspace:i})})),e.slots.inject("sidebar.schedule",()=>e.slots.register({name:"sidebar.schedule",id:"dsh-automation-schedule",order:10,locale:Be,label:()=>n("sidebar.tab")},function(l){return(0,Fe.createElement)(Io,{t:n,runtime:r,openSession:ft(e,r,l.openSession),openTaskSettings:o,...l.view===void 0?{}:{view:l.view},...l.showViewSwitch===void 0?{}:{showViewSwitch:l.showViewSwitch}})})),e.slots.inject("sidebar.workspaces",()=>{let a,l,c,g,m,x=()=>{},A=!1,f,p=()=>{queueMicrotask(()=>window.dispatchEvent(new Event("dsh-native-sidebar-change")))},u=z=>e.slots.subscribe?.("sidebar.channels",z)??(()=>{}),y=()=>{f!==void 0&&(window.clearInterval(f),f=void 0)},h=()=>{if(y(),x(),x=()=>{},m=void 0,a!==void 0){l!==void 0&&a.component===c&&(a.component=l);let z=a;z.__dshNativeTabs===g&&delete z.__dshNativeTabs,p()}a=void 0,l=void 0,c=void 0,g=void 0},S=(z,Q)=>{let V=eo(z);return V===void 0?!1:(m!==V&&(x(),x=()=>{},m=V),V.getTabs().some(F=>F.id==="schedule")||(x=V.insert({id:"schedule",label:n("sidebar.tab"),order:30,matchSession:F=>F.startsWith(We),render:F=>{let G=typeof F.openSession=="function"?F.openSession:typeof F.open=="function"?F.open:Q,W=ft(e,r,G);return(0,Fe.createElement)(Pn,{t:n,runtime:r,openSession:W,...ui(F.useSessions)?{useSessions:F.useSessions}:{},...pi(F.useWorkspaces)?{useWorkspaces:F.useWorkspaces}:{},...typeof F.renderSlot=="function"?{renderSlot:F.renderSlot}:{},...typeof F.useSessionStatus=="function"?{useSessionStatus:F.useSessionStatus}:{},...Nn(F),openTaskSettings:o})}})),!0)},N=()=>{let z=Hn(e,"sidebar.workspaces");for(let Q of z){let V=Q;if(S(Q)||S(V.component))return!0}return!1},M=()=>{if(N()){y();return}if(f!==void 0)return;let z=0;f=window.setInterval(()=>{z+=1,(N()||z>=20)&&y()},250)},_=()=>{if(!A){A=!0;try{let ce=function(H){let L=ft(e,r,H.openSession??H.open);return(0,Fe.createElement)(Co,{t:n,runtime:r,hostProps:H,openSession:L,openTaskSettings:o,tabRegistry:ee,...H.wide===void 0?{}:{wide:H.wide},hasChannels:()=>gi(e,"sidebar.channels"),subscribeChannels:u,...H.useSessions===void 0?{}:{useSessions:H.useSessions},...H.useWorkspaces===void 0?{}:{useWorkspaces:H.useWorkspaces},...H.renderSlot===void 0?{}:{renderSlot:H.renderSlot},officialTree:R})};var z=ce;if(Jt(Hn(e,"sidebar"))){h();return}let Q=Hn(e,"sidebar.workspaces"),V=Q.find(H=>H?.component!==void 0);if(a!==void 0&&(V!==a||V.component!==c)&&h(),V===a&&V?.component===c&&c!==void 0){M();return}if(V===void 0){h();return}let F=as(Q),G=F?.component;if(G!==void 0&&no(G)){M();return}if(F?.component===void 0)return;let W=is(F.component);if(W===void 0)return;l=W;let ee=Qs(l);g=ee,lt(F,ee);let I=ce;I.displayName="AutomationNativeWorkspaceShell",I.__dshNativeTabHost=!0,I.__dshAutomationWrapped=!0,I.__dshAutomationOriginal=l;let R=l;lt(I,ee),F.component=I,c=I,a=F,M(),p()}catch(Q){console.warn("[dsh-automation] \u5305\u88F9\u5B98\u65B9\u4EFB\u52A1\u6811\u5931\u8D25",Q)}finally{A=!1}}};_();let se=typeof e.slots.subscribe=="function"?e.slots.subscribe("sidebar.workspaces",_):()=>{},re=e.slots.subscribe?.("sidebar",_)??(()=>{});return window.addEventListener("dsh-native-sidebar-change",_),M(),()=>{se(),re(),window.removeEventListener("dsh-native-sidebar-change",_),h()}}),e.slots.inject("conversation.input.left",()=>e.slots.register({name:"conversation.input.left",id:"dsh-automation-prefill",order:80,locale:Be},hi))}function ft(e,n,t){return s=>{let r=es(e);ss({id:s,adopt:i=>n.adoptSession(i),listed:i=>{let o=e.sessions?.list?.getSnapshot();return(o?.ids??[]).includes(i)||o?.byId?.[i]!==void 0},...e.sessions?.refresh===void 0?{}:{refresh:()=>e.sessions.refresh()},...ns(r)?{openRuntime:i=>{ts(r,i)}}:{},...t===void 0?{}:{openHost:t}})}}function hi(e){return(0,Fe.useEffect)(()=>{let n=t=>{if(!(t===null||t==="")){if(e.inputActions!==void 0){e.inputActions.setDraft(t),nt();return}_s(t)&&nt()}};return n(Hs()),Ws(n)},[e.inputActions]),null}function Hn(e,n){try{return(e.slots.entriesOfSlot??e.slots.entries)?.call(e.slots,n)??[]}catch{return[]}}function gi(e,n){return Hn(e,n).length>0}
|
|
186
|
+
`,ei={check:"\u68C0\u67E5\u66F4\u65B0",update:"\u66F4\u65B0",close:"\u5173\u95ED",recheck:"\u91CD\u65B0\u68C0\u67E5",auto:"\u81EA\u52A8\u66F4\u65B0",updating:"\u6B63\u5728\u66F4\u65B0\u2026",copy:"\u590D\u5236\u547D\u4EE4",copied:"\u5DF2\u590D\u5236",copyFailed:"\u590D\u5236\u5931\u8D25",checking:"\u6B63\u5728\u68C0\u67E5\u66F4\u65B0\u2026",latest:"\u5DF2\u662F\u6700\u65B0\u7248\u672C",found:"\u53D1\u73B0\u65B0\u7248\u672C",failed:"\u68C0\u67E5\u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",current:"\u8FD0\u884C\u7248\u672C",latestLabel:"\u6700\u65B0\u7248\u672C",profile:"\u76EE\u6807 profile",unknown:"\u672A\u77E5",manual:"\u624B\u5DE5\u66F4\u65B0",manualHint:"\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u65F6\uFF0C\u53EF\u5728\u5F53\u524D DSH \u7EC8\u7AEF\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\uFF0C\u5B8C\u6210\u540E\u91CD\u542F DSH Web\u3002",manualHintDesktop:"\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u65F6\uFF0C\u8BF7\u5148\u5B8C\u5168\u9000\u51FA DSH Desktop\uFF0C\u518D\u7528 Desktop \u81EA\u5E26\u7684 dsh \u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u3002\u666E\u901A dsh \u4F1A\u62D2\u7EDD desktop profile\u3002",intro:"\u4EC5\u68C0\u67E5\u5E76\u66F4\u65B0\u5F53\u524D\u63D2\u4EF6\uFF0C\u4E0D\u4F1A\u8054\u52A8\u5B89\u88C5\u5176\u4ED6\u63D2\u4EF6\u3002",restart:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u8BF7\u91CD\u542F DSH Web\u3002",restartDesktop:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u8BF7\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u65B0\u6253\u5F00 DSH Desktop\u3002",restarting:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u6B63\u5728\u91CD\u542F DSH Desktop\u2026",unavailable:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u81EA\u52A8\u66F4\u65B0\uFF0C\u8BF7\u4F7F\u7528\u624B\u5DE5\u66F4\u65B0\u547D\u4EE4\u3002"},ni={check:"Check for updates",update:"Update",close:"Close",recheck:"Check again",auto:"Update automatically",updating:"Updating\u2026",copy:"Copy command",copied:"Copied",copyFailed:"Copy failed",checking:"Checking for updates\u2026",latest:"You are up to date",found:"New version available",failed:"Could not check for updates. Try again later.",current:"Running version",latestLabel:"Latest version",profile:"Target profile",unknown:"Unknown",manual:"Manual update",manualHint:"If automatic update fails, run this command in the current DSH terminal, then restart DSH Web.",manualHintDesktop:"If automatic update fails, fully quit DSH Desktop, then run this command with Desktop's own dsh. A regular dsh rejects the desktop profile.",intro:"Only this plugin is checked and updated. Other plugins are not changed.",restart:"Update complete. Restart DSH Web.",restartDesktop:"Update complete. Fully quit and reopen DSH Desktop.",restarting:"Update complete. Restarting DSH Desktop\u2026",unavailable:"Automatic update is unavailable. Use the manual command."};function _n(e){return e.toLowerCase().startsWith("en")?ni:ei}function ti(e,n,t,s){let r=_n(e),o=n?.profileName==="desktop"?{...r,manualHint:r.manualHintDesktop,restart:r.restartDesktop}:r,a=t!=="idle",l=o.checking,c="";return t==="checking"?l=o.checking:t==="updating"?l=o.updating:s.type==="error"?(l=s.message||o.failed,c="error"):s.type==="restart"?(l=o.restart,c="success"):s.type==="restarting"?(l=o.restarting,c="success"):n===void 0?l=o.checking:n.latestCheckFailed?(l=o.failed,c="error"):!n.canAutoUpdate&&n.updateAvailable?(l=o.unavailable,c="update"):n.updateAvailable?(l=`${o.found}: v${n.latestVersion??o.unknown}`,c="update"):(l=o.latest,c="success"),{copy:o,busy:a,message:l,kind:c,loading:t==="updating",updateLabel:t==="updating"?o.updating:o.auto,disabled:a||n?.canAutoUpdate!==!0||n.updateAvailable!==!0,currentVersion:n===void 0?o.unknown:`v${n.currentVersion}`,latestVersion:n?.latestVersion===void 0?o.unknown:`v${n.latestVersion}`,profileName:n?.profileName??o.unknown,profileRaw:n?.profileName??"",latestRaw:n?.latestVersion??"latest"}}function si(e,n,t){let s="idle",r=n,i={type:"status"},o=new Set,a=()=>{for(let c of o)c()},l=c=>{r=c,t?.(c)};return{subscribe(c){return o.add(c),()=>{o.delete(c)}},view(c){return ti(c,r,s,i)},async check(){if(s==="idle"){s="checking",i={type:"status"},a();try{l(await e("GET")),i={type:"status"}}catch(c){i={type:"error",message:c instanceof Error?c.message:""}}finally{s="idle",a()}}},async update(){if(s==="idle"){s="updating",i={type:"status"},a();try{let c=await e("POST");l(c),i={type:c.autoReload===!0?"restarting":"restart"}}catch(c){i={type:"error",message:c instanceof Error?c.message:""}}finally{s="idle",a()}}}}}function oi(){Do(Qr)}function ri(e){if(e===null||typeof e!="object")return!1;let n=e;return typeof n.packageName=="string"&&typeof n.currentVersion=="string"&&typeof n.updateAvailable=="boolean"&&typeof n.profileName=="string"&&typeof n.canAutoUpdate=="boolean"&&typeof n.latestCheckFailed=="boolean"&&(n.latestVersion===void 0||typeof n.latestVersion=="string")}async function zo(e,n,t){let s=t===void 0?{}:{signal:t},r=await fetch(e,n==="GET"?{cache:"no-store",...s}:{method:"POST",headers:{"content-type":"application/json",[Yr]:"1"},body:"{}",...s}),i=await r.json();if(!r.ok||!ri(i))throw new Error(i!==null&&typeof i=="object"&&"error"in i&&typeof i.error=="string"?i.error:_n(document.documentElement.lang).failed);return i}function ii(e){let n=D.default.useRef(null);return D.default.useLayoutEffect(()=>{n.current?.replaceChildren(e.node)},[e.node]),D.default.createElement("span",{ref:n,className:"mpi-icon","aria-hidden":!0})}function ai(e){let n=D.default.useRef(null),[,t]=D.default.useState(0),[s,r]=D.default.useState("idle");D.default.useEffect(()=>e.flow.subscribe(()=>t(y=>y+1)),[e.flow]),D.default.useEffect(()=>{let y=document.documentElement,m=new MutationObserver(()=>t(T=>T+1));return m.observe(y,{attributes:!0,attributeFilter:["lang"]}),()=>m.disconnect()},[]),D.default.useEffect(()=>{e.flow.check()},[e.flow]),D.default.useEffect(()=>{let y=m=>{_o(m,e.onClose)};return document.addEventListener("keydown",y,!0),()=>document.removeEventListener("keydown",y,!0)},[e.onClose]);let i=document.documentElement.lang,o=e.flow.view(i),a=i.toLowerCase().startsWith("en")?e.enName:e.zhName,l=Wo(o.profileRaw,e.packageName,o.latestRaw),c=s==="copied"?o.copy.copied:s==="failed"?o.copy.copyFailed:o.copy.copy;return D.default.createElement(Oe.Modal,{open:!0,className:"dsh-st-update-dialog",title:`${a} ${o.copy.update}`,closeLabel:o.copy.close,onClose:e.onClose,footer:D.default.createElement(D.default.Fragment,null,D.default.createElement(Oe.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:o.busy,onClick:()=>{e.flow.check()}},o.copy.recheck),D.default.createElement(Oe.Button,{variant:"primary",className:"dsh-st-modal-action",disabled:o.disabled,onClick:()=>{e.flow.update()}},o.updateLabel))},D.default.createElement("div",{ref:n},D.default.createElement("p",{className:"mpi-intro"},o.copy.intro),D.default.createElement("dl",{className:"mpi-meta"},D.default.createElement("dt",null,o.copy.current),D.default.createElement("dd",null,D.default.createElement("span",{className:"mpi-mono"},o.currentVersion)),D.default.createElement("dt",null,o.copy.latestLabel),D.default.createElement("dd",{className:"mpi-latest"},D.default.createElement("span",{className:"mpi-mono"},o.latestVersion),D.default.createElement("span",{className:"mpi-status",role:"status","data-kind":o.kind,...o.kind==="update"?{style:{color:"#e8b15a"}}:{}},o.message)),D.default.createElement("dt",null,o.copy.profile),D.default.createElement("dd",null,D.default.createElement("span",{className:"mpi-mono"},o.profileName))),o.busy?D.default.createElement("div",{className:"dsh-st-update-progress",role:"progressbar","aria-busy":"true"},D.default.createElement("div",{className:"dsh-st-update-progress-bar"})):null,D.default.createElement("section",{className:"mpi-manual"},D.default.createElement("h3",null,o.copy.manual),D.default.createElement("p",null,o.copy.manualHint),D.default.createElement("div",{className:"mpi-command"},D.default.createElement("code",null,l),D.default.createElement(Oe.Button,{variant:"outline",size:"sm",disabled:o.busy,onClick:()=>{let y=navigator.clipboard?.writeText(l);if(y===void 0){r("failed");return}y.then(()=>{r("copied"),window.setTimeout(()=>r("idle"),1400)}).catch(()=>r("failed"))}},c)))))}function Go(e){if(typeof document>"u"||document.body===null)return()=>{};oi();let n=new AbortController,t,s,r,i,o,a,l,c=()=>{r?.unmount(),r=void 0,s=void 0,i=void 0},y=()=>{if(r===void 0)return;i===void 0&&(i=e.createIcon("refresh"));let u=i;r.render(D.default.createElement(Oe.Button,{variant:"outline",size:"sm",onClick:T,icon:D.default.createElement(ii,{node:u})},D.default.createElement("span",{"data-mpi-label":""},_n(document.documentElement.lang).check)))},m=()=>{a?.unmount(),a=void 0,o?.remove(),o=void 0};function T(){m();let u=document.createElement("div");u.className="mpi-dialog-root",document.body.append(u),o=u;let g=(0,gt.createRoot)(u);a=g,g.render(D.default.createElement(ai,{flow:si(h=>zo(e.endpoint,h,n.signal),t,h=>{t=h,A()}),packageName:e.packageName,zhName:e.zhName,enName:e.enName,onClose:m}))}let A=()=>{let u=document.querySelector(e.titleRowSelector);if(u===null)return;let g=u.querySelector("h1,h2");if(g!==null&&t!==void 0){let L=g.querySelector(`.mpi-version[data-package="${e.packageName}"]`);L===null&&(L=document.createElement("span"),L.className="mpi-version",L.dataset.package=e.packageName,g.append(L));let H=`v${t.currentVersion}`;L.textContent!==H&&(L.textContent=H)}s!==void 0&&!s.isConnected&&c();let h=u.querySelector(e.linksSelector);if(h===null)return;let S=h.querySelector(`[data-mpi-check="${e.packageName}"]`);if(S!==null){let L=S.querySelector("[data-mpi-label]");(L===null||L.textContent!==_n(document.documentElement.lang).check)&&y();return}let R=document.createElement("span");R.dataset.mpiCheck=e.packageName,R.className="mpi-check-host",h.append(R),s=R,r=(0,gt.createRoot)(R),y()},f=async()=>(t=await zo(e.endpoint,"GET",n.signal),A(),t),p=new MutationObserver(()=>{l===void 0&&(l=window.requestAnimationFrame(()=>{l=void 0,A()}))});return p.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["lang"]}),A(),f().catch(()=>{}),()=>{n.abort(),p.disconnect(),m(),c(),l!==void 0&&window.cancelAnimationFrame(l),document.querySelectorAll(`[data-mpi-check="${e.packageName}"],.mpi-version[data-package="${e.packageName}"]`).forEach(u=>u.remove())}}var di="dsh-automation-client",li=["slots","locale","connection","sessions"],ci={refresh:["M13.5 5.5V2.5m0 0h-3m3 0-2.1 2.1A5.5 5.5 0 1 0 13.2 12"],download:["M8 2v8m0 0 3-3m-3 3-3-3M3 13v2h10v-2"],copy:["M5 5h8v8H5z","M3 3h8"],close:["m4 4 8 8M12 4 4 12"]};function ui(e){let n=document.createElement("span"),t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 16 16"),t.setAttribute("width","16"),t.setAttribute("height","16"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.5"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");for(let s of ci[e]){let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",s),t.append(r)}return n.append(t),n}var pi='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-dsh-schedule-icon="1"><path d="M8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14Z"/><path d="M8 4.667V8l2.333 2.333"/></svg>';function mi(e){return typeof e=="function"}function fi(e){return typeof e=="function"}function hi(e){let n=new Set(e().map(i=>i.trim()).filter(i=>i!=="")),t=i=>{let o=(i.textContent??"").replace(/\s+/g," ").trim();if(!n.has(o))return;let a=i.querySelector("svg");a===null||a.getAttribute("data-dsh-schedule-icon")==="1"||(a.outerHTML=pi)},s=i=>{i instanceof HTMLButtonElement&&t(i);for(let o of i.querySelectorAll?.("button")??[])t(o)};s(document);let r=new MutationObserver(i=>{for(let o of i){let l=(o.target instanceof Element?o.target:o.target.parentElement)?.closest("button");l instanceof HTMLButtonElement&&t(l);for(let c of o.addedNodes)c instanceof Element&&s(c)}});return r.observe(document.documentElement,{childList:!0,characterData:!0,subtree:!0}),()=>{r.disconnect()}}function gi(e){e.effect(()=>Po(),"dsh-automation: styles"),e.effect(()=>e.locale.register(Be,{zh:eo,en:Qs}),"dsh-automation: locale"),e.effect(()=>Go({endpoint:"/api/michengai/dsh-automation/update",packageName:"@michengai/dsh-automation",titleRowSelector:".dsh-st-heading-row",linksSelector:".dsh-st-heading-links",zhName:"\u5B9A\u65F6\u4EFB\u52A1",enName:"Scheduled tasks",createIcon:ui}),"dsh-automation: plugin update ui");let n=e.locale.bind(Be),t=e.locale.bind("permission.access"),s=e.locale.bind("model"),r=js(e.connection.rpc),i=async()=>{let a=await qn(e);return a===void 0?void 0:(await jn(e,a),(await r.registerWorkspace(a)).id)},o=a=>{ct(a),Fo([n("tab"),"Scheduled tasks","\u5B9A\u65F6\u4EFB\u52A1"],()=>{ct(a)})};e.effect(()=>Ks(r,()=>e.sessions),"dsh-automation: session sync"),e.effect(()=>hi(()=>[n("tab"),"Scheduled tasks","\u5B9A\u65F6\u4EFB\u52A1"]),"dsh-automation: settings icon"),e.slots.inject("settings.section",()=>e.slots.register({name:"settings.section",id:"scheduled-tasks",order:35,locale:Be,label:()=>n("tab"),icon:"schedule",inject:()=>({createWorkspace:a=>jn(e,a.path),pickDirectory:()=>qn(e),permissionT:t,modelT:s})},function(l){return(0,He.createElement)(Ys,{t:n,permissionT:t,modelT:s,runtime:r,...l.close===void 0?{}:{closeSettings:l.close},addWorkspace:i})})),e.slots.inject("sidebar.schedule",()=>e.slots.register({name:"sidebar.schedule",id:"dsh-automation-schedule",order:10,locale:Be,label:()=>n("sidebar.tab")},function(l){return(0,He.createElement)(No,{t:n,runtime:r,openSession:yt(e,r,l.openSession),openTaskSettings:o,...l.view===void 0?{}:{view:l.view},...l.showViewSwitch===void 0?{}:{showViewSwitch:l.showViewSwitch}})})),e.slots.inject("sidebar.workspaces",()=>{let a,l,c,y,m,T=()=>{},A=!1,f,p=()=>{queueMicrotask(()=>window.dispatchEvent(new Event("dsh-native-sidebar-change")))},u=W=>e.slots.subscribe?.("sidebar.channels",W)??(()=>{}),g=()=>{f!==void 0&&(window.clearInterval(f),f=void 0)},h=()=>{if(g(),T(),T=()=>{},m=void 0,a!==void 0){l!==void 0&&a.component===c&&(a.component=l);let W=a;W.__dshNativeTabs===y&&delete W.__dshNativeTabs,p()}a=void 0,l=void 0,c=void 0,y=void 0},S=(W,se)=>{let K=so(W);return K===void 0?!1:(m!==K&&(T(),T=()=>{},m=K),K.getTabs().some(O=>O.id==="schedule")||(T=K.insert({id:"schedule",label:n("sidebar.tab"),order:30,matchSession:O=>O.startsWith(We),render:O=>{let z=typeof O.openSession=="function"?O.openSession:typeof O.open=="function"?O.open:se,_=yt(e,r,z);return(0,He.createElement)(On,{t:n,runtime:r,openSession:_,...mi(O.useSessions)?{useSessions:O.useSessions}:{},...fi(O.useWorkspaces)?{useWorkspaces:O.useWorkspaces}:{},...typeof O.renderSlot=="function"?{renderSlot:O.renderSlot}:{},...typeof O.useSessionStatus=="function"?{useSessionStatus:O.useSessionStatus}:{},...En(O),openTaskSettings:o})}})),!0)},R=()=>{let W=zn(e,"sidebar.workspaces");for(let se of W){let K=se;if(S(se)||S(K.component))return!0}return!1},L=()=>{if(R()){g();return}if(f!==void 0)return;let W=0;f=window.setInterval(()=>{W+=1,(R()||W>=20)&&g()},250)},H=()=>{if(!A){A=!0;try{let pe=function(G){let x=yt(e,r,G.openSession??G.open);return(0,He.createElement)(Ro,{t:n,runtime:r,hostProps:G,openSession:x,openTaskSettings:o,tabRegistry:oe,...G.wide===void 0?{}:{wide:G.wide},hasChannels:()=>vi(e,"sidebar.channels"),subscribeChannels:u,...G.useSessions===void 0?{}:{useSessions:G.useSessions},...G.useWorkspaces===void 0?{}:{useWorkspaces:G.useWorkspaces},...G.renderSlot===void 0?{}:{renderSlot:G.renderSlot},officialTree:M})};var W=pe;if(es(zn(e,"sidebar"))){h();return}let se=zn(e,"sidebar.workspaces"),K=se.find(G=>G?.component!==void 0);if(a!==void 0&&(K!==a||K.component!==c)&&h(),K===a&&K?.component===c&&c!==void 0){L();return}if(K===void 0){h();return}let O=cs(se),z=O?.component;if(z!==void 0&&oo(z)){L();return}if(O?.component===void 0)return;let _=ls(O.component);if(_===void 0)return;l=_;let oe=to(l);y=oe,pt(O,oe);let U=pe;U.displayName="AutomationNativeWorkspaceShell",U.__dshNativeTabHost=!0,U.__dshAutomationWrapped=!0,U.__dshAutomationOriginal=l;let M=l;pt(U,oe),O.component=U,c=U,a=O,L(),p()}catch(se){console.warn("[dsh-automation] \u5305\u88F9\u5B98\u65B9\u4EFB\u52A1\u6811\u5931\u8D25",se)}finally{A=!1}}};H();let ae=typeof e.slots.subscribe=="function"?e.slots.subscribe("sidebar.workspaces",H):()=>{},de=e.slots.subscribe?.("sidebar",H)??(()=>{});return window.addEventListener("dsh-native-sidebar-change",H),L(),()=>{ae(),de(),window.removeEventListener("dsh-native-sidebar-change",H),h()}}),e.slots.inject("conversation.input.left",()=>e.slots.register({name:"conversation.input.left",id:"dsh-automation-prefill",order:80,locale:Be},yi))}function yt(e,n,t){return s=>{let r=ss(e);is({id:s,adopt:i=>n.adoptSession(i),listed:i=>{let o=e.sessions?.list?.getSnapshot();return(o?.ids??[]).includes(i)||o?.byId?.[i]!==void 0},...e.sessions?.refresh===void 0?{}:{refresh:()=>e.sessions.refresh()},...os(r)?{openRuntime:i=>{rs(r,i)}}:{},...t===void 0?{}:{openHost:t}})}}function yi(e){return(0,He.useEffect)(()=>{let n=t=>{if(!(t===null||t==="")){if(e.inputActions!==void 0){e.inputActions.setDraft(t),ot();return}Vs(t)&&ot()}};return n(zs()),Gs(n)},[e.inputActions]),null}function zn(e,n){try{return(e.slots.entriesOfSlot??e.slots.entries)?.call(e.slots,n)??[]}catch{return[]}}function vi(e,n){return zn(e,n).length>0}
|
|
173
187
|
return module.exports; } });
|
|
174
188
|
//# sourceMappingURL=client.js.map
|