tide-commander 1.76.0 → 1.76.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-BSAIyY5Q.js → BossLogsModal-B41BvcEF.js} +1 -1
- package/dist/assets/{BossSpawnModal-DWG3vywZ.js → BossSpawnModal-DUTcju8I.js} +1 -1
- package/dist/assets/{ControlsModal-D7sQMy9U.js → ControlsModal-DbiIdKPt.js} +1 -1
- package/dist/assets/{DockerLogsModal-BxebN9cf.js → DockerLogsModal-5mrsMmlQ.js} +1 -1
- package/dist/assets/{EmbeddedEditor-BJ7l5Zuf.js → EmbeddedEditor-DirMT3E8.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-CzdqIXK3.js → GmailOAuthSetup-CmGKGxui.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-DKjU--mc.js → GoogleOAuthSetup-CbWwCAK0.js} +1 -1
- package/dist/assets/{IframeModal-DkK8asfI.js → IframeModal-Dboa4JXN.js} +1 -1
- package/dist/assets/{IntegrationsPanel--yZ_3y5S.js → IntegrationsPanel-DS28YNJo.js} +2 -2
- package/dist/assets/{LogViewerModal-CxAnXG6j.js → LogViewerModal-UbrMLs2v.js} +1 -1
- package/dist/assets/{MonitoringModal-B2AaGtlF.js → MonitoringModal-B_XI1vTS.js} +1 -1
- package/dist/assets/{PM2LogsModal-auR8lVnW.js → PM2LogsModal-ChvPf5Uv.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-BJn-apo4.js → RestoreArchivedAreaModal-CEq_4zoQ.js} +1 -1
- package/dist/assets/{Scene2DCanvas-Q-FykJjz.js → Scene2DCanvas-DYDA_fv5.js} +1 -1
- package/dist/assets/{SceneManager-JpuslnCc.js → SceneManager-Be_I2Z9r.js} +1 -1
- package/dist/assets/{SkillsPanel-BYfp0jLH.js → SkillsPanel-CNIkJScD.js} +1 -1
- package/dist/assets/{SpawnModal-_wxlHhYk.js → SpawnModal-BXV32TQn.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-tvfKFyRh.js → SubordinateAssignmentModal-DK3uJtBR.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-DRKDuQAM.js → TriggerManagerPanel-C8JheOOO.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-BPBBCTem.js → WorkflowEditorPanel-DeLnt3ou.js} +1 -1
- package/dist/assets/{index-bu2bf20Y.js → index-B7BnOlMV.js} +2 -2
- package/dist/assets/index-BR3DNqtn.js +5 -0
- package/dist/assets/{index-DIDFZjvm.js → index-BZFjiZW2.js} +1 -1
- package/dist/assets/{index-CNo8F4Hv.js → index-C-HNvKyN.js} +1 -1
- package/dist/assets/{index-W693QVuI.js → index-C2QVwmIa.js} +1 -1
- package/dist/assets/{index-B87wqtN7.js → index-CymWdB1l.js} +1 -1
- package/dist/assets/{index-C8wnSaGW.js → index-D6ez6g4v.js} +1 -1
- package/dist/assets/{index-CPEajh-P.js → index-DHlpIGVI.js} +1 -1
- package/dist/assets/{index-snzCcqn6.js → index-DXjESpea.js} +3 -3
- package/dist/assets/{main-CjPuuFGh.js → main-BvvvhWnd.js} +6 -6
- package/dist/assets/{web-CY6mLlQ5.js → web-B-5bt6Uj.js} +1 -1
- package/dist/assets/{web-Bd3T_lvT.js → web-Dyi_JNTJ.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/src/packages/server/services/runtime-command-execution.js +9 -0
- package/package.json +1 -1
- package/dist/assets/index-DybFI3Yz.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c5 as s}from"./main-
|
|
1
|
+
import{c5 as s}from"./main-BvvvhWnd.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class l extends s{constructor(){super(...arguments),this.pending=[],this.deliveredNotifications=[],this.hasNotificationSupport=()=>{if(!("Notification"in window)||!Notification.requestPermission)return!1;if(Notification.permission!=="granted")try{new Notification("")}catch(i){if(i instanceof Error&&i.name==="TypeError")return!1}return!0}}async getDeliveredNotifications(){const i=[];for(const t of this.deliveredNotifications){const e={title:t.title,id:parseInt(t.tag),body:t.body};i.push(e)}return{notifications:i}}async removeDeliveredNotifications(i){for(const t of i.notifications){const e=this.deliveredNotifications.find(n=>n.tag===String(t.id));e==null||e.close(),this.deliveredNotifications=this.deliveredNotifications.filter(()=>!e)}}async removeAllDeliveredNotifications(){for(const i of this.deliveredNotifications)i.close();this.deliveredNotifications=[]}async createChannel(){throw this.unimplemented("Not implemented on web.")}async deleteChannel(){throw this.unimplemented("Not implemented on web.")}async listChannels(){throw this.unimplemented("Not implemented on web.")}async schedule(i){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");for(const t of i.notifications)this.sendNotification(t);return{notifications:i.notifications.map(t=>({id:t.id}))}}async getPending(){return{notifications:this.pending}}async registerActionTypes(){throw this.unimplemented("Not implemented on web.")}async cancel(i){this.pending=this.pending.filter(t=>!i.notifications.find(e=>e.id===t.id))}async areEnabled(){const{display:i}=await this.checkPermissions();return{value:i==="granted"}}async changeExactNotificationSetting(){throw this.unimplemented("Not implemented on web.")}async checkExactNotificationSetting(){throw this.unimplemented("Not implemented on web.")}async requestPermissions(){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");return{display:this.transformNotificationPermission(await Notification.requestPermission())}}async checkPermissions(){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");return{display:this.transformNotificationPermission(Notification.permission)}}transformNotificationPermission(i){switch(i){case"granted":return"granted";case"denied":return"denied";default:return"prompt"}}sendPending(){var i;const t=[],e=new Date().getTime();for(const n of this.pending)!((i=n.schedule)===null||i===void 0)&&i.at&&n.schedule.at.getTime()<=e&&(this.buildNotification(n),t.push(n));this.pending=this.pending.filter(n=>!t.find(o=>o===n))}sendNotification(i){var t;if(!((t=i.schedule)===null||t===void 0)&&t.at){const e=i.schedule.at.getTime()-new Date().getTime();this.pending.push(i),setTimeout(()=>{this.sendPending()},e);return}this.buildNotification(i)}buildNotification(i){const t=new Notification(i.title,{body:i.body,tag:String(i.id)});return t.addEventListener("click",this.onClick.bind(this,i),!1),t.addEventListener("show",this.onShow.bind(this,i),!1),t.addEventListener("close",()=>{this.deliveredNotifications=this.deliveredNotifications.filter(()=>!this)},!1),this.deliveredNotifications.push(t),t}onClick(i){const t={actionId:"tap",notification:i};this.notifyListeners("localNotificationActionPerformed",t)}onShow(i){this.notifyListeners("localNotificationReceived",i)}}export{l as LocalNotificationsWeb};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c5 as a}from"./main-
|
|
1
|
+
import{c5 as a}from"./main-BvvvhWnd.js";import{ImpactStyle as i,NotificationType as r}from"./index-B7BnOlMV.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class h extends a{constructor(){super(...arguments),this.selectionStarted=!1}async impact(t){const e=this.patternForImpact(t==null?void 0:t.style);this.vibrateWithPattern(e)}async notification(t){const e=this.patternForNotification(t==null?void 0:t.type);this.vibrateWithPattern(e)}async vibrate(t){const e=(t==null?void 0:t.duration)||300;this.vibrateWithPattern([e])}async selectionStart(){this.selectionStarted=!0}async selectionChanged(){this.selectionStarted&&this.vibrateWithPattern([70])}async selectionEnd(){this.selectionStarted=!1}patternForImpact(t=i.Heavy){return t===i.Medium?[43]:t===i.Light?[20]:[61]}patternForNotification(t=r.Success){return t===r.Warning?[30,40,30,50,60]:t===r.Error?[27,45,50]:[35,65,21]}vibrateWithPattern(t){if(navigator.vibrate)navigator.vibrate(t);else throw this.unavailable("Browser does not support the vibrate API")}}export{h as HapticsWeb};
|
package/dist/index.html
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png" />
|
|
23
23
|
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png" />
|
|
24
24
|
<title>Tide Commander</title>
|
|
25
|
-
<script type="module" crossorigin src="/assets/main-
|
|
25
|
+
<script type="module" crossorigin src="/assets/main-BvvvhWnd.js"></script>
|
|
26
26
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react--Eh9ivFN.js">
|
|
27
27
|
<link rel="modulepreload" crossorigin href="/assets/vendor-three-Chj50gSY.js">
|
|
28
28
|
<link rel="stylesheet" crossorigin href="/assets/main-Co2mNETL.css">
|
|
@@ -228,11 +228,20 @@ export function createRuntimeCommandExecution(deps) {
|
|
|
228
228
|
if (hasPendingSilentContextRefresh(agentId)) {
|
|
229
229
|
clearPendingSilentContextRefresh(agentId);
|
|
230
230
|
}
|
|
231
|
+
// Clear tracking-board state on explicit stop so stale taskLabel /
|
|
232
|
+
// trackingStatus / trackingStatusDetail don't linger on the tracking board
|
|
233
|
+
// after the agent is killed. Natural task completion does NOT funnel
|
|
234
|
+
// through stopAgent — its final-turn PATCH sets need-review /
|
|
235
|
+
// can-clear-context, and we want to keep that visible.
|
|
231
236
|
agentService.updateAgent(agentId, {
|
|
232
237
|
status: 'idle',
|
|
233
238
|
currentTask: undefined,
|
|
234
239
|
currentTool: undefined,
|
|
235
240
|
isDetached: false,
|
|
241
|
+
taskLabel: undefined,
|
|
242
|
+
trackingStatus: null,
|
|
243
|
+
trackingStatusDetail: undefined,
|
|
244
|
+
trackingStatusTimestamp: undefined,
|
|
236
245
|
});
|
|
237
246
|
}
|
|
238
247
|
return {
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{b9 as Oe,r as t,s as I,l as ye,ba as Ee,aE as _e,j as e,I as z,u as fe,bb as ze,bc as Te,bd as Be,be as Ue,m as Ke,bf as We,bg as De,bh as Ve,$ as Ge,a0 as qe,bi as Ye,aN as Je,E as Me,S as ce,aH as Xe,aD as Qe,V as Ze,G as Ie,ab as et,N as tt,bj as st,n as X,bk as nt}from"./main-CjPuuFGh.js";import{F as at}from"./index-snzCcqn6.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Se={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ct={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ot=12e4;function rt(n){return n.trim().replace(/\r\n/g,`
|
|
2
|
-
`)}function $e(n,a){return`${n}:${rt(a)}`}function it(n,a,l,f){if(n.uuid&&a.has(n.uuid))return!1;const p=n.isUserPrompt?"user":"assistant",d=$e(p,n.text),M=n.timestamp||0,A=l.get(d);return A!==void 0&&Math.abs(M-A)<=ot?!1:M>f}function dt({isOpen:n,agents:a}){const l=Oe(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{n||(d.current.clear(),p(new Map))},[n]),t.useEffect(()=>{if(!n)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;l>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,C,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),k}),!i.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(i.id,[],C),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),k});return}try{const k=await(await _e(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=k.messages||[],W=P.length>0?Math.max(...P.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,Y=new Set(P.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of P){if(w.type!=="user"&&w.type!=="assistant")continue;const o=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,K=V.get(o)??0;L>K&&V.set(o,L)}const G=I.getOutputs(i.id),U=(C&&C.length>0?[...C,...G]:G).filter(w=>it(w,Y,V,W));I.clearOutputs(i.id);for(const w of U)I.addOutput(i.id,w);p(w=>{const o=new Map(w);return o.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:k.hasMore||!1,totalCount:k.totalCount||0}),o})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),C&&C.length>0){I.clearOutputs(i.id);for(const k of C)I.addOutput(i.id,k)}p(k=>{const P=new Map(k);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=l>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const C=h==null?void 0:h.get(i.id);v(i,C,u)}},[n,M,A,l]);const R=t.useRef(a),S=t.useRef(f);R.current=a,S.current=f;const b=t.useCallback(async j=>{const h=R.current.get(j),v=S.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(C=>{const F=new Map(C),x=C.get(j);return x&&F.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function ut({command:n,onCommandChange:a,useTextarea:l,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:S,uploadFile:b,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),C=t.useRef(l);t.useEffect(()=>{if(l&&!C.current&&i.current){const o=i.current;o.focus(),o.selectionStart=o.selectionEnd=o.value.length}C.current=l},[l]),t.useEffect(()=>{const o=i.current;if(!o||!l)return;o.style.height="auto";const L=v?120:180,K=Math.min(o.scrollHeight,L);o.style.height=`${K}px`},[n,l,v]);const F=t.useCallback(async o=>{const L=o.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){o.preventDefault();const $=_.getAsFile();if($){const H=await b($);H&&R(H)}return}const K=o.clipboardData.files;if(K.length>0){o.preventDefault();for(const _ of K){const $=await b(_);$&&R($)}return}const B=o.clipboardData.getData("text"),te=(B.match(/\n/g)||[]).length+1;if(te>5){o.preventDefault();const $=`[Pasted text #${E(B)} +${te} lines]`,H=o.target,se=H.selectionStart||0,ae=H.selectionEnd||0,ne=n.slice(0,se)+$+n.slice(ae);a(ne),l||p(!0)}},[n,a,l,p,b,R,E]),x=t.useCallback(async o=>{const L=o.target.files;if(L){for(const K of L){const B=await b(K);B&&R(B)}D.current&&(D.current.value="")}},[b,R]),k=t.useCallback(o=>{if(o.key==="Enter"&&o.shiftKey){l||(o.preventDefault(),p(!0));return}o.key==="Enter"&&(o.preventDefault(),d())},[l,p,d]),P=t.useCallback(o=>{},[]),W=t.useCallback(o=>{o.button===1&&(o.preventDefault(),o.stopPropagation())},[]),Y=t.useCallback(o=>{i.current=o,u==null||u(o)},[u]),V=v?"agent-panel-input":"guake-input",G=v?"agent-panel-input-container":"guake-input-container",Q=v?"agent-panel-attach-btn":"guake-attach-btn",U=v?"agent-panel-send-btn":"",w=l?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(o=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${o.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:o.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:o.path,children:o.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(o.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>S(o.id),title:"Remove",children:"×"})]},o.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:G,onAuxClick:W,children:[e.jsx("button",{className:Q,onClick:()=>{var o;return(o=D.current)==null?void 0:o.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),l?e.jsx("textarea",{ref:Y,placeholder:j,value:n,onChange:o=>a(o.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:n,onChange:o=>a(o.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}),e.jsx("button",{className:U,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function mt(n){const a=Math.floor(n/1e3),l=Math.floor(a/60),f=a%60;return`${l}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:l,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!l||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[l,f]),l?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:n,history:a,outputs:l,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:S,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),j=ze(n.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[C,F]=t.useState(!0),[x,k]=t.useState(!1),[P,W]=t.useState(null),[Y,V]=t.useState(null),[G,Q]=t.useState(null);Te(`commander-image-modal-${n.id}`,P!==null,()=>W(null));const{command:U,setCommand:w,forceTextarea:o,setForceTextarea:L,useTextarea:K,setPastedTexts:B,incrementPastedCount:te,resetPastedCount:_,attachedFiles:$,setAttachedFiles:H,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Be({selectedAgentId:n.id}),le=U.trim().length>0||$.length>0,s=Ue({outputs:l,viewMode:d?"advanced":"simple"}),c=t.useMemo(()=>{const N=Ke(n);return{usedPercent:N.usedPercent,freePercent:N.freePercent,hasData:!!n.contextStats,totalTokens:N.totalTokens,contextWindow:N.contextWindow}},[n.contextStats,n.contextUsed,n.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&S&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,S())},[v,a==null?void 0:a.hasMore,S]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,F(!1)},[]),T=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Z.current)&&(i.current=!1,F(!0),k(!0)),T.current=f,Z.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),k(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const N=h.current;if(!N)return;const y=performance.now();let O=0,ue=-1,ke;const Re=()=>{const{scrollTop:Fe,scrollHeight:Ne,clientHeight:Le}=N,He=Ne-Fe-Le<=2;if(Math.abs(Ne-ue)<=1&&He?O+=1:O=0,ue=Ne,O>=3){k(!1);return}if(performance.now()-y>5e3){k(!1);return}ke=requestAnimationFrame(Re)};return ke=requestAnimationFrame(Re),()=>cancelAnimationFrame(ke)},[x]),t.useEffect(()=>{i.current||F(!0)},[s.length]);const q=t.useCallback(()=>!1,[]),ie=t.useCallback(N=>{const y=te();return B(O=>new Map(O).set(y,N)),y},[te,B]),he=t.useCallback(N=>{H(y=>[...y,N])},[H]),xe=t.useCallback(()=>{if(!le)return;if(U.trim()==="/clear"&&$.length===0){I.clearContext(n.id),b(),w(""),L(!1),B(new Map),H([]),_();return}let N=ne(U.trim());if($.length>0){const y=$.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
|
|
3
|
-
`);N=N?`${N}
|
|
4
|
-
|
|
5
|
-
${y}`:y}I.sendCommand(n.id,N),w(""),L(!1),B(new Map),H([]),_()},[n.id,U,le,$,ne,b,_,w,L,B,H]),ge=t.useCallback((N,y)=>{W({url:N,name:y})},[]),ve=t.useCallback((N,y)=>{const O=We(N,n.cwd),ue=O.line?{...y||{},targetLine:O.line}:y;I.setFileViewerPath(O.path,ue,n.cwd)},[n.cwd]),je=t.useCallback((N,y)=>{V({command:N,output:y,isLive:y==="Running..."})},[]),we=t.useCallback(N=>{Q(N)},[]),Ce=t.useCallback(()=>{k(!1),i.current=!0,F(!1)},[]),be=t.useCallback(()=>W(null),[]),r=t.useCallback(()=>V(null),[]),J=t.useCallback(()=>Q(null),[]),de=t.useCallback(N=>{N.stopPropagation(),M()},[M]),oe=ct[n.status]||"#888888",re=(a==null?void 0:a.messages)||[];return e.jsxs("div",{className:`agent-panel ${n.status==="working"?"working":""} ${f?"expanded":""} ${p?"focused":""}`,onClick:p?void 0:A,children:[e.jsxs("div",{className:"agent-panel-header",onClick:p?A:void 0,children:[e.jsxs("div",{className:"agent-panel-info",children:[e.jsx("span",{className:"agent-panel-status",style:{background:oe},title:n.status}),e.jsxs("span",{className:"agent-panel-name",children:[(n.isBoss||n.class==="boss")&&e.jsx("span",{className:"agent-panel-boss-crown",children:e.jsx(z,{name:"crown",size:14})}),n.name]}),e.jsx("span",{className:`agent-panel-status-label ${n.status}`,children:n.status}),e.jsx("span",{className:"agent-panel-class",children:n.class}),e.jsx("span",{className:`agent-panel-provider ${n.provider==="codex"?"codex":n.provider==="opencode"?"opencode":"claude"}`,children:n.provider||"claude"}),e.jsxs("span",{className:"agent-panel-id",title:`ID: ${n.id}`,children:["[",n.id.substring(0,4),"]"]}),n.taskLabel?e.jsxs("div",{className:"agent-panel-task agent-panel-task-label",title:n.taskLabel,children:[e.jsx(z,{name:"task",size:12})," ",n.taskLabel]}):n.currentTask?e.jsxs("div",{className:"agent-panel-task",title:n.currentTask,children:[n.currentTask.substring(0,40),"..."]}):null]}),e.jsxs("div",{className:"agent-panel-context",title:`Context: ${Math.round(c.usedPercent)}% used (${De(c.totalTokens)} / ${De(c.contextWindow)})`,children:[e.jsx("div",{className:"agent-panel-context-bar",style:{background:c.freePercent<20?"#ff4a4a":c.freePercent<50?"#ff9e4a":"#4aff9e",width:`${c.freePercent}%`}}),e.jsxs("span",{className:"agent-panel-context-text",children:[Math.round(c.freePercent),"%"]})]}),e.jsx("div",{className:"agent-panel-actions",children:e.jsx("button",{className:"agent-panel-expand",onClick:de,title:E(f?"commander.collapsePanel":"commander.expandPanel"),children:f?e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})]}),e.jsx("div",{className:"agent-panel-content",ref:h,children:a!=null&&a.loading?e.jsx("div",{className:"agent-panel-loading",children:E("common:status.loading")}):e.jsx(e.Fragment,{children:!re.length&&!s.length?e.jsxs("div",{className:"agent-panel-empty",children:[E("commander.noMessages"),!n.sessionId&&e.jsx("div",{style:{fontSize:"10px",color:"#666"},children:E("commander.noSessionId")})]}):e.jsx(Ve,{historyMessages:re,liveOutputs:s,agentId:n.id,viewMode:d?"advanced":"simple",selectedMessageIndex:null,isMessageSelected:q,onImageClick:ge,onFileClick:ve,onBashClick:je,onViewMarkdown:we,scrollContainerRef:h,onScrollTopReached:g,isLoadingMore:v,hasMore:a==null?void 0:a.hasMore,shouldAutoScroll:C,onUserScroll:m,pinToBottom:x,onPinCancel:Ce,isLoadingHistory:a==null?void 0:a.loading})})}),e.jsxs("div",{className:`guake-input-wrapper ${n.status==="working"?"has-stop-btn is-working":""}`,children:[e.jsx(ft,{agentId:n.id,isWorking:n.status==="working",timestamp:j==null?void 0:j.timestamp}),e.jsx(ut,{command:U,onCommandChange:w,useTextarea:K,forceTextarea:o,onForceTextarea:L,onSend:xe,canSend:le,attachedFiles:$,onAddFile:he,onRemoveFile:se,uploadFile:ae,onAddPastedText:ie,placeholder:E("commander.command",{name:n.name}),compact:!1,inputRef:R})]}),P&&e.jsx(Ge,{url:P.url,name:P.name,onClose:be}),Y&&e.jsx(qe,{state:Y,onClose:r}),e.jsx(Ye,{agent:n,content:G,onClose:J})]})}function ht({currentArea:n,onClose:a}){const{t:l}=fe(["terminal","common"]),[f,p]=t.useState(()=>{const u=new Set(Array.from(I.getState().agents.values()).map(D=>D.name));return Je.find(D=>!u.has(D))||`Agent-${Date.now().toString(36)}`}),[d,M]=t.useState(()=>Me(ce.LAST_CWD)),[A,R]=t.useState("scout"),[S,b]=t.useState("claude"),[E,j]=t.useState(!1),h=()=>{if(!f.trim()||!d.trim())return;j(!0),Ie(ce.LAST_CWD,d);let u;n&&(u={x:n.center.x,z:n.center.z}),I.spawnAgent(f.trim(),A,d.trim(),u,void 0,void 0,void 0,void 0,S),setTimeout(()=>{a()},500)},v=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),h()),u.key==="Escape"&&a()};return e.jsx("div",{className:"commander-spawn-overlay",onClick:a,children:e.jsxs("div",{className:"commander-spawn-form",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"commander-spawn-header",children:[e.jsx("h3",{children:l("spawn.addNewAgent")}),n&&e.jsxs("span",{className:"commander-spawn-area",children:[e.jsx("span",{className:"commander-spawn-area-dot",style:{background:n.color}}),n.name]})]}),e.jsxs("div",{className:"commander-spawn-body",children:[e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.name")}),e.jsx("input",{type:"text",value:f,onChange:u=>p(u.target.value),onKeyDown:v,autoFocus:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.workingDirectory")}),e.jsx(Xe,{value:d,onChange:M,onSubmit:h,placeholder:l("spawn.workingDirPlaceholder"),directoriesOnly:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.class")}),e.jsx("div",{className:"commander-spawn-classes",children:Qe.map(u=>e.jsxs("button",{className:`commander-spawn-class ${A===u.id?"selected":""}`,onClick:()=>R(u.id),children:[e.jsx(Ze,{classId:u.id,size:18,className:"commander-spawn-class-icon"}),e.jsx("span",{children:u.name})]},u.id))})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.runtime")}),e.jsxs("div",{className:"commander-spawn-classes",children:[e.jsxs("button",{className:`commander-spawn-class ${S==="claude"?"selected":""}`,onClick:()=>b("claude"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"brain",size:14})}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`commander-spawn-class ${S==="codex"?"selected":""}`,onClick:()=>b("codex"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"gear",size:14})}),e.jsx("span",{children:"Codex"})]}),e.jsxs("button",{className:`commander-spawn-class ${S==="opencode"?"selected":""}`,onClick:()=>b("opencode"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"status-pending",size:12,weight:"fill",color:"#4ade80"})}),e.jsx("span",{children:"OpenCode"})]})]})]})]}),e.jsxs("div",{className:"commander-spawn-footer",children:[e.jsx("button",{className:"commander-spawn-cancel",onClick:a,children:l("common:buttons.cancel")}),e.jsx("button",{className:"commander-spawn-submit",onClick:h,disabled:!f.trim()||!d.trim()||E,children:l(E?"common:buttons.deploying":"common:buttons.deploy")})]})]})})}const Pe=t.memo(function({agent:a,history:l,isExpanded:f,isFocused:p,advancedView:d,index:M,onExpand:A,onCollapse:R,onFocus:S,onInputRef:b,onLoadMore:E,onClearHistory:j}){const h=nt(a.id),v=t.useCallback(()=>{f?R():A(a.id)},[a.id,f,A,R]),u=t.useCallback(()=>{S(p?-1:M)},[M,p,S]),D=t.useCallback(F=>{b(a.id,F)},[a.id,b]),i=t.useCallback(()=>{E(a.id)},[a.id,E]),C=t.useCallback(()=>{j(a.id)},[a.id,j]);return e.jsx(pt,{agent:a,history:l,outputs:h,isExpanded:f,isFocused:p,advancedView:d,onExpand:v,onFocus:u,inputRef:D,onLoadMore:i,onClearHistory:C})});function Ct({isOpen:n,onClose:a}){const{t:l}=fe(["terminal","common"]),f=et(),p=tt(),[d,M]=t.useState(()=>Me(ce.COMMANDER_TAB,"all")),[A,R]=t.useState(0),[S,b]=t.useState(null),E=t.useRef(null),[j,h]=t.useState(0),[v,u]=t.useState(!1),[D,i]=t.useState(null),[C,F]=t.useState(!1),[x,k]=t.useState(()=>{try{const s=Me(ce.COMMANDER_FILTERS,"");if(s)return{...Se,...JSON.parse(s)}}catch{}return Se}),P=t.useRef(new Map),W=t.useRef([]),Y=t.useRef(0),V=t.useRef([]),G=t.useRef(d),{histories:Q,loadMoreHistory:U,clearAgentHistory:w}=dt({isOpen:n,agents:f});t.useEffect(()=>{n||(b(null),h(0),u(!1))},[n]);const o=t.useMemo(()=>{const s=Array.from(p.values()).sort((g,m)=>g.name.localeCompare(m.name)),c=[{id:"all",name:l("common:labels.all")}];for(const g of s)c.push({id:g.id,name:g.name,color:g.color});return c.push({id:"unassigned",name:l("commander.unassigned")}),c},[p]),L=t.useMemo(()=>d==="all"||d==="unassigned"?null:p.get(d)||null,[d,p]),K=t.useMemo(()=>{const s=new Map;s.set("all",f.size);let c=0;for(const g of f.values()){const m=I.getAreaForAgent(g.id);m?s.set(m.id,(s.get(m.id)||0)+1):c++}return s.set("unassigned",c),s},[f]),B=x.status!=="all"||x.activity!=="all"||x.sort!=="activity",te=(x.status!=="all"?1:0)+(x.activity!=="all"?1:0)+(x.sort!=="activity"?1:0),_=t.useMemo(()=>{const s=m=>m.isBoss===!0||m.class==="boss",c=Date.now();let g=Array.from(f.values());if(d==="unassigned"?g=g.filter(m=>!I.getAreaForAgent(m.id)):d!=="all"&&(g=g.filter(m=>{const T=I.getAreaForAgent(m.id);return(T==null?void 0:T.id)===d})),x.status!=="all"&&(g=g.filter(m=>{switch(x.status){case"working":return m.status==="working";case"idle":return m.status==="idle";case"error":return m.status==="error"||m.status==="waiting"||m.status==="waiting_permission";case"offline":return m.status==="offline"||m.status==="orphaned";default:return!0}})),x.activity!=="all"){const m=lt[x.activity];g=g.filter(T=>c-(T.lastActivity||0)<m)}return g.sort((m,T)=>{var Z,ee;if(s(m)&&!s(T))return-1;if(!s(m)&&s(T))return 1;switch(x.sort){case"activity":return(T.lastActivity||0)-(m.lastActivity||0);case"name":return m.name.localeCompare(T.name);case"created":return(m.createdAt||0)-(T.createdAt||0);case"context":{const q=((Z=m.contextStats)==null?void 0:Z.usedPercent)??(m.contextUsed||0)/(m.contextLimit||2e5)*100;return(((ee=T.contextStats)==null?void 0:ee.usedPercent)??(T.contextUsed||0)/(T.contextLimit||2e5)*100)-q}default:return(T.lastActivity||0)-(m.lastActivity||0)}}),g},[f,d,x]),$=Math.ceil(_.length/Ae),H=t.useMemo(()=>_.slice(A*Ae,(A+1)*Ae),[_,A]);W.current=H,E.current=S,Y.current=j,V.current=o,G.current=d,Te("commander-expanded",S!==null,()=>b(null));const se=st();t.useEffect(()=>{n&&se&&(b(se),I.clearCommanderExpandRequest())},[n,se]);const ae=t.useCallback(()=>b(null),[]),ne=t.useCallback(s=>b(s),[]),le=t.useCallback(s=>h(s),[]),pe=t.useCallback((s,c)=>{c?P.current.set(s,c):P.current.delete(s)},[]);return t.useEffect(()=>{R(0),Ie(ce.COMMANDER_TAB,d)},[d]),t.useEffect(()=>{Ie(ce.COMMANDER_FILTERS,JSON.stringify(x)),R(0)},[x]),t.useEffect(()=>{var c;if(!n||window.matchMedia("(pointer: coarse)").matches)return;const s=S||((c=W.current[j])==null?void 0:c.id);if(s){const g=P.current.get(s);g&&document.activeElement!==g&&setTimeout(()=>g.focus(),50)}},[n,j,S]),t.useEffect(()=>{if(!n)return;const s=c=>{const g=I.getShortcuts(),m=c.target,T=m.tagName==="INPUT"||m.tagName==="TEXTAREA",Z=W.current,ee=Z.length-1,q=E.current,ie=g.find(r=>r.id==="commander-close");if(X(c,ie)){const{fileViewerPath:r,contextModalAgentId:J}=I.getState();if(r||J)return;c.preventDefault(),c.stopImmediatePropagation(),q?b(null):a();return}const he=g.find(r=>r.id==="commander-vim-left");if(X(c,he)&&!q){c.preventDefault(),h(r=>r>0?r-1:r);return}const xe=g.find(r=>r.id==="commander-vim-right");if(X(c,xe)&&!q){c.preventDefault(),h(r=>r<ee?r+1:r);return}const ge=g.find(r=>r.id==="commander-vim-up");if(X(c,ge)&&!q){c.preventDefault(),h(r=>r>=me?r-me:r);return}const ve=g.find(r=>r.id==="commander-vim-down");if(X(c,ve)&&!q){c.preventDefault(),h(r=>r+me<=ee?r+me:r);return}const je=g.find(r=>r.id==="commander-expand");if(X(c,je)){if(c.preventDefault(),q)b(null);else{const r=Z[Y.current];r&&b(r.id)}return}const we=g.find(r=>r.id==="commander-new-agent");if(X(c,we)){c.preventDefault(),u(!0);return}const Ce=g.find(r=>r.id==="commander-next-tab"),be=g.find(r=>r.id==="commander-prev-tab");if(!T){const r=V.current;if(X(c,Ce)){const J=I.getState().latestNotificationAgentId;if(J){if(c.preventDefault(),c.stopPropagation(),!I.getState().agents.get(J)){I.setLatestNotificationAgentId(null);return}const y=I.getAreaForAgent(J);y&&r.some(O=>O.id===y.id)?M(y.id):M("unassigned"),b(J),h(0),R(0),I.setLatestNotificationAgentId(null);return}c.preventDefault(),c.stopPropagation();const oe=(r.findIndex(re=>re.id===G.current)+1)%r.length;M(r[oe].id),h(0);return}if(X(c,be)){c.preventDefault(),c.stopPropagation();const de=(r.findIndex(oe=>oe.id===G.current)-1+r.length)%r.length;M(r[de].id),h(0);return}}};return document.addEventListener("keydown",s,!0),()=>document.removeEventListener("keydown",s,!0)},[n,a]),n?e.jsx("div",{className:"commander-overlay",onClick:a,children:e.jsxs("div",{className:"commander-view",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"commander-header",children:[e.jsxs("div",{className:"commander-title-section",children:[e.jsx("h2",{className:"commander-title",children:l("commander.title")}),e.jsx("span",{className:"commander-shortcuts",children:l("commander.shortcuts")})]}),e.jsxs("div",{className:"commander-controls",children:[e.jsx("button",{className:`commander-view-toggle ${C?"active":""}`,onClick:()=>F(!C),title:l(C?"commander.simple":"commander.advanced"),children:C?e.jsxs(e.Fragment,{children:[e.jsx(z,{name:"target",size:12})," ",l("commander.advanced")]}):e.jsxs(e.Fragment,{children:[e.jsx(z,{name:"status-pending",size:12})," ",l("commander.simple")]})}),e.jsx("button",{className:"commander-add-btn",onClick:()=>u(!0),title:l("commander.addAgent"),children:l("commander.addAgent")}),e.jsx("button",{className:"commander-close",onClick:a,children:l("commander.close")})]})]}),e.jsx("div",{className:"commander-tabs",children:o.map(s=>{const c=s.id!=="all"&&s.id!=="unassigned"?p.get(s.id):null,g=c&&c.directories&&c.directories.length>0;return e.jsxs("button",{className:`commander-tab ${d===s.id?"active":""}`,onClick:()=>{M(s.id),h(0)},style:s.color?{borderBottomColor:d===s.id?s.color:"transparent"}:void 0,children:[s.color&&e.jsx("span",{className:"commander-tab-dot",style:{background:s.color}}),e.jsx("span",{children:s.name}),e.jsx("span",{className:"commander-tab-count",children:K.get(s.id)||0}),g&&e.jsx("span",{className:"commander-tab-folder",onClick:m=>{m.stopPropagation(),i(s.id)},title:l("commander.openFileExplorer"),children:e.jsx(z,{name:"folder",size:12})})]},s.id)})}),e.jsxs("div",{className:"commander-filters",children:[e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.status")}),["all","working","idle","error","offline"].map(s=>e.jsx("button",{className:`commander-filter-btn ${x.status===s?"active":""}`,onClick:()=>k(c=>({...c,status:s})),children:s==="all"?l("commander.filters.all"):s==="error"?l("commander.filters.needsAttn"):s.charAt(0).toUpperCase()+s.slice(1)},s))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.active")}),["all","1h","6h","24h"].map(s=>e.jsx("button",{className:`commander-filter-btn ${x.activity===s?"active":""}`,onClick:()=>k(c=>({...c,activity:s})),children:s==="all"?l("commander.filters.any"):`< ${s}`},s))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.sort")}),["activity","name","created","context"].map(s=>e.jsx("button",{className:`commander-filter-btn ${x.sort===s?"active":""}`,onClick:()=>k(c=>({...c,sort:s})),children:s==="activity"?l("commander.filters.recent"):s==="context"?l("commander.filters.context"):s.charAt(0).toUpperCase()+s.slice(1)},s))]}),B&&e.jsx("button",{className:"commander-filter-clear",onClick:()=>k(Se),title:l("commander.clearFilters"),children:l("commander.filters.clearFilters",{count:te})})]}),$>1&&e.jsxs("div",{className:"commander-pagination",children:[e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(s=>Math.max(0,s-1)),disabled:A===0,children:[e.jsx(z,{name:"caret-left",size:12})," ",l("commander.prev")]}),e.jsx("span",{className:"commander-page-info",children:l("commander.page",{current:A+1,total:$,count:_.length})}),e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(s=>Math.min($-1,s+1)),disabled:A===$-1,children:[l("commander.next")," ",e.jsx(z,{name:"caret-right",size:12})]})]}),e.jsx("div",{className:`commander-grid ${S?"has-expanded":""}`,"data-agent-count":S?1:H.length,children:H.length===0?e.jsx("div",{className:"commander-empty",children:l(d==="all"?"commander.noAgentsAll":d==="unassigned"?"commander.noAgentsUnassigned":"commander.noAgentsArea")}):S?(()=>{const s=f.get(S);return s?e.jsx(Pe,{agent:s,history:Q.get(s.id),isExpanded:!0,isFocused:!0,advancedView:C,index:0,onExpand:ne,onCollapse:ae,onFocus:le,onInputRef:pe,onLoadMore:U,onClearHistory:w},s.id):null})():H.map((s,c)=>e.jsx(Pe,{agent:s,history:Q.get(s.id),isExpanded:!1,isFocused:c===j,advancedView:C,index:c,onExpand:ne,onCollapse:ae,onFocus:le,onInputRef:pe,onLoadMore:U,onClearHistory:w},s.id))}),v&&e.jsx(ht,{currentArea:L,onClose:()=>u(!1)}),D&&e.jsx(at,{isOpen:!0,areaId:D,onClose:()=>i(null),onChangeArea:s=>i(s)})]})}):null}export{Ct as CommanderView};
|