@yeaft/webchat-agent 1.0.558 → 1.0.559

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":"1.0.558"}
1
+ {"version":"1.0.559"}
@@ -6731,9 +6731,9 @@ ${String(e||"").trim()}
6731
6731
  </section>
6732
6732
  </div>
6733
6733
  </aside>
6734
- `}});function _r(e){return typeof e=="string"?e.trim():""}function oC(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t.href:""}catch{return""}}function _v(e){let t=_r(e).replace(/\\/g,"/"),s=t.match(/^[A-Za-z]:/)?.[0]||"",n=t.startsWith("/")||!!s,r=t.slice(s.length).split("/"),i=[];for(let o of r)if(!(!o||o==="."))if(o===".."){if(!i.length)return"";i.pop()}else i.push(o);return`${s}${n&&!s||s?"/":""}${i.join("/")}`}function Md(e,t){let s=_r(e?.ref);if(!s)return null;let n=oC(s);if(e?.kind==="link"||e?.kind==="pr"||n)return n?{type:"url",url:n}:null;if(e?.kind!=="file"||!/^(?:[A-Za-z]:[\\/]|[\\/])/.test(_r(t)))return null;let r=_v(t),i=/^(?:[A-Za-z]:[\\/]|[\\/])/.test(s),o=_v(i?s:`${r}/${s}`);if(!r||!o)return null;let a=/^[A-Za-z]:/.test(r)?r.toLowerCase():r,l=/^[A-Za-z]:/.test(o)?o.toLowerCase():o,c=a.endsWith("/")?a:`${a}/`;return l!==a&&!l.startsWith(c)?null:{type:"file",filePath:o}}function Ev({agentId:e,workItem:t,routeProtocolSupported:s=!1,hasAgentCapability:n=()=>!1}={}){let r=_r(t?.id),i=_r(t?.workbench?.workDir),o={runtimeProvider:"work-center",agentId:_r(e),workItemId:r},a=lt(o),l=iC.filter(u=>!n(o.agentId,u)),c=s===!0&&!!(a&&i)&&l.length===0,d=c?Es(a,i):"";return{available:c,browserAvailable:!1,missingCapabilities:l,ownerRoute:o,ownerWorkDir:i,routeKey:a,workspaceGeneration:d,openOutput(u){if(!c)return!1;let g=Md(u,i);return g?.type!=="file"?!1:(window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:g.filePath,agentId:o.agentId,conversationId:En(a),workbenchRoute:o,workbenchRouteKey:a,workspaceGeneration:d}})),!0)}}}var iC,Dv=B(()=>{ps();iC=Object.freeze(["workbench_session_routes","workbench_request_correlation","workbench_terminal_cleanup_fence","work_center_workbench"])});function aC(){try{let e=Number(localStorage.getItem("work-center-actions-width"));if(Number.isFinite(e)&&e>=280&&e<=1e4)return e}catch{}return 400}function Oa(e){let t=(Number(e?.workCenterUrlRestoreGeneration)||0)+1;return e&&(e.workCenterUrlRestoreGeneration=t),t}var Fa,Pd=B(()=>{Pr();Vc();It();Ea();bv();Sv();xv();Qc();Qo();Yo();Ca();Tr();ba();Mv();Rv();Dv();Ad();en();wi();Co();Fa={name:"WorkCenterPage",components:{NavigationIcon:ks,MessageComposer:la,UserTurnBlock:vr,VpTurnBlock:mr,WorkCenterActionDetail:yv,WorkCenterActionReference:Rr,WorkCenterSettingsModal:Av,AgentSettingsPanel:Mr,ModernSelect:ws,WorkCenterResourceControl:kv,WorkbenchPanel:Ir,PaneResizeHandle:Tv,WorkCenterSidebar:Pv},mixins:[hv],data(){return{sidebarExpanded:window.innerWidth>1100,mobileNavigation:window.innerWidth<=1100,selectedId:null,infoTab:"requirement",workbenchExpanded:!1,selectedActionId:null,narrowPane:"items",contentPanelOpen:!1,actionsPaneWidth:aC(),contentStack:[{type:"action-list"}],staleComposerTarget:null,composerTargetValue:"coordinator",actionInputRequestGeneration:0,workCenterUrlRestoreGeneration:0,workItemMessage:"",workItemMessageQuote:null,workItemMessageAttachments:[],workItemMessageAttachmentsUploading:!1,workItemMessageSending:!1,workItemMessageError:"",workItemComposerGeneration:0,preserveComposerOnEnvelopeClear:!1,detailLoading:!1,detailError:"",createOpen:!1,settingsOpen:!1,saving:!1,createGeneration:0,llmConfigOpen:!1,agentSettingsOpen:!1,agentSettingsTargetId:null,unavailableAgentStateGeneration:0,unavailableAgentStateLoading:!1,unavailableAgentStateError:"",search:"",filtersOpen:!1,headerMenuOpen:!1,boardVpId:"",boardWorkItemType:"",boardUpdatedRange:"week",mobileBoardLane:"active",deletingWorkItemIds:{},deleteWorkItemError:"",boardQueryTimer:null,actionNowMs:Date.now(),workDirTouched:!1,startTouched:!1,createAttachments:[],attachmentsUploading:!1,previewingAttachmentId:null,attachmentPreviewError:"",attachmentPreviewGeneration:0,form:{requirement:"",workDir:"",deliveryTarget:"",reuseMemory:!0,start:!0}}},computed:{store(){return Pinia.useChatStore()},chat(){return this.store},agents(){return this.store.agents||[]},onlineAgents(){return this.agents.filter(e=>e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("work_center"))},configurableDisabledAgents(){return this.agents.filter(e=>{let t=this.store.workCenterFeatureSettingsByAgent?.[e?.id];return e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("work_center_feature_settings")&&!e.capabilities.includes("work_center")&&t?.loaded===!0&&!t.error&&t.enabled!==!0})},configurableUnavailableAgents(){return this.agents.filter(e=>{let t=this.store.workCenterFeatureSettingsByAgent?.[e?.id];return e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("work_center_feature_settings")&&!e.capabilities.includes("work_center")&&t?.loaded===!0&&!t.error&&t.enabled===!0})},configurableAgentSettingsLoading(){return this.unavailableAgentStateLoading},configurableAgentSettingsFailed(){return!!this.unavailableAgentStateError},hasConfigurableOnlineAgents(){return this.agents.some(e=>e?.online&&e.capabilities?.includes("work_center_feature_settings"))},hasOnlineAgents(){return this.agents.some(e=>e?.online)},agentId(){let e=this.store.workCenterAgentId;return this.onlineAgents.some(t=>t.id===e)?e:this.onlineAgents[0]?.id||null},sidebarAgents(){return this.agents.filter(e=>e.capabilities?.includes("work_center"))},watcher(){return this.store.workCenterWatcherByAgent[this.agentId]||null},boardNextCursor(){return this.store.workCenterListPageByAgent[this.agentId]?.nextCursor||null},boardLoadingMore(){return!!this.store.workCenterListMoreLoadingByAgent[this.agentId]},settings(){return this.store.workCenterSettingsByAgent[this.agentId]||null},runtime(){return this.store.workCenterRuntimeByAgent[this.agentId]||null},workItemTypes(){return Array.isArray(this.runtime?.workItemTypes)?this.runtime.workItemTypes:[]},workItemAttachmentsSupported(){return this.runtime?.workItemAttachments===!0},canonicalMessageWireSupported(){return this.agents.find(e=>e?.id===this.agentId)?.capabilities?.includes("work_center_message_v2")===!0},createDefaultWorkDir(){return this.settings?.defaultWorkDir||this.runtime?.defaultWorkDir||""},createDefaultStart(){return this.settings?.startImmediately!==!1},folderPickerAgentId(){return this.agentId||""},defaultWorkDir(){return this.createDefaultWorkDir},items(){return this.store.workCenterItemsByAgent[this.agentId]||[]},loading(){return!!this.store.workCenterLoadingByAgent[this.agentId]},loaded(){return!!this.store.workCenterLoadedByAgent[this.agentId]},error(){return this.store.workCenterErrorByAgent[this.agentId]||null},detail(){return this.store.workCenterDetailByAgent[this.agentId]||null},selected(){return this.detail?.id===this.selectedId?this.detail:this.items.find(e=>e.id===this.selectedId)||null},workbenchContext(){return Ev({agentId:this.agentId,workItem:this.narrowPane!=="items"?this.selected:null,routeProtocolSupported:this.store.workCenterWorkbenchProtocolSupported===!0&&this.store.workbenchRouteProtocolSupported===!0,hasAgentCapability:(e,t)=>this.store.hasAgentCapability(e,t)})},infoTabs(){return["requirement","progress","outputs","goals","usage"].map(e=>({id:e,label:this.$t(`workCenter.infoTab.${e}`)}))},requirementText(){return this.selected?.requirement||this.selected?.goal||""},goalProgress(){let e=this.selected?.goalProgress;return Array.isArray(e?.criteria)?e:null},finalResponses(){let e=this.selected?.finalResult?.responses;return Array.isArray(e)?e.filter(t=>typeof t?.summary=="string"&&t.summary.trim()):[]},selectedAction(){return(Array.isArray(this.selected?.actions)?this.selected.actions:[]).find(t=>t.id===this.selectedActionId)||null},contentRef(){return this.contentStack[this.contentStack.length-1]||{type:"action-list"}},contentIsActionList(){return this.contentRef.type==="action-list"},composerTargetIsCoordinator(){return this.composerTargetValue==="coordinator"},composerTargetAction(){if(!this.composerTargetValue.startsWith("action:"))return null;let[,e,t]=this.composerTargetValue.split(":"),s=Number(t);return(Array.isArray(this.selected?.actions)?this.selected.actions:[]).find(r=>r.id===e&&Number(r.generation)===s)||null},composerTargetIsStale(){return this.composerTargetValue!=="coordinator"&&!this.composerTargetAction},composerTargetOptions(){let e=Array.isArray(this.selected?.actions)?this.selected.actions:[],t=this.tr("workCenter.coordinator","Coordinator"),s=[{value:"coordinator",label:this.$t("workCenter.sendToTarget",{target:t}),sublabel:this.tr("workCenter.coordinatorTargetHint","Work Item planning and coordination"),disabled:!1},...e.map(n=>{let r=this.$t("workCenter.actionNumber",{number:this.actionSequence(n)});return{value:`action:${n.id}:${n.generation}`,label:this.$t("workCenter.sendToTarget",{target:r}),sublabel:n.brief?.objective||this.actionLabel(n.type),badge:this.statusLabel(n.status),disabled:!this.canMessageAction(n)}})];return this.composerTargetIsStale?[{value:this.composerTargetValue,label:this.tr("workCenter.targetUnavailable","Selected Action is no longer available"),sublabel:this.tr("workCenter.targetUnavailableHelp","Choose another target before sending. This draft was not redirected."),disabled:!0},...s]:s},composerTargetLabel(){return this.composerTargetAction?this.composerTargetAction.brief?.objective||this.actionLabel(this.composerTargetAction.type):this.tr("workCenter.coordinator","Coordinator")},composerPlaceholder(){return this.composerTargetAction?this.$t("workCenter.actionChatPlaceholder",{name:this.composerTargetLabel}):this.tr("workCenter.conversationPlaceholder","Message about this work item")},composerTargetUnavailable(){return this.coordinatorReadOnly?!0:this.composerTargetIsCoordinator?this.coordinatorThinking:this.composerTargetAction?!this.canMessageAction(this.composerTargetAction):!0},composerCanSend(){return!this.workItemMessageSending&&!this.workItemMessageAttachmentsUploading&&!this.composerTargetUnavailable&&(!!this.workItemMessage.trim()||this.workItemMessageAttachments.length>0)},pendingMessageEnvelope(){return this.selected?.id?this.store.loadWorkCenterMessageEnvelope(this.agentId,this.selected.id):null},composerDraftLocked(){return!!this.pendingMessageEnvelope&&!this.composerTargetIsStale},pendingEnvelopeHasAttachments(){return Array.isArray(this.pendingMessageEnvelope?.attachments)&&this.pendingMessageEnvelope.attachments.length>0},pendingEnvelopeAttachmentRecovery(){return this.composerDraftLocked&&this.pendingEnvelopeHasAttachments},actionMessageKey(){return this.selected?.id&&this.selectedAction?.id?or(this.agentId,this.selected.id,this.selectedAction.id,this.selectedAction.generation):""},workItemComposerScope(){return this.selected?.id?`${this.agentId}:${this.selected.id}:${this.workItemComposerGeneration}`:""},conversationBlocks(){return(Array.isArray(this.selected?.messages)?this.selected.messages:[]).map(e=>{let t=Number(e?.updatedAt||e?.createdAt)||0;if(e?.role==="user")return{key:e.id,kind:"user",message:{id:e.id,messageId:e.id,type:"user",content:e.text||"",attachments:Array.isArray(e.attachments)?e.attachments:[],quote:Mt(e.quote),timestamp:t}};if(e?.role==="assistant"){let s=e.speaker||{},n=this.workItemMessageSpeaker(e),r=s.id||`work-center-coordinator:${this.selected?.id||"unknown"}`,i=e.status==="thinking"?this.tr("workCenter.conversationThinking","Working\u2026"):e.error||"",o=e.decision?.kind&&e.decision.kind!=="answer"?this.tr(`workCenter.coordinatorDecision.${e.decision.kind}`,e.decision.kind):"",a=[e.text,i,o].filter(Boolean);return{key:e.id,kind:"assistant",speakerName:n,turn:{id:e.id,messageId:e.id,atMessageId:e.id,turnId:e.turnId||e.id,textContent:a.join(`
6734
+ `}});function _r(e){return typeof e=="string"?e.trim():""}function oC(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t.href:""}catch{return""}}function _v(e){let t=_r(e).replace(/\\/g,"/"),s=t.match(/^[A-Za-z]:/)?.[0]||"",n=t.startsWith("/")||!!s,r=t.slice(s.length).split("/"),i=[];for(let o of r)if(!(!o||o==="."))if(o===".."){if(!i.length)return"";i.pop()}else i.push(o);return`${s}${n&&!s||s?"/":""}${i.join("/")}`}function Md(e,t){let s=_r(e?.ref);if(!s)return null;let n=oC(s);if(e?.kind==="link"||e?.kind==="pr"||n)return n?{type:"url",url:n}:null;if(e?.kind!=="file"||!/^(?:[A-Za-z]:[\\/]|[\\/])/.test(_r(t)))return null;let r=_v(t),i=/^(?:[A-Za-z]:[\\/]|[\\/])/.test(s),o=_v(i?s:`${r}/${s}`);if(!r||!o)return null;let a=/^[A-Za-z]:/.test(r)?r.toLowerCase():r,l=/^[A-Za-z]:/.test(o)?o.toLowerCase():o,c=a.endsWith("/")?a:`${a}/`;return l!==a&&!l.startsWith(c)?null:{type:"file",filePath:o}}function Ev({agentId:e,workItem:t,routeProtocolSupported:s=!1,hasAgentCapability:n=()=>!1}={}){let r=_r(t?.id),i=_r(t?.workbench?.workDir),o={runtimeProvider:"work-center",agentId:_r(e),workItemId:r},a=lt(o),l=iC.filter(u=>!n(o.agentId,u)),c=s===!0&&!!(a&&i)&&l.length===0,d=c?Es(a,i):"";return{available:c,browserAvailable:!1,missingCapabilities:l,ownerRoute:o,ownerWorkDir:i,routeKey:a,workspaceGeneration:d,openOutput(u){if(!c)return!1;let g=Md(u,i);return g?.type!=="file"?!1:(window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:g.filePath,agentId:o.agentId,conversationId:En(a),workbenchRoute:o,workbenchRouteKey:a,workspaceGeneration:d}})),!0)}}}var iC,Dv=B(()=>{ps();iC=Object.freeze(["workbench_session_routes","workbench_request_correlation","workbench_terminal_cleanup_fence","work_center_workbench"])});function aC(){try{let e=Number(localStorage.getItem("work-center-actions-width"));if(Number.isFinite(e)&&e>=280&&e<=1e4)return e}catch{}return 400}function Oa(e){let t=(Number(e?.workCenterUrlRestoreGeneration)||0)+1;return e&&(e.workCenterUrlRestoreGeneration=t),t}var Fa,Pd=B(()=>{Pr();Vc();It();Ea();bv();Sv();xv();Qc();Qo();Yo();Ca();Tr();ba();Mv();Rv();Dv();Ad();en();wi();Co();Fa={name:"WorkCenterPage",components:{NavigationIcon:ks,MessageComposer:la,UserTurnBlock:vr,VpTurnBlock:mr,WorkCenterActionDetail:yv,WorkCenterActionReference:Rr,WorkCenterSettingsModal:Av,AgentSettingsPanel:Mr,ModernSelect:ws,WorkCenterResourceControl:kv,WorkbenchPanel:Ir,PaneResizeHandle:Tv,WorkCenterSidebar:Pv},mixins:[hv],data(){return{sidebarExpanded:window.innerWidth>1100,mobileNavigation:window.innerWidth<=1100,selectedId:null,infoTab:"requirement",workbenchExpanded:!1,selectedActionId:null,narrowPane:"items",contentPanelOpen:!1,actionsPaneWidth:aC(),contentStack:[{type:"action-list"}],staleComposerTarget:null,composerTargetValue:"coordinator",actionInputRequestGeneration:0,workCenterUrlRestoreGeneration:0,workItemMessage:"",workItemMessageQuote:null,workItemMessageAttachments:[],workItemMessageAttachmentUploadCount:0,workItemMessageAttachmentsUploading:!1,workItemMessageSending:!1,workItemMessageError:"",workItemComposerGeneration:0,preserveComposerOnEnvelopeClear:!1,detailLoading:!1,detailError:"",createOpen:!1,settingsOpen:!1,saving:!1,createGeneration:0,llmConfigOpen:!1,agentSettingsOpen:!1,agentSettingsTargetId:null,unavailableAgentStateGeneration:0,unavailableAgentStateLoading:!1,unavailableAgentStateError:"",search:"",filtersOpen:!1,headerMenuOpen:!1,boardVpId:"",boardWorkItemType:"",boardUpdatedRange:"week",mobileBoardLane:"active",deletingWorkItemIds:{},deleteWorkItemError:"",boardQueryTimer:null,actionNowMs:Date.now(),workDirTouched:!1,startTouched:!1,createAttachments:[],createAttachmentUploadCount:0,attachmentsUploading:!1,createAttachmentError:"",previewingAttachmentId:null,attachmentPreviewError:"",attachmentPreviewGeneration:0,form:{requirement:"",workDir:"",deliveryTarget:"",reuseMemory:!0,start:!0}}},computed:{store(){return Pinia.useChatStore()},chat(){return this.store},agents(){return this.store.agents||[]},onlineAgents(){return this.agents.filter(e=>e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("work_center"))},configurableDisabledAgents(){return this.agents.filter(e=>{let t=this.store.workCenterFeatureSettingsByAgent?.[e?.id];return e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("work_center_feature_settings")&&!e.capabilities.includes("work_center")&&t?.loaded===!0&&!t.error&&t.enabled!==!0})},configurableUnavailableAgents(){return this.agents.filter(e=>{let t=this.store.workCenterFeatureSettingsByAgent?.[e?.id];return e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("work_center_feature_settings")&&!e.capabilities.includes("work_center")&&t?.loaded===!0&&!t.error&&t.enabled===!0})},configurableAgentSettingsLoading(){return this.unavailableAgentStateLoading},configurableAgentSettingsFailed(){return!!this.unavailableAgentStateError},hasConfigurableOnlineAgents(){return this.agents.some(e=>e?.online&&e.capabilities?.includes("work_center_feature_settings"))},hasOnlineAgents(){return this.agents.some(e=>e?.online)},agentId(){let e=this.store.workCenterAgentId;return this.onlineAgents.some(t=>t.id===e)?e:this.onlineAgents[0]?.id||null},sidebarAgents(){return this.agents.filter(e=>e.capabilities?.includes("work_center"))},watcher(){return this.store.workCenterWatcherByAgent[this.agentId]||null},boardNextCursor(){return this.store.workCenterListPageByAgent[this.agentId]?.nextCursor||null},boardLoadingMore(){return!!this.store.workCenterListMoreLoadingByAgent[this.agentId]},settings(){return this.store.workCenterSettingsByAgent[this.agentId]||null},runtime(){return this.store.workCenterRuntimeByAgent[this.agentId]||null},workItemTypes(){return Array.isArray(this.runtime?.workItemTypes)?this.runtime.workItemTypes:[]},workItemAttachmentsSupported(){let e=this.agents.find(t=>t?.id===this.agentId);return e?.capabilityMetadataProvided===!0?e.capabilities?.includes("work_item_attachments")===!0:this.runtime?.workItemAttachments===!0},canonicalMessageWireSupported(){return this.agents.find(e=>e?.id===this.agentId)?.capabilities?.includes("work_center_message_v2")===!0},createDefaultWorkDir(){return this.settings?.defaultWorkDir||this.runtime?.defaultWorkDir||""},createDefaultStart(){return this.settings?.startImmediately!==!1},folderPickerAgentId(){return this.agentId||""},defaultWorkDir(){return this.createDefaultWorkDir},items(){return this.store.workCenterItemsByAgent[this.agentId]||[]},loading(){return!!this.store.workCenterLoadingByAgent[this.agentId]},loaded(){return!!this.store.workCenterLoadedByAgent[this.agentId]},error(){return this.store.workCenterErrorByAgent[this.agentId]||null},detail(){return this.store.workCenterDetailByAgent[this.agentId]||null},selected(){return this.detail?.id===this.selectedId?this.detail:this.items.find(e=>e.id===this.selectedId)||null},workbenchContext(){return Ev({agentId:this.agentId,workItem:this.narrowPane!=="items"?this.selected:null,routeProtocolSupported:this.store.workCenterWorkbenchProtocolSupported===!0&&this.store.workbenchRouteProtocolSupported===!0,hasAgentCapability:(e,t)=>this.store.hasAgentCapability(e,t)})},infoTabs(){return["requirement","progress","outputs","goals","usage"].map(e=>({id:e,label:this.$t(`workCenter.infoTab.${e}`)}))},requirementText(){return this.selected?.requirement||this.selected?.goal||""},goalProgress(){let e=this.selected?.goalProgress;return Array.isArray(e?.criteria)?e:null},finalResponses(){let e=this.selected?.finalResult?.responses;return Array.isArray(e)?e.filter(t=>typeof t?.summary=="string"&&t.summary.trim()):[]},selectedAction(){return(Array.isArray(this.selected?.actions)?this.selected.actions:[]).find(t=>t.id===this.selectedActionId)||null},contentRef(){return this.contentStack[this.contentStack.length-1]||{type:"action-list"}},contentIsActionList(){return this.contentRef.type==="action-list"},composerTargetIsCoordinator(){return this.composerTargetValue==="coordinator"},composerTargetAction(){if(!this.composerTargetValue.startsWith("action:"))return null;let[,e,t]=this.composerTargetValue.split(":"),s=Number(t);return(Array.isArray(this.selected?.actions)?this.selected.actions:[]).find(r=>r.id===e&&Number(r.generation)===s)||null},composerTargetIsStale(){return this.composerTargetValue!=="coordinator"&&!this.composerTargetAction},composerTargetOptions(){let e=Array.isArray(this.selected?.actions)?this.selected.actions:[],t=this.tr("workCenter.coordinator","Coordinator"),s=[{value:"coordinator",label:this.$t("workCenter.sendToTarget",{target:t}),sublabel:this.tr("workCenter.coordinatorTargetHint","Work Item planning and coordination"),disabled:!1},...e.map(n=>{let r=this.$t("workCenter.actionNumber",{number:this.actionSequence(n)});return{value:`action:${n.id}:${n.generation}`,label:this.$t("workCenter.sendToTarget",{target:r}),sublabel:n.brief?.objective||this.actionLabel(n.type),badge:this.statusLabel(n.status),disabled:!this.canMessageAction(n)}})];return this.composerTargetIsStale?[{value:this.composerTargetValue,label:this.tr("workCenter.targetUnavailable","Selected Action is no longer available"),sublabel:this.tr("workCenter.targetUnavailableHelp","Choose another target before sending. This draft was not redirected."),disabled:!0},...s]:s},composerTargetLabel(){return this.composerTargetAction?this.composerTargetAction.brief?.objective||this.actionLabel(this.composerTargetAction.type):this.tr("workCenter.coordinator","Coordinator")},composerPlaceholder(){return this.composerTargetAction?this.$t("workCenter.actionChatPlaceholder",{name:this.composerTargetLabel}):this.tr("workCenter.conversationPlaceholder","Message about this work item")},composerTargetUnavailable(){return this.coordinatorReadOnly?!0:this.composerTargetIsCoordinator?this.coordinatorThinking:this.composerTargetAction?!this.canMessageAction(this.composerTargetAction):!0},composerCanSend(){return!this.workItemMessageSending&&!this.workItemMessageAttachmentsUploading&&!this.composerTargetUnavailable&&(!!this.workItemMessage.trim()||this.workItemMessageAttachments.length>0)},pendingMessageEnvelope(){return this.selected?.id?this.store.loadWorkCenterMessageEnvelope(this.agentId,this.selected.id):null},composerDraftLocked(){return!!this.pendingMessageEnvelope&&!this.composerTargetIsStale},pendingEnvelopeHasAttachments(){return Array.isArray(this.pendingMessageEnvelope?.attachments)&&this.pendingMessageEnvelope.attachments.length>0},pendingEnvelopeAttachmentRecovery(){return this.composerDraftLocked&&this.pendingEnvelopeHasAttachments},actionMessageKey(){return this.selected?.id&&this.selectedAction?.id?or(this.agentId,this.selected.id,this.selectedAction.id,this.selectedAction.generation):""},workItemComposerScope(){return this.selected?.id?`${this.agentId}:${this.selected.id}:${this.workItemComposerGeneration}`:""},conversationBlocks(){return(Array.isArray(this.selected?.messages)?this.selected.messages:[]).map(e=>{let t=Number(e?.updatedAt||e?.createdAt)||0;if(e?.role==="user")return{key:e.id,kind:"user",message:{id:e.id,messageId:e.id,type:"user",content:e.text||"",attachments:Array.isArray(e.attachments)?e.attachments:[],quote:Mt(e.quote),timestamp:t}};if(e?.role==="assistant"){let s=e.speaker||{},n=this.workItemMessageSpeaker(e),r=s.id||`work-center-coordinator:${this.selected?.id||"unknown"}`,i=e.status==="thinking"?this.tr("workCenter.conversationThinking","Working\u2026"):e.error||"",o=e.decision?.kind&&e.decision.kind!=="answer"?this.tr(`workCenter.coordinatorDecision.${e.decision.kind}`,e.decision.kind):"",a=[e.text,i,o].filter(Boolean);return{key:e.id,kind:"assistant",speakerName:n,turn:{id:e.id,messageId:e.id,atMessageId:e.id,turnId:e.turnId||e.id,textContent:a.join(`
6735
6735
 
6736
- `),textSegments:a.map((l,c)=>({key:`${e.id}:${c}`,content:l,kind:e.status==="thinking"?"progress":"result",isStreaming:e.status==="thinking"})),isStreaming:e.status==="thinking",speakerVpId:r,speakerTimestamp:t,showSpeakerHeader:!0,timestamp:t,createdAt:t,todoMsg:null,toolMsgs:[],toolSummaryCount:0,imageMsgs:[],askMsg:null,attachments:Array.isArray(e.attachments)?e.attachments:[]}}}return{key:e.id,kind:"system",message:e}})},coordinatorThinking(){return(this.selected?.messages||[]).some(e=>e?.role==="assistant"&&e.status==="thinking")},coordinatorReadOnly(){return["done","cancelled"].includes(this.selected?.status)},actionMessages(){let e=Array.isArray(this.selectedAction?.messages)?this.selectedAction.messages:[],t=(Array.isArray(this.selectedAction?.thread)?this.selectedAction.thread:[]).flatMap(o=>Array.isArray(o?.messages)?o.messages:[]),s=this.store.workCenterActionMessages[this.actionMessageKey]?.messages||[],n=di(t,s,e),r=this.selectedAction?.liveMessage,i=r&&n.some(o=>o.role==="assistant"&&o.runId!=null&&o.runId===r.runId&&(r.status==="running"?o.text===r.text:o.status!=="running"));return di(n,i?null:r)},actionMessagesNextCursor(){let e=this.store.workCenterActionMessages[this.actionMessageKey];return e?e.nextCursor:this.selectedAction?.messageCursor},actionMessagesLoading(){return!!this.store.workCenterActionMessagesLoading[this.actionMessageKey]},actionMessagesError(){return this.store.workCenterActionMessagesError[this.actionMessageKey]||""},orderedActions(){let e=Array.isArray(this.selected?.actions)?this.selected.actions:[];return ql(e)},boardLanes(){return[{id:"active",title:this.tr("workCenter.board.active","Active")},{id:"needs_attention",title:this.tr("workCenter.board.needsAttention","Needs attention")},{id:"closed",title:this.tr("workCenter.board.closed","Closed")}].map(e=>({...e,items:this.items.filter(t=>t.boardLane===e.id)}))},boardExecutorOptions(){let e=new Map;for(let t of this.items)for(let s of Array.isArray(t.executors)?t.executors:[])s?.id&&e.set(s.id,s.name||s.id);return[...e.entries()].map(([t,s])=>({id:t,name:s}))},boardTypeOptions(){return[...new Set(this.items.map(e=>e.workItemType).filter(Boolean))].sort()},emptyState(){return{title:this.search.trim()?this.tr("workCenter.noMatchesTitle","No matching work items"):this.tr("workCenter.emptyTitle","No work items yet"),body:this.search.trim()?this.tr("workCenter.noMatchesBody","Try a different search or filter."):this.tr("workCenter.emptyBody","Create a persistent task when work must continue beyond one conversation turn."),canCreate:!this.search.trim()}}},watch:{selectedId(){this.infoTab="requirement"},"workbenchContext.workspaceGeneration"(){this.workbenchExpanded=!1},agents:{immediate:!0,deep:!0,handler(){this.loadUnavailableAgentStates()}},agentId:{immediate:!0,handler(e,t){if(Oa(this),this.createGeneration=(Number(this.createGeneration)||0)+1,this.saving=!1,this.selectedId=null,this.selectedActionId=null,this.contentPanelOpen=!1,this.resetWorkItemComposer?.(),this.resetContentStack?.(),this.composerTargetValue="coordinator",this.narrowPane="items",this.filtersOpen=!1,this.headerMenuOpen=!1,this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1,t&&e!==t&&(this.closeFolderPicker(),this.resetCreateExecutionContext(e)),this.store.workCenterAgentId!==e){this.store.enterWorkCenter(e);return}e&&((typeof this.boardFilters=="function"?this.store.listWorkItems(e,this.boardFilters()):this.store.listWorkItems(e)).catch(()=>{}),this.store.loadWorkCenterSettings(e).catch(()=>{}))}},actionsPaneWidth(e){try{localStorage.setItem("work-center-actions-width",String(e))}catch{}},createDefaultWorkDir(){this.applyCreateDefaults()},createDefaultStart(){this.applyCreateDefaults()},search(){this.scheduleBoardQuery()},boardVpId(){this.scheduleBoardQuery()},boardWorkItemType(){this.scheduleBoardQuery()},boardUpdatedRange(){this.scheduleBoardQuery()},"detail.coordinatorRevision"(){this.$nextTick(()=>{let e=this.$el?.querySelector?.(".work-center-conversation-scroll");e&&(e.scrollTop=e.scrollHeight)})},pendingMessageEnvelope(e,t){if(!(!t||e||t.workItemId!==this.selectedId)){if(this.preserveComposerOnEnvelopeClear){this.preserveComposerOnEnvelopeClear=!1,this.workItemMessageError="",this.workItemMessageSending=!1;return}this.workItemMessage="",this.workItemMessageQuote=null,this.workItemMessageAttachments=[],this.workItemMessageError="",this.workItemMessageSending=!1}},detail:{deep:!0,handler(e){if(!e||e.id!==this.selectedId)return;let t=Array.isArray(e.actions)?e.actions:[];this.selectedActionId&&!t.some(s=>s.id===this.selectedActionId)&&(this.selectedActionId=null,this.contentPanelOpen=!1,this.resetContentStack(),this.syncWorkCenterUrl(!0),this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1),this.composerTargetAction==null&&this.composerTargetValue!=="coordinator"?this.staleComposerTarget=this.composerTargetValue:this.staleComposerTarget=null}}},beforeUnmount(){Oa(this),this.unavailableAgentStateGeneration+=1,this.boardQueryTimer&&clearTimeout(this.boardQueryTimer),clearInterval(this.actionClockTimer),window.removeEventListener("popstate",this.restoreWorkCenterUrl),document.removeEventListener("click",this.closeHeaderPopovers),this.navigationMedia?.removeEventListener("change",this.onNavigationResize)},mounted(){this.actionClockTimer=setInterval(()=>{this.actionNowMs=Date.now()},1e3),this.returnFocusElement=document.activeElement,this.navigationMedia=window.matchMedia("(max-width: 1100px)"),this.navigationMedia.addEventListener("change",this.onNavigationResize),this.$nextTick(()=>this.focusNavigationReturn()),window.addEventListener("popstate",this.restoreWorkCenterUrl),document.addEventListener("click",this.closeHeaderPopovers),this.restoreWorkCenterUrl();let e=this.store.workCenterCreateDraft;e&&(this.form={requirement:e.requirement||e.goal||e.title||"",workDir:e.workDir||"",deliveryTarget:e.deliveryTarget||"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.createOpen=!0,this.workDirTouched=!!String(e.workDir||"").trim(),this.startTouched=!1,this.applyCreateDefaults())},methods:{selectInfoTab(e){this.infoTab=e,this.$nextTick(()=>{let t=this.$refs.shell?.querySelector(`#work-item-info-panel-${e}`);t&&(t.scrollTop=0)})},onInfoTabKeydown(e,t){let s=this.infoTabs.map(r=>r.id),n=s.indexOf(t);if(e.key==="ArrowRight")n=(n+1)%s.length;else if(e.key==="ArrowLeft")n=(n+s.length-1)%s.length;else if(e.key==="Home")n=0;else if(e.key==="End")n=s.length-1;else return;e.preventDefault(),this.selectInfoTab(s[n]),this.$nextTick(()=>this.$refs.shell?.querySelector(`#work-item-info-tab-${s[n]}`)?.focus())},onNavigationResize(e){this.mobileNavigation=e.matches,this.sidebarExpanded=!e.matches},toggleNavigation(){this.sidebarExpanded=!this.sidebarExpanded,this.$nextTick(()=>this.sidebarExpanded&&this.mobileNavigation?this.$refs.navigation?.focusReturn():this.focusNavigationReturn())},focusNavigationReturn(){this.mobileNavigation?[...this.$refs.header?.querySelectorAll(".work-center-navigation-toggle")||[]].find(e=>e.getClientRects().length)?.focus({preventScroll:!0}):this.$refs.navigation?.focusReturn()},async selectActivity({item:e,actionId:t}){let s=this.agentId;if(await this.selectItem(e),!(this.agentId!==s||this.selectedId!==e.id||this.detailError)&&t){let n=this.selected?.actions?.find(r=>r.id===t);n&&this.selectAction(n)}},toggleWorkbench(){this.$refs.workbench?.toggle()},canOpenOutput(e){return this.workbenchContext.available&&this.store.hasAgentCapability(this.agentId,"file_editor")&&Md(e,this.workbenchContext.ownerWorkDir)?.type==="file"},openOutput(e){this.canOpenOutput(e)&&this.workbenchContext.openOutput(e)},closeHeaderPopovers(e){e?.target?.closest?.(".work-center-filter-menu, .work-center-search")||(this.filtersOpen=!1),e?.target?.closest?.(".work-center-header-menu")||(this.headerMenuOpen=!1)},backToChat(){this.store.leaveWorkCenter(),this.$nextTick(()=>{let e=this.returnFocusElement,t=n=>n?.isConnected&&n.getClientRects().length&&getComputedStyle(n).visibility!=="hidden"&&n.getBoundingClientRect().right>0;(t(e)&&e!==document.body?e:[...document.querySelectorAll(".sidebar-work-center-trigger, .header-sidebar-toggle, .yeaft-topbar-sidebar-toggle")].find(t))?.focus({preventScroll:!0})})},tr(e,t){let s=this.$t?this.$t(e):e;return s&&s!==e?s:t},async loadUnavailableAgentStates(){let e=++this.unavailableAgentStateGeneration,t=this.agents.filter(r=>r?.online&&r.capabilities?.includes("work_center_feature_settings")&&!r.capabilities.includes("work_center")&&(this.store.workCenterFeatureSettingsByAgent?.[r.id]?.loaded!==!0||this.store.workCenterFeatureSettingsByAgent?.[r.id]?.error));if(this.unavailableAgentStateLoading=t.length>0,this.unavailableAgentStateError="",t.length===0)return;let s=await Promise.allSettled(t.map(r=>this.store.loadWorkCenterFeatureSettings(r.id)));if(e!==this.unavailableAgentStateGeneration)return;let n=s.filter(r=>r.status==="rejected");this.unavailableAgentStateError=n.length?n[0].reason?.message||this.tr("workCenter.agentStatusLoadFailed","Could not check Work Center status."):"",this.unavailableAgentStateLoading=!1},openWorkCenterAgentSettings(){let e=this.configurableDisabledAgents[0]||this.configurableUnavailableAgents[0]||this.agents.find(t=>t?.online)||null;this.agentSettingsTargetId=e?.id||null,this.agentSettingsOpen=!0},closeWorkCenterAgentSettings({focusBack:e=!1}={}){this.agentSettingsOpen=!1,e&&this.$nextTick(()=>this.focusNavigationReturn())},selectWorkCenterAgent(e){if(this.mobileNavigation&&(this.sidebarExpanded=!1),!e||e===this.agentId){this.showItemsPane();return}this.saveComposerDraft(),this.showItemsPane(),this.store.enterWorkCenter(e)},statusLabel(e){return this.tr(`workCenter.status.${e}`,String(e||"").replace("_"," "))},goalStatusLabel(e){return this.tr(`workCenter.goalStatus.${e}`,this.statusLabel(e))},deliveryTargetLabel(e){let t={response:"Response",workspace_files:"Files",pull_request:"Pr",merge:"Merge"};return t[e]?this.tr(`workCenter.deliveryTarget${t[e]}`,e):e||this.tr("workCenter.deliveryTargetAsk","Ask me before delivery")},actionLabel(e){return this.tr(`workCenter.action.${e}`,e||"\u2014")},messageSpeakerRole(e,t){return e?this.$t("workCenter.messageSpeakerRole",{name:e,role:t}):t},workItemMessageSpeaker(e){if(e?.role==="user")return this.tr("workCenter.you","You");if(e?.role==="legacy_instruction")return this.tr("workCenter.originalRequest","Original request");let t=e?.speaker?.name||e?.speaker?.id||"";return this.messageSpeakerRole(t,this.tr("workCenter.coordinator","Coordinator"))},quoteWorkItemMessage(e){if(this.coordinatorReadOnly)return;let t=Mt(e);t&&(this.workItemMessageQuote=t,this.saveComposerDraft(),this.$nextTick(()=>this.$refs.workItemComposer?.getTextarea?.()?.focus?.()))},removeWorkItemMessageQuote(){this.workItemMessageQuote=null,this.saveComposerDraft()},editWorkItemMessageAsNew(e){this.coordinatorReadOnly||(this.workItemMessageQuote=null,this.workItemMessage=String(e||""),this.saveComposerDraft(),this.$nextTick(()=>{let t=this.$refs.workItemComposer?.getTextarea?.();t?.focus?.();let s=t?.value?.length||0;t?.setSelectionRange?.(s,s)}))},openConversationAttachment(e){return this.previewAttachment(e?.attachment||e,e?.trigger||null)},actionSequence(e){let t=Number(e?.sequence);if(Number.isFinite(t)&&t>0)return t;let n=(Array.isArray(this.selected?.actions)?this.selected.actions:[]).findIndex(r=>r?.id===e?.id);return n>=0?n+1:1},actionBreadcrumbDescription(e){return String(e?.brief?.objective||e?.objective||this.actionContentSummary(e)||"").trim().replace(/\s+/g," ")||this.tr("workCenter.untitledAction","Untitled Action")},itemActionProgress(e){let t=Math.max(0,Number(e?.actionCount)||0),s=Math.min(t,Math.max(0,Number(e?.completedActionCount)||0));return this.$t("workCenter.actionProgress",{completed:s,total:t})},actionDuration(e){let t=e?.executionDurationMs;if(!Number.isFinite(t)||t<0)return"\u2014";let s=e.executionStartedAt,n=e.status==="running"&&Number.isFinite(s)&&s>0?Math.max(0,this.actionNowMs-s):0;return Ai(t+n)||"\u2014"},time(e){if(!e)return"";try{return new Date(Number(e)).toLocaleString()}catch{return""}},onWorkItemMessageInput(){this.saveComposerDraft()},onWorkItemMessageKeydown(e){e.key!=="Enter"||e.shiftKey||e.isComposing||(e.preventDefault(),this.sendSelectedWorkItemMessage())},boardFilters(){let e=Date.now(),t=this.boardUpdatedRange==="day"?e-1440*60*1e3:this.boardUpdatedRange==="week"?e-10080*60*1e3:this.boardUpdatedRange==="month"?e-720*60*60*1e3:null;return{keyword:this.search.trim(),vpId:this.boardVpId,workItemType:this.boardWorkItemType,updatedFrom:t,limit:200}},scheduleBoardQuery(){this.boardQueryTimer&&clearTimeout(this.boardQueryTimer),this.boardQueryTimer=setTimeout(()=>{this.boardQueryTimer=null,this.agentId&&this.refresh()},180)},refresh(){return this.agentId?this.store.listWorkItems(this.agentId,this.boardFilters()).catch(()=>{}):Promise.resolve([])},refreshWorkCenterRuntime(e){if(!(!e||e!==this.agentId))return this.store.refreshWorkCenterRuntime(e).catch(()=>{})},loadMoreBoardItems(){return this.store.loadMoreWorkItems(this.agentId).catch(()=>{})},boardAction(e){return e.attentionAction||e.activeAction||e.currentAction||null},boardActionCountLabel(e){let t=e.actionCounts||{},s=[];for(let n of["running","failed","waiting","ready"])Number(t[n])>0&&s.push(`${t[n]} ${this.statusLabel(n)}`);return s.join(" \xB7 ")||this.itemActionProgress(e)},boardExecutorLabel(e){let t=Array.isArray(e.executors)?e.executors:[];if(t.length>0)return t.map(n=>n.name||n.id).join(", ");let s=this.boardAction(e);return s?.assignedVp?.name||s?.assignedVp?.id||this.tr("workCenter.assignment.planned","Planned assignment")},sameContentRef(e,t){return e?.type===t?.type&&e?.actionId===t?.actionId&&e?.runId===t?.runId&&e?.resourceId===t?.resourceId},resetContentStack(e=[{type:"action-list"}]){let t=Array.isArray(e)?e:[e],s=t[0]?.type==="action-list"?t:[{type:"action-list"},...t];this.contentStack=s.length>0?s:[{type:"action-list"}];let n=[...this.contentStack].reverse().find(r=>r.type==="action");this.selectedActionId=this.contentRef.actionId||n?.actionId||null},openContentPanel({syncUrl:e=!0}={}){this.contentPanelOpen=!0,e&&this.syncWorkCenterUrl(),this.$nextTick(()=>{this.$refs.actionsButton?.getClientRects().length||this.$refs.contentClose?.focus({preventScroll:!0})})},closeContentPanel({syncUrl:e=!0}={}){this.contentPanelOpen=!1,this.resetContentStack(),e&&this.syncWorkCenterUrl(),this.$nextTick(()=>this.$refs.actionsButton?.focus?.())},pushContentRef(e,{replace:t=!1,syncUrl:s=!0}={}){let n=this.contentRef;if(this.contentPanelOpen=!0,this.sameContentRef(n,e)){s&&this.syncWorkCenterUrl(t);return}this.contentStack=e.type==="action-list"?[{type:"action-list"}]:[...this.contentStack,e],this.selectedActionId=e.actionId||this.selectedActionId,s&&this.syncWorkCenterUrl(t)},popContentRef(){if(this.contentStack.length<=1)return;this.contentStack=this.contentStack.slice(0,-1);let e=[...this.contentStack].reverse().find(t=>t.type==="action");this.selectedActionId=e?.actionId||null,this.syncWorkCenterUrl()},contentRefParam(e){return e.type==="action"&&e.actionId?`action:${e.actionId}`:e.type==="run"&&e.actionId&&e.runId?`run:${e.actionId}:${e.runId}`:e.type==="attachment"&&e.resourceId?`attachment:${e.actionId||"-"}:${e.resourceId}`:"action-list"},contentStackParam(){return this.contentStack.map(e=>this.contentRefParam(e)).join("/")},parseContentRef(e){let t=String(e||"");if(t==="action-list")return{type:"action-list"};if(t.startsWith("action:"))return{type:"action",actionId:t.slice(7)};if(t.startsWith("run:")){let[,s,n]=t.split(":");return{type:"run",actionId:s,runId:n}}if(t.startsWith("attachment:")){let[,s,n]=t.split(":");return{type:"attachment",actionId:s==="-"?null:s,resourceId:n}}return{type:"action-list"}},parseContentStack(e){let s=[...String(e||"").split("/").filter(Boolean).map(n=>this.parseContentRef(n))].reverse().find(n=>n.actionId&&["action","run","attachment"].includes(n.type));return s?[{type:"action-list"},{type:"action",actionId:s.actionId}]:[{type:"action-list"}]},workCenterUrlRoute(){let e=new URLSearchParams(window.location.search);return{agentId:e.get("workAgentId"),itemId:e.get("workItemId"),content:e.has("workContent")?e.get("workContent"):null}},sameWorkCenterUrlRoute(e,t){return e?.agentId===t?.agentId&&e?.itemId===t?.itemId&&e?.content===t?.content},syncWorkCenterUrl(e=!1){Oa(this);let t=new URL(window.location.href);this.selectedId?(t.searchParams.set("workAgentId",this.agentId||""),t.searchParams.set("workItemId",this.selectedId),t.searchParams.set("workContent",this.contentPanelOpen?this.contentStackParam():"none")):(t.searchParams.delete("workAgentId"),t.searchParams.delete("workItemId"),t.searchParams.delete("workContent"));let s=`${t.pathname}${t.search}${t.hash}`;if(`${window.location.pathname}${window.location.search}${window.location.hash}`===s)return;let n={...window.history.state,workCenter:!!this.selectedId,workCenterContent:!!this.selectedId&&this.contentPanelOpen};window.history[e?"replaceState":"pushState"](n,"",s)},async restoreWorkCenterUrl(){let e=Oa(this),t=this.workCenterUrlRoute(),s=()=>e===this.workCenterUrlRestoreGeneration&&this.sameWorkCenterUrlRoute(t,this.workCenterUrlRoute()),n=t.agentId,r=t.itemId;if(!r||n&&n!==this.agentId){this.selectedId&&this.showItemsPane({syncUrl:!1});return}let i=t.content==null?(this.$refs.shell?.clientWidth||window.innerWidth)>900:t.content!=="none",o=this.parseContentStack(t.content),a=o.at(-1);if(this.selectedId!==r||this.detail?.id!==r){this.openWorkItem(r,{syncUrl:!1,contentRefs:o,contentOpen:i}),this.detailLoading=!0;try{await this.store.getWorkItem(r,this.agentId)}catch(c){s()&&(this.detailError=c?.message||String(c))}finally{s()&&(this.detailLoading=!1)}}if(!s())return;let l=a.actionId||[...o].reverse().find(c=>c.type==="action")?.actionId;if(l&&!this.selected?.actions?.some(c=>c.id===l)){this.resetContentStack(),this.syncWorkCenterUrl(!0);return}this.resetContentStack(o),this.contentPanelOpen=i,this.narrowPane="work-item",i&&l&&this.loadLatestActionMessages(this.selectedAction),i&&t.content!==this.contentStackParam()&&this.syncWorkCenterUrl(!0)},resetWorkItemComposer(){this.workItemComposerGeneration+=1,this.workItemMessage="",this.workItemMessageQuote=null,this.workItemMessageAttachments=[],this.workItemMessageAttachmentsUploading=!1,this.workItemMessageError="",this.workItemMessageSending=!1},draftTarget(){let e=this.composerTargetAction;return e?{kind:"action",actionId:e.id,generation:Number(e.generation)}:this.composerTargetValue==="coordinator"?{kind:"coordinator"}:(()=>{let[,t="",s="0"]=this.composerTargetValue.split(":");return{kind:"action",actionId:t,generation:Number(s)||0}})()},targetValue(e){return typeof e=="string"&&e.startsWith("action:")?e:e?.kind==="action"?`action:${e.actionId}:${e.generation}`:"coordinator"},saveComposerDraft(){!this.selectedId||!this.agentId||this.store.saveWorkCenterComposerDraft(this.agentId,this.selectedId,{text:this.workItemMessage,quote:this.workItemMessageQuote,attachments:[...this.workItemMessageAttachments],target:this.draftTarget(),error:this.workItemMessageError})},restoreComposerDraft(e){let s=this.store.loadWorkCenterMessageEnvelope(this.agentId,e)||this.store.loadWorkCenterComposerDraft(this.agentId,e);this.workItemMessage=s?.text||"",this.workItemMessageQuote=Mt(s?.quote),this.workItemMessageAttachments=[...s?.attachments||[]],this.composerTargetValue=this.targetValue(s?.target),this.workItemMessageError=s?.error||"",this.staleComposerTarget=null,this.workItemMessageSending=!1,this.workItemMessageAttachmentsUploading=!1,this.workItemComposerGeneration+=1},openWorkItem(e,{syncUrl:t=!0,contentRefs:s=[{type:"action-list"}],contentOpen:n=(this.$refs.shell?.clientWidth||window.innerWidth)>900}={}){this.saveComposerDraft(),this.selectedId=e,this.narrowPane="work-item",this.contentPanelOpen=n,this.resetContentStack(s),this.restoreComposerDraft(e),this.detailError="",this.detailLoading=!1,this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1,t&&this.syncWorkCenterUrl()},async selectItem(e){this.mobileNavigation&&(this.sidebarExpanded=!1),this.openWorkItem(e.id),this.detailLoading=!0;try{await this.store.getWorkItem(e.id,this.agentId)}catch(t){this.selectedId===e.id&&(this.detailError=t?.message||String(t))}finally{this.selectedId===e.id&&(this.detailLoading=!1)}},selectAction(e){this.selectedActionId!==e.id&&(this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1),this.pushContentRef({type:"action",actionId:e.id}),this.loadLatestActionMessages(e),this.$nextTick(()=>this.$refs.actionBack?.focus({preventScroll:!0}))},loadLatestActionMessages(e=this.selectedAction){if(!this.selected?.id||!e?.id||Array.isArray(e.messages))return null;let t=or(this.agentId,this.selected.id,e.id,e.generation);return this.store.workCenterActionMessages[t]?null:this.store.loadWorkItemActionMessages(this.selected.id,e.id,e.generation,null,this.agentId).catch(()=>null)},showItemsPane({syncUrl:e=!0}={}){this.saveComposerDraft(),this.narrowPane="items",this.selectedId=null,this.contentPanelOpen=!1,this.resetContentStack(),this.composerTargetValue="coordinator",this.resetWorkItemComposer(),e&&this.syncWorkCenterUrl()},showActionsPane(){this.contentPanelOpen=!0,this.contentIsActionList?this.syncWorkCenterUrl():this.popContentRef(),this.$nextTick(()=>this.$refs.contentClose?.focus({preventScroll:!0}))},canMessageAction(e){return!e||["done","cancelled"].includes(this.selected?.status)?!1:["idle","ready","running","paused","waiting","failed","completed","stopped"].includes(e.status)&&e.admissionStatus!=="blocked"},clearPendingMessageEnvelope({preserveAttachments:e=!1}={}){return!this.selectedId||!this.pendingMessageEnvelope?!1:(this.actionInputRequestGeneration=(Number(this.actionInputRequestGeneration)||0)+1,this.preserveComposerOnEnvelopeClear=!0,this.store.discardWorkCenterMessageEnvelope(this.agentId,this.selectedId)?(e||(this.workItemMessageAttachments=[]),this.workItemMessageError="",this.workItemMessageSending=!1,!0):(this.preserveComposerOnEnvelopeClear=!1,!1))},chooseCoordinatorTarget(){this.pendingMessageEnvelope&&!this.clearPendingMessageEnvelope({preserveAttachments:!0})||(this.composerTargetValue="coordinator",this.staleComposerTarget=null,this.saveComposerDraft())},onComposerTargetChange(){this.pendingMessageEnvelope&&!this.clearPendingMessageEnvelope({preserveAttachments:!0})||(this.staleComposerTarget=this.composerTargetAction==null&&this.composerTargetValue!=="coordinator"?this.composerTargetValue:null,this.saveComposerDraft())},loadEarlierActionMessages(){return!this.selected?.id||!this.selectedAction?.id||this.actionMessagesNextCursor==null?null:this.store.loadWorkItemActionMessages(this.selected.id,this.selectedAction.id,this.selectedAction.generation,this.actionMessagesNextCursor,this.agentId).catch(()=>null)},actionExecutor(e){return e?.assignedVp?.name||e?.assignedVp?.id||e?.requiredRole||e?.assignmentPolicy?.fixedVpId||e?.assignmentPolicy?.capability||this.tr("workCenter.assignment.auto","Auto")},actionContentSummary(e){return String(e?.contentSummary||e?.response||e?.brief?.objective||"").trim()},executionStats(e){return e?.executionStats||{}},formatCount(e){return new Intl.NumberFormat().format(Math.max(0,Number(e)||0))},formatTokens(e){let t=Math.max(0,Number(e)||0);return t>=1e6?`${(t/1e6).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)},resetCreateExecutionContext(e){let t=this.workDirTouched||this.startTouched,s=this.store.workCenterCreateDraft;s&&(this.store.workCenterCreateDraft={sourceAgentId:e||null,requirement:s.requirement||s.goal||s.title||"",workDir:"",deliveryTarget:s.deliveryTarget||"",origin:null,linkedSessionIds:[]}),this.form.workDir="",this.form.start=!0,this.workDirTouched=!1,this.startTouched=!1,t&&(this.createOpen=!1),this.applyCreateDefaults()},applyCreateDefaults(){this.createOpen&&(!this.workDirTouched&&!this.form.workDir.trim()&&(this.form.workDir=this.createDefaultWorkDir),this.startTouched||(this.form.start=this.createDefaultStart))},folderPickerInitialDir(){return this.form.workDir.trim()||this.createDefaultWorkDir},folderPickerSetWorkDir(e){this.form.workDir=e,this.workDirTouched=!0},onCreateWorkDirInput(){this.workDirTouched=!0},onCreateStartInput(){this.startTouched=!0},async onCreateAttachmentInput(e){if(!this.workItemAttachmentsSupported)throw e.target.value="",new Error(this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments."));let t=Array.from(e.target.files||[]);if(e.target.value="",t.length===0)return;let s=Math.max(0,10-this.createAttachments.length),n=t.slice(0,s);if(n.length!==0){this.attachmentsUploading=!0;try{let r=new FormData;for(let d of n)r.append("files",d,d.name||"attachment");let i=Pinia.useAuthStore(),o=i.getActiveToken?.()||i.token||null,a=o?{Authorization:`Bearer ${o}`}:{},l=await fetch("/api/upload",{method:"POST",headers:a,body:r});if(!l.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let c=await l.json();this.createAttachments=[...this.createAttachments,...Array.isArray(c.files)?c.files:[]].slice(0,10)}finally{this.attachmentsUploading=!1}}},removeCreateAttachment(e){this.createAttachments=this.createAttachments.filter((t,s)=>s!==e)},discardPendingMessageEnvelope(){this.clearPendingMessageEnvelope()&&this.saveComposerDraft()},async onWorkItemMessageAttachmentInput(e){if(!this.workItemAttachmentsSupported){e.target.value="",this.workItemMessageError=this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments.");return}let t=Array.from(e.target.files||[]);if(e.target.value="",t.length===0)return;let s=this.workItemComposerScope;if(!s)return;let n=this.pendingEnvelopeAttachmentRecovery,r=Array.isArray(this.selected?.attachments)?this.selected.attachments.length:0,i=Math.max(0,10-r-(n?0:this.workItemMessageAttachments.length)),o=t.slice(0,i);if(o.length!==0){this.workItemMessageAttachmentsUploading=!0,this.workItemMessageError="";try{let a=new FormData;for(let f of o)a.append("files",f,f.name||"attachment");let l=Pinia.useAuthStore(),c=l.getActiveToken?.()||l.token||null,d=c?{Authorization:`Bearer ${c}`}:{},u=await fetch("/api/upload",{method:"POST",headers:d,body:a});if(!u.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let g=await u.json();if(this.workItemComposerScope!==s)return;let p=(Array.isArray(g.files)?g.files:[]).slice(0,Math.max(0,10-r));if(n){let f=this.store.replaceWorkCenterMessageEnvelopeAttachments(this.agentId,this.selectedId,p);if(!f)throw new Error(this.tr("workCenter.pendingEnvelopeChanged","The pending request changed; reopen this Work Item and try again."));this.workItemMessageAttachments=[...f.attachments],this.workItemMessageError=""}else this.workItemMessageAttachments=[...this.workItemMessageAttachments,...p].slice(0,Math.max(0,10-r)),this.saveComposerDraft()}catch(a){this.workItemComposerScope===s&&(this.workItemMessageError=a?.message||String(a))}finally{this.workItemComposerScope===s&&(this.workItemMessageAttachmentsUploading=!1)}}},removeWorkItemMessageAttachment(e){this.workItemMessageAttachments=this.workItemMessageAttachments.filter((t,s)=>s!==e),this.saveComposerDraft()},async previewAttachment(e,t=null){if(!this.selected?.id||!e?.id||this.previewingAttachmentId)return;let s=this.agentId,n=this.selected.id,r=this.selectedActionId||"",i=`${s}:${n}:${r}`,o=(Number(this.attachmentPreviewGeneration)||0)+1;this.attachmentPreviewGeneration=o;let a=()=>this.attachmentPreviewGeneration===o&&`${this.agentId}:${this.selected?.id||""}:${this.selectedActionId||""}`===i,l=e.isImage?null:window.open("","_blank");if(!e.isImage&&!l){this.attachmentPreviewError=this.tr("workCenter.attachmentOpenBlocked","The browser blocked the attachment window. Allow pop-ups and try again.");return}l&&(l.opener=null),this.previewingAttachmentId=e.id,this.attachmentPreviewError="";try{let c=await this.store.previewWorkItemAttachment(n,e.id,s);if(!a()){l?.close();return}c?.preview&&c.attachment?.isImage?Fs(c.preview,{alt:e.name||this.tr("workCenter.previewAttachment","Open attachment"),closeLabel:this.tr("common.close","Close"),trigger:t}):c?.preview&&l?l.location.replace(c.preview):l?.close()}catch(c){l?.close(),a()&&(this.attachmentPreviewError=c?.message||this.tr("workCenter.attachmentPreviewFailed","Could not open the attachment. Try again."))}finally{a()&&(this.previewingAttachmentId=null)}},isExternalOutput(e){return["link","pr"].includes(e?.kind)&&/^https?:\/\//i.test(String(e?.ref||""))},formatAttachmentSize(e){let t=Math.max(0,Number(e)||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`},openCreate(){this.createOpen=!0,this.workDirTouched=!1,this.startTouched=!1,this.applyCreateDefaults()},closeCreate(){this.saving||(this.closeFolderPicker(),this.createOpen=!1,this.store.workCenterCreateDraft=null)},async submitCreate(){let e=String(this.form.requirement||this.form.goal||this.form.title||"").trim();if(!e||!this.form.workDir.trim())return;let t=this.agentId,s=(Number(this.createGeneration)||0)+1;this.createGeneration=s,this.saving=!0;try{let n=this.store.workCenterCreateDraft,r=n?.sourceAgentId===t,i=await this.store.createWorkItem({requirement:e,title:e.replace(/\s+/g," ").slice(0,80),titleSource:"coordinator_pending",goal:e,acceptanceCriteria:[],workItemType:"auto",workDir:this.form.workDir.trim(),deliveryTarget:this.form.deliveryTarget||null,origin:r&&n.origin||null,linkedSessionIds:r?n.linkedSessionIds||[]:[],attachments:this.workItemAttachmentsSupported?(this.createAttachments||[]).map(o=>({fileId:o.fileId,name:o.name,mimeType:o.mimeType,size:o.size})):[],reuseMemory:this.form.reuseMemory,start:this.form.start},t);if(this.agentId!==t||this.createGeneration!==s)return;this.openWorkItem(i.id),this.form={requirement:"",workDir:"",deliveryTarget:"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.store.workCenterCreateDraft=null,this.createAttachments=[],this.workDirTouched=!1,this.startTouched=!1,this.createOpen=!1}finally{this.agentId===t&&this.createGeneration===s&&(this.saving=!1)}},async startSelected(){this.selected&&await this.store.startWorkItem(this.selected.id,this.agentId)},async sendSelectedWorkItemMessage(){if(!this.selected||!this.composerCanSend)return;let e=this.workItemComposerScope,t=this.composerTargetValue,s=this.composerTargetAction;if(!this.composerTargetIsCoordinator&&!s)return;let n=this.selected.id,r=this.selected.revision,i=this.workItemMessage.trim(),o=Mt(this.workItemMessageQuote),a=this.workItemMessageAttachments.map(c=>({fileId:c.fileId,name:c.name,mimeType:c.mimeType,size:c.size})),l=(Number(this.actionInputRequestGeneration)||0)+1;this.actionInputRequestGeneration=l,this.workItemMessageSending=!0,this.workItemMessageError="",this.saveComposerDraft();try{let c={planRevision:this.selected.planRevision,ledgerRevision:this.selected.ledgerRevision,coordinatorRevision:this.selected.coordinatorRevision};this.canonicalMessageWireSupported?await this.store.postWorkItemMessage(n,i,s?{kind:"action",actionId:s.id,generation:s.generation}:{kind:"coordinator"},r,a,this.agentId,c,o):s?await this.store.sendWorkItemActionInput(n,i,s.id,r,s.generation,a,this.agentId,o):await this.store.sendWorkItemMessage(n,i,r,a,this.agentId,c,o),this.workItemComposerScope===e&&this.actionInputRequestGeneration===l&&this.composerTargetValue===t&&this.workItemMessage.trim()===i&&!this.store.loadWorkCenterMessageEnvelope(this.agentId,n)&&(this.workItemMessage="",this.workItemMessageQuote=null,this.workItemMessageAttachments=[],this.store.removeWorkCenterComposerDraft(this.agentId,n))}catch(c){this.workItemComposerScope===e&&this.actionInputRequestGeneration===l&&(this.workItemMessageError=c?.message||String(c),this.saveComposerDraft())}finally{this.workItemComposerScope===e&&this.actionInputRequestGeneration===l&&(this.workItemMessageSending=!1)}},workItemCanDelete(e){return["done","cancelled","draft","needs_attention"].includes(e?.status)},workItemDeleting(e){return!!this.deletingWorkItemIds[e?.id]},async deleteWorkItem(e){if(!e||this.workItemDeleting(e))return;let t=this.tr("workCenter.deleteConfirm","Permanently delete this Work Item, its execution history, and attachments?");if(await We(t,{destructive:!0})){this.deleteWorkItemError="",this.deletingWorkItemIds={...this.deletingWorkItemIds,[e.id]:!0};try{let s=await this.store.deleteWorkItem(e.id,e.revision,this.agentId);s?.cleanupWarning&&(this.deleteWorkItemError=s.cleanupWarning),this.selectedId===e.id&&this.showItemsPane()}catch(s){this.deleteWorkItemError=s?.message||String(s)}finally{let s={...this.deletingWorkItemIds};delete s[e.id],this.deletingWorkItemIds=s}}},async cancelSelected(){if(!this.selected||["done","cancelled"].includes(this.selected.status))return;let e=this.tr("workCenter.cancelConfirm","Stop this work item and its unfinished Actions?");await We(e,{destructive:!0})&&await this.store.cancelWorkItem(this.selected.id,this.agentId)},async resumeSelected(){!this.selected||this.selected.status!=="cancelled"||await this.store.resumeWorkItem(this.selected.id,this.selected.revision,this.agentId,this.selected.executionControl?.revision)}},template:`
6736
+ `),textSegments:a.map((l,c)=>({key:`${e.id}:${c}`,content:l,kind:e.status==="thinking"?"progress":"result",isStreaming:e.status==="thinking"})),isStreaming:e.status==="thinking",speakerVpId:r,speakerTimestamp:t,showSpeakerHeader:!0,timestamp:t,createdAt:t,todoMsg:null,toolMsgs:[],toolSummaryCount:0,imageMsgs:[],askMsg:null,attachments:Array.isArray(e.attachments)?e.attachments:[]}}}return{key:e.id,kind:"system",message:e}})},coordinatorThinking(){return(this.selected?.messages||[]).some(e=>e?.role==="assistant"&&e.status==="thinking")},coordinatorReadOnly(){return["done","cancelled"].includes(this.selected?.status)},actionMessages(){let e=Array.isArray(this.selectedAction?.messages)?this.selectedAction.messages:[],t=(Array.isArray(this.selectedAction?.thread)?this.selectedAction.thread:[]).flatMap(o=>Array.isArray(o?.messages)?o.messages:[]),s=this.store.workCenterActionMessages[this.actionMessageKey]?.messages||[],n=di(t,s,e),r=this.selectedAction?.liveMessage,i=r&&n.some(o=>o.role==="assistant"&&o.runId!=null&&o.runId===r.runId&&(r.status==="running"?o.text===r.text:o.status!=="running"));return di(n,i?null:r)},actionMessagesNextCursor(){let e=this.store.workCenterActionMessages[this.actionMessageKey];return e?e.nextCursor:this.selectedAction?.messageCursor},actionMessagesLoading(){return!!this.store.workCenterActionMessagesLoading[this.actionMessageKey]},actionMessagesError(){return this.store.workCenterActionMessagesError[this.actionMessageKey]||""},orderedActions(){let e=Array.isArray(this.selected?.actions)?this.selected.actions:[];return ql(e)},boardLanes(){return[{id:"active",title:this.tr("workCenter.board.active","Active")},{id:"needs_attention",title:this.tr("workCenter.board.needsAttention","Needs attention")},{id:"closed",title:this.tr("workCenter.board.closed","Closed")}].map(e=>({...e,items:this.items.filter(t=>t.boardLane===e.id)}))},boardExecutorOptions(){let e=new Map;for(let t of this.items)for(let s of Array.isArray(t.executors)?t.executors:[])s?.id&&e.set(s.id,s.name||s.id);return[...e.entries()].map(([t,s])=>({id:t,name:s}))},boardTypeOptions(){return[...new Set(this.items.map(e=>e.workItemType).filter(Boolean))].sort()},emptyState(){return{title:this.search.trim()?this.tr("workCenter.noMatchesTitle","No matching work items"):this.tr("workCenter.emptyTitle","No work items yet"),body:this.search.trim()?this.tr("workCenter.noMatchesBody","Try a different search or filter."):this.tr("workCenter.emptyBody","Create a persistent task when work must continue beyond one conversation turn."),canCreate:!this.search.trim()}}},watch:{selectedId(){this.infoTab="requirement"},"workbenchContext.workspaceGeneration"(){this.workbenchExpanded=!1},agents:{immediate:!0,deep:!0,handler(){this.loadUnavailableAgentStates()}},agentId:{immediate:!0,handler(e,t){if(Oa(this),this.createGeneration=(Number(this.createGeneration)||0)+1,this.createAttachmentUploadCount=0,this.attachmentsUploading=!1,this.saving=!1,this.selectedId=null,this.selectedActionId=null,this.contentPanelOpen=!1,this.resetWorkItemComposer?.(),this.resetContentStack?.(),this.composerTargetValue="coordinator",this.narrowPane="items",this.filtersOpen=!1,this.headerMenuOpen=!1,this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1,t&&e!==t&&(this.closeFolderPicker(),this.resetCreateExecutionContext(e)),this.store.workCenterAgentId!==e){this.store.enterWorkCenter(e);return}e&&((typeof this.boardFilters=="function"?this.store.listWorkItems(e,this.boardFilters()):this.store.listWorkItems(e)).catch(()=>{}),this.store.loadWorkCenterSettings(e).catch(()=>{}))}},actionsPaneWidth(e){try{localStorage.setItem("work-center-actions-width",String(e))}catch{}},createDefaultWorkDir(){this.applyCreateDefaults()},createDefaultStart(){this.applyCreateDefaults()},search(){this.scheduleBoardQuery()},boardVpId(){this.scheduleBoardQuery()},boardWorkItemType(){this.scheduleBoardQuery()},boardUpdatedRange(){this.scheduleBoardQuery()},"detail.coordinatorRevision"(){this.$nextTick(()=>{let e=this.$el?.querySelector?.(".work-center-conversation-scroll");e&&(e.scrollTop=e.scrollHeight)})},pendingMessageEnvelope(e,t){if(!(!t||e||t.workItemId!==this.selectedId)){if(this.preserveComposerOnEnvelopeClear){this.preserveComposerOnEnvelopeClear=!1,this.workItemMessageError="",this.workItemMessageSending=!1;return}this.workItemMessage="",this.workItemMessageQuote=null,this.workItemMessageAttachments=[],this.workItemMessageError="",this.workItemMessageSending=!1}},detail:{deep:!0,handler(e){if(!e||e.id!==this.selectedId)return;let t=Array.isArray(e.actions)?e.actions:[];this.selectedActionId&&!t.some(s=>s.id===this.selectedActionId)&&(this.selectedActionId=null,this.contentPanelOpen=!1,this.resetContentStack(),this.syncWorkCenterUrl(!0),this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1),this.composerTargetAction==null&&this.composerTargetValue!=="coordinator"?this.staleComposerTarget=this.composerTargetValue:this.staleComposerTarget=null}}},beforeUnmount(){Oa(this),this.createGeneration=(Number(this.createGeneration)||0)+1,this.workItemComposerGeneration+=1,this.unavailableAgentStateGeneration+=1,this.boardQueryTimer&&clearTimeout(this.boardQueryTimer),clearInterval(this.actionClockTimer),window.removeEventListener("popstate",this.restoreWorkCenterUrl),document.removeEventListener("click",this.closeHeaderPopovers),this.navigationMedia?.removeEventListener("change",this.onNavigationResize)},mounted(){this.actionClockTimer=setInterval(()=>{this.actionNowMs=Date.now()},1e3),this.returnFocusElement=document.activeElement,this.navigationMedia=window.matchMedia("(max-width: 1100px)"),this.navigationMedia.addEventListener("change",this.onNavigationResize),this.$nextTick(()=>this.focusNavigationReturn()),window.addEventListener("popstate",this.restoreWorkCenterUrl),document.addEventListener("click",this.closeHeaderPopovers),this.restoreWorkCenterUrl();let e=this.store.workCenterCreateDraft;e&&(this.form={requirement:e.requirement||e.goal||e.title||"",workDir:e.workDir||"",deliveryTarget:e.deliveryTarget||"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.createOpen=!0,this.workDirTouched=!!String(e.workDir||"").trim(),this.startTouched=!1,this.applyCreateDefaults())},methods:{selectInfoTab(e){this.infoTab=e,this.$nextTick(()=>{let t=this.$refs.shell?.querySelector(`#work-item-info-panel-${e}`);t&&(t.scrollTop=0)})},onInfoTabKeydown(e,t){let s=this.infoTabs.map(r=>r.id),n=s.indexOf(t);if(e.key==="ArrowRight")n=(n+1)%s.length;else if(e.key==="ArrowLeft")n=(n+s.length-1)%s.length;else if(e.key==="Home")n=0;else if(e.key==="End")n=s.length-1;else return;e.preventDefault(),this.selectInfoTab(s[n]),this.$nextTick(()=>this.$refs.shell?.querySelector(`#work-item-info-tab-${s[n]}`)?.focus())},onNavigationResize(e){this.mobileNavigation=e.matches,this.sidebarExpanded=!e.matches},toggleNavigation(){this.sidebarExpanded=!this.sidebarExpanded,this.$nextTick(()=>this.sidebarExpanded&&this.mobileNavigation?this.$refs.navigation?.focusReturn():this.focusNavigationReturn())},focusNavigationReturn(){this.mobileNavigation?[...this.$refs.header?.querySelectorAll(".work-center-navigation-toggle")||[]].find(e=>e.getClientRects().length)?.focus({preventScroll:!0}):this.$refs.navigation?.focusReturn()},async selectActivity({item:e,actionId:t}){let s=this.agentId;if(await this.selectItem(e),!(this.agentId!==s||this.selectedId!==e.id||this.detailError)&&t){let n=this.selected?.actions?.find(r=>r.id===t);n&&this.selectAction(n)}},toggleWorkbench(){this.$refs.workbench?.toggle()},canOpenOutput(e){return this.workbenchContext.available&&this.store.hasAgentCapability(this.agentId,"file_editor")&&Md(e,this.workbenchContext.ownerWorkDir)?.type==="file"},openOutput(e){this.canOpenOutput(e)&&this.workbenchContext.openOutput(e)},closeHeaderPopovers(e){e?.target?.closest?.(".work-center-filter-menu, .work-center-search")||(this.filtersOpen=!1),e?.target?.closest?.(".work-center-header-menu")||(this.headerMenuOpen=!1)},backToChat(){this.store.leaveWorkCenter(),this.$nextTick(()=>{let e=this.returnFocusElement,t=n=>n?.isConnected&&n.getClientRects().length&&getComputedStyle(n).visibility!=="hidden"&&n.getBoundingClientRect().right>0;(t(e)&&e!==document.body?e:[...document.querySelectorAll(".sidebar-work-center-trigger, .header-sidebar-toggle, .yeaft-topbar-sidebar-toggle")].find(t))?.focus({preventScroll:!0})})},tr(e,t){let s=this.$t?this.$t(e):e;return s&&s!==e?s:t},async loadUnavailableAgentStates(){let e=++this.unavailableAgentStateGeneration,t=this.agents.filter(r=>r?.online&&r.capabilities?.includes("work_center_feature_settings")&&!r.capabilities.includes("work_center")&&(this.store.workCenterFeatureSettingsByAgent?.[r.id]?.loaded!==!0||this.store.workCenterFeatureSettingsByAgent?.[r.id]?.error));if(this.unavailableAgentStateLoading=t.length>0,this.unavailableAgentStateError="",t.length===0)return;let s=await Promise.allSettled(t.map(r=>this.store.loadWorkCenterFeatureSettings(r.id)));if(e!==this.unavailableAgentStateGeneration)return;let n=s.filter(r=>r.status==="rejected");this.unavailableAgentStateError=n.length?n[0].reason?.message||this.tr("workCenter.agentStatusLoadFailed","Could not check Work Center status."):"",this.unavailableAgentStateLoading=!1},openWorkCenterAgentSettings(){let e=this.configurableDisabledAgents[0]||this.configurableUnavailableAgents[0]||this.agents.find(t=>t?.online)||null;this.agentSettingsTargetId=e?.id||null,this.agentSettingsOpen=!0},closeWorkCenterAgentSettings({focusBack:e=!1}={}){this.agentSettingsOpen=!1,e&&this.$nextTick(()=>this.focusNavigationReturn())},selectWorkCenterAgent(e){if(this.mobileNavigation&&(this.sidebarExpanded=!1),!e||e===this.agentId){this.showItemsPane();return}this.saveComposerDraft(),this.showItemsPane(),this.store.enterWorkCenter(e)},statusLabel(e){return this.tr(`workCenter.status.${e}`,String(e||"").replace("_"," "))},goalStatusLabel(e){return this.tr(`workCenter.goalStatus.${e}`,this.statusLabel(e))},deliveryTargetLabel(e){let t={response:"Response",workspace_files:"Files",pull_request:"Pr",merge:"Merge"};return t[e]?this.tr(`workCenter.deliveryTarget${t[e]}`,e):e||this.tr("workCenter.deliveryTargetAsk","Ask me before delivery")},actionLabel(e){return this.tr(`workCenter.action.${e}`,e||"\u2014")},messageSpeakerRole(e,t){return e?this.$t("workCenter.messageSpeakerRole",{name:e,role:t}):t},workItemMessageSpeaker(e){if(e?.role==="user")return this.tr("workCenter.you","You");if(e?.role==="legacy_instruction")return this.tr("workCenter.originalRequest","Original request");let t=e?.speaker?.name||e?.speaker?.id||"";return this.messageSpeakerRole(t,this.tr("workCenter.coordinator","Coordinator"))},quoteWorkItemMessage(e){if(this.coordinatorReadOnly)return;let t=Mt(e);t&&(this.workItemMessageQuote=t,this.saveComposerDraft(),this.$nextTick(()=>this.$refs.workItemComposer?.getTextarea?.()?.focus?.()))},removeWorkItemMessageQuote(){this.workItemMessageQuote=null,this.saveComposerDraft()},editWorkItemMessageAsNew(e){this.coordinatorReadOnly||(this.workItemMessageQuote=null,this.workItemMessage=String(e||""),this.saveComposerDraft(),this.$nextTick(()=>{let t=this.$refs.workItemComposer?.getTextarea?.();t?.focus?.();let s=t?.value?.length||0;t?.setSelectionRange?.(s,s)}))},openConversationAttachment(e){return this.previewAttachment(e?.attachment||e,e?.trigger||null)},actionSequence(e){let t=Number(e?.sequence);if(Number.isFinite(t)&&t>0)return t;let n=(Array.isArray(this.selected?.actions)?this.selected.actions:[]).findIndex(r=>r?.id===e?.id);return n>=0?n+1:1},actionBreadcrumbDescription(e){return String(e?.brief?.objective||e?.objective||this.actionContentSummary(e)||"").trim().replace(/\s+/g," ")||this.tr("workCenter.untitledAction","Untitled Action")},itemActionProgress(e){let t=Math.max(0,Number(e?.actionCount)||0),s=Math.min(t,Math.max(0,Number(e?.completedActionCount)||0));return this.$t("workCenter.actionProgress",{completed:s,total:t})},actionDuration(e){let t=e?.executionDurationMs;if(!Number.isFinite(t)||t<0)return"\u2014";let s=e.executionStartedAt,n=e.status==="running"&&Number.isFinite(s)&&s>0?Math.max(0,this.actionNowMs-s):0;return Ai(t+n)||"\u2014"},time(e){if(!e)return"";try{return new Date(Number(e)).toLocaleString()}catch{return""}},onWorkItemMessageInput(){this.saveComposerDraft()},onWorkItemMessageKeydown(e){e.key!=="Enter"||e.shiftKey||e.isComposing||(e.preventDefault(),this.sendSelectedWorkItemMessage())},boardFilters(){let e=Date.now(),t=this.boardUpdatedRange==="day"?e-1440*60*1e3:this.boardUpdatedRange==="week"?e-10080*60*1e3:this.boardUpdatedRange==="month"?e-720*60*60*1e3:null;return{keyword:this.search.trim(),vpId:this.boardVpId,workItemType:this.boardWorkItemType,updatedFrom:t,limit:200}},scheduleBoardQuery(){this.boardQueryTimer&&clearTimeout(this.boardQueryTimer),this.boardQueryTimer=setTimeout(()=>{this.boardQueryTimer=null,this.agentId&&this.refresh()},180)},refresh(){return this.agentId?this.store.listWorkItems(this.agentId,this.boardFilters()).catch(()=>{}):Promise.resolve([])},refreshWorkCenterRuntime(e){if(!(!e||e!==this.agentId))return this.store.refreshWorkCenterRuntime(e).catch(()=>{})},loadMoreBoardItems(){return this.store.loadMoreWorkItems(this.agentId).catch(()=>{})},boardAction(e){return e.attentionAction||e.activeAction||e.currentAction||null},boardActionCountLabel(e){let t=e.actionCounts||{},s=[];for(let n of["running","failed","waiting","ready"])Number(t[n])>0&&s.push(`${t[n]} ${this.statusLabel(n)}`);return s.join(" \xB7 ")||this.itemActionProgress(e)},boardExecutorLabel(e){let t=Array.isArray(e.executors)?e.executors:[];if(t.length>0)return t.map(n=>n.name||n.id).join(", ");let s=this.boardAction(e);return s?.assignedVp?.name||s?.assignedVp?.id||this.tr("workCenter.assignment.planned","Planned assignment")},sameContentRef(e,t){return e?.type===t?.type&&e?.actionId===t?.actionId&&e?.runId===t?.runId&&e?.resourceId===t?.resourceId},resetContentStack(e=[{type:"action-list"}]){let t=Array.isArray(e)?e:[e],s=t[0]?.type==="action-list"?t:[{type:"action-list"},...t];this.contentStack=s.length>0?s:[{type:"action-list"}];let n=[...this.contentStack].reverse().find(r=>r.type==="action");this.selectedActionId=this.contentRef.actionId||n?.actionId||null},openContentPanel({syncUrl:e=!0}={}){this.contentPanelOpen=!0,e&&this.syncWorkCenterUrl(),this.$nextTick(()=>{this.$refs.actionsButton?.getClientRects().length||this.$refs.contentClose?.focus({preventScroll:!0})})},closeContentPanel({syncUrl:e=!0}={}){this.contentPanelOpen=!1,this.resetContentStack(),e&&this.syncWorkCenterUrl(),this.$nextTick(()=>this.$refs.actionsButton?.focus?.())},pushContentRef(e,{replace:t=!1,syncUrl:s=!0}={}){let n=this.contentRef;if(this.contentPanelOpen=!0,this.sameContentRef(n,e)){s&&this.syncWorkCenterUrl(t);return}this.contentStack=e.type==="action-list"?[{type:"action-list"}]:[...this.contentStack,e],this.selectedActionId=e.actionId||this.selectedActionId,s&&this.syncWorkCenterUrl(t)},popContentRef(){if(this.contentStack.length<=1)return;this.contentStack=this.contentStack.slice(0,-1);let e=[...this.contentStack].reverse().find(t=>t.type==="action");this.selectedActionId=e?.actionId||null,this.syncWorkCenterUrl()},contentRefParam(e){return e.type==="action"&&e.actionId?`action:${e.actionId}`:e.type==="run"&&e.actionId&&e.runId?`run:${e.actionId}:${e.runId}`:e.type==="attachment"&&e.resourceId?`attachment:${e.actionId||"-"}:${e.resourceId}`:"action-list"},contentStackParam(){return this.contentStack.map(e=>this.contentRefParam(e)).join("/")},parseContentRef(e){let t=String(e||"");if(t==="action-list")return{type:"action-list"};if(t.startsWith("action:"))return{type:"action",actionId:t.slice(7)};if(t.startsWith("run:")){let[,s,n]=t.split(":");return{type:"run",actionId:s,runId:n}}if(t.startsWith("attachment:")){let[,s,n]=t.split(":");return{type:"attachment",actionId:s==="-"?null:s,resourceId:n}}return{type:"action-list"}},parseContentStack(e){let s=[...String(e||"").split("/").filter(Boolean).map(n=>this.parseContentRef(n))].reverse().find(n=>n.actionId&&["action","run","attachment"].includes(n.type));return s?[{type:"action-list"},{type:"action",actionId:s.actionId}]:[{type:"action-list"}]},workCenterUrlRoute(){let e=new URLSearchParams(window.location.search);return{agentId:e.get("workAgentId"),itemId:e.get("workItemId"),content:e.has("workContent")?e.get("workContent"):null}},sameWorkCenterUrlRoute(e,t){return e?.agentId===t?.agentId&&e?.itemId===t?.itemId&&e?.content===t?.content},syncWorkCenterUrl(e=!1){Oa(this);let t=new URL(window.location.href);this.selectedId?(t.searchParams.set("workAgentId",this.agentId||""),t.searchParams.set("workItemId",this.selectedId),t.searchParams.set("workContent",this.contentPanelOpen?this.contentStackParam():"none")):(t.searchParams.delete("workAgentId"),t.searchParams.delete("workItemId"),t.searchParams.delete("workContent"));let s=`${t.pathname}${t.search}${t.hash}`;if(`${window.location.pathname}${window.location.search}${window.location.hash}`===s)return;let n={...window.history.state,workCenter:!!this.selectedId,workCenterContent:!!this.selectedId&&this.contentPanelOpen};window.history[e?"replaceState":"pushState"](n,"",s)},async restoreWorkCenterUrl(){let e=Oa(this),t=this.workCenterUrlRoute(),s=()=>e===this.workCenterUrlRestoreGeneration&&this.sameWorkCenterUrlRoute(t,this.workCenterUrlRoute()),n=t.agentId,r=t.itemId;if(!r||n&&n!==this.agentId){this.selectedId&&this.showItemsPane({syncUrl:!1});return}let i=t.content==null?(this.$refs.shell?.clientWidth||window.innerWidth)>900:t.content!=="none",o=this.parseContentStack(t.content),a=o.at(-1);if(this.selectedId!==r||this.detail?.id!==r){this.openWorkItem(r,{syncUrl:!1,contentRefs:o,contentOpen:i}),this.detailLoading=!0;try{await this.store.getWorkItem(r,this.agentId)}catch(c){s()&&(this.detailError=c?.message||String(c))}finally{s()&&(this.detailLoading=!1)}}if(!s())return;let l=a.actionId||[...o].reverse().find(c=>c.type==="action")?.actionId;if(l&&!this.selected?.actions?.some(c=>c.id===l)){this.resetContentStack(),this.syncWorkCenterUrl(!0);return}this.resetContentStack(o),this.contentPanelOpen=i,this.narrowPane="work-item",i&&l&&this.loadLatestActionMessages(this.selectedAction),i&&t.content!==this.contentStackParam()&&this.syncWorkCenterUrl(!0)},resetWorkItemComposer(){this.workItemComposerGeneration+=1,this.workItemMessage="",this.workItemMessageQuote=null,this.workItemMessageAttachments=[],this.workItemMessageAttachmentUploadCount=0,this.workItemMessageAttachmentsUploading=!1,this.workItemMessageError="",this.workItemMessageSending=!1},draftTarget(){let e=this.composerTargetAction;return e?{kind:"action",actionId:e.id,generation:Number(e.generation)}:this.composerTargetValue==="coordinator"?{kind:"coordinator"}:(()=>{let[,t="",s="0"]=this.composerTargetValue.split(":");return{kind:"action",actionId:t,generation:Number(s)||0}})()},targetValue(e){return typeof e=="string"&&e.startsWith("action:")?e:e?.kind==="action"?`action:${e.actionId}:${e.generation}`:"coordinator"},saveComposerDraft(){!this.selectedId||!this.agentId||this.store.saveWorkCenterComposerDraft(this.agentId,this.selectedId,{text:this.workItemMessage,quote:this.workItemMessageQuote,attachments:[...this.workItemMessageAttachments],target:this.draftTarget(),error:this.workItemMessageError})},restoreComposerDraft(e){let s=this.store.loadWorkCenterMessageEnvelope(this.agentId,e)||this.store.loadWorkCenterComposerDraft(this.agentId,e);this.workItemMessage=s?.text||"",this.workItemMessageQuote=Mt(s?.quote),this.workItemMessageAttachments=[...s?.attachments||[]],this.composerTargetValue=this.targetValue(s?.target),this.workItemMessageError=s?.error||"",this.staleComposerTarget=null,this.workItemMessageSending=!1,this.workItemMessageAttachmentUploadCount=0,this.workItemMessageAttachmentsUploading=!1,this.workItemComposerGeneration+=1},openWorkItem(e,{syncUrl:t=!0,contentRefs:s=[{type:"action-list"}],contentOpen:n=(this.$refs.shell?.clientWidth||window.innerWidth)>900}={}){this.saveComposerDraft(),this.selectedId=e,this.narrowPane="work-item",this.contentPanelOpen=n,this.resetContentStack(s),this.restoreComposerDraft(e),this.detailError="",this.detailLoading=!1,this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1,t&&this.syncWorkCenterUrl()},async selectItem(e){this.mobileNavigation&&(this.sidebarExpanded=!1),this.openWorkItem(e.id),this.detailLoading=!0;try{await this.store.getWorkItem(e.id,this.agentId)}catch(t){this.selectedId===e.id&&(this.detailError=t?.message||String(t))}finally{this.selectedId===e.id&&(this.detailLoading=!1)}},selectAction(e){this.selectedActionId!==e.id&&(this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1),this.pushContentRef({type:"action",actionId:e.id}),this.loadLatestActionMessages(e),this.$nextTick(()=>this.$refs.actionBack?.focus({preventScroll:!0}))},loadLatestActionMessages(e=this.selectedAction){if(!this.selected?.id||!e?.id||Array.isArray(e.messages))return null;let t=or(this.agentId,this.selected.id,e.id,e.generation);return this.store.workCenterActionMessages[t]?null:this.store.loadWorkItemActionMessages(this.selected.id,e.id,e.generation,null,this.agentId).catch(()=>null)},showItemsPane({syncUrl:e=!0}={}){this.saveComposerDraft(),this.narrowPane="items",this.selectedId=null,this.contentPanelOpen=!1,this.resetContentStack(),this.composerTargetValue="coordinator",this.resetWorkItemComposer(),e&&this.syncWorkCenterUrl()},showActionsPane(){this.contentPanelOpen=!0,this.contentIsActionList?this.syncWorkCenterUrl():this.popContentRef(),this.$nextTick(()=>this.$refs.contentClose?.focus({preventScroll:!0}))},canMessageAction(e){return!e||["done","cancelled"].includes(this.selected?.status)?!1:["idle","ready","running","paused","waiting","failed","completed","stopped"].includes(e.status)&&e.admissionStatus!=="blocked"},clearPendingMessageEnvelope({preserveAttachments:e=!1}={}){return!this.selectedId||!this.pendingMessageEnvelope?!1:(this.actionInputRequestGeneration=(Number(this.actionInputRequestGeneration)||0)+1,this.preserveComposerOnEnvelopeClear=!0,this.store.discardWorkCenterMessageEnvelope(this.agentId,this.selectedId)?(e||(this.workItemMessageAttachments=[]),this.workItemMessageError="",this.workItemMessageSending=!1,!0):(this.preserveComposerOnEnvelopeClear=!1,!1))},chooseCoordinatorTarget(){this.pendingMessageEnvelope&&!this.clearPendingMessageEnvelope({preserveAttachments:!0})||(this.composerTargetValue="coordinator",this.staleComposerTarget=null,this.saveComposerDraft())},onComposerTargetChange(){this.pendingMessageEnvelope&&!this.clearPendingMessageEnvelope({preserveAttachments:!0})||(this.staleComposerTarget=this.composerTargetAction==null&&this.composerTargetValue!=="coordinator"?this.composerTargetValue:null,this.saveComposerDraft())},loadEarlierActionMessages(){return!this.selected?.id||!this.selectedAction?.id||this.actionMessagesNextCursor==null?null:this.store.loadWorkItemActionMessages(this.selected.id,this.selectedAction.id,this.selectedAction.generation,this.actionMessagesNextCursor,this.agentId).catch(()=>null)},actionExecutor(e){return e?.assignedVp?.name||e?.assignedVp?.id||e?.requiredRole||e?.assignmentPolicy?.fixedVpId||e?.assignmentPolicy?.capability||this.tr("workCenter.assignment.auto","Auto")},actionContentSummary(e){return String(e?.contentSummary||e?.response||e?.brief?.objective||"").trim()},executionStats(e){return e?.executionStats||{}},formatCount(e){return new Intl.NumberFormat().format(Math.max(0,Number(e)||0))},formatTokens(e){let t=Math.max(0,Number(e)||0);return t>=1e6?`${(t/1e6).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)},resetCreateExecutionContext(e){let t=this.workDirTouched||this.startTouched,s=this.store.workCenterCreateDraft;s&&(this.store.workCenterCreateDraft={sourceAgentId:e||null,requirement:s.requirement||s.goal||s.title||"",workDir:"",deliveryTarget:s.deliveryTarget||"",origin:null,linkedSessionIds:[]}),this.form.workDir="",this.form.start=!0,this.workDirTouched=!1,this.startTouched=!1,t&&(this.createOpen=!1),this.applyCreateDefaults()},applyCreateDefaults(){this.createOpen&&(!this.workDirTouched&&!this.form.workDir.trim()&&(this.form.workDir=this.createDefaultWorkDir),this.startTouched||(this.form.start=this.createDefaultStart))},folderPickerInitialDir(){return this.form.workDir.trim()||this.createDefaultWorkDir},folderPickerSetWorkDir(e){this.form.workDir=e,this.workDirTouched=!0},onCreateWorkDirInput(){this.workDirTouched=!0},onCreateStartInput(){this.startTouched=!0},clipboardFiles(e){return Array.from(e?.clipboardData?.items||[]).filter(t=>t?.kind==="file").map(t=>t.getAsFile?.()).filter(Boolean)},clipboardIncludesText(e){return Array.from(e?.clipboardData?.types||[]).some(t=>String(t).toLowerCase().startsWith("text/"))},attachmentUploadName(e,t){let s=String(e?.name||"").trim();if(s)return s;let n={"image/png":".png","image/jpeg":".jpg","image/gif":".gif","image/webp":".webp","application/pdf":".pdf","application/json":".json","text/plain":".txt"};return`${String(e?.type||"").startsWith("image/")?"pasted-image":"pasted-file"}-${Date.now()}-${t+1}${n[e?.type]||""}`},async uploadPendingAttachments(e){let t=new FormData;e.forEach((a,l)=>{t.append("files",a,this.attachmentUploadName(a,l))});let s=Pinia.useAuthStore(),n=s.getActiveToken?.()||s.token||null,r=n?{Authorization:`Bearer ${n}`}:{},i=await fetch("/api/upload",{method:"POST",headers:r,body:t});if(!i.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let o=await i.json();return Array.isArray(o.files)?o.files:[]},async addCreateAttachments(e){if(!this.workItemAttachmentsSupported){this.createAttachmentError=this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments.");return}let t=Math.max(0,10-this.createAttachments.length),s=Array.from(e||[]).slice(0,t);if(s.length===0)return;let n=this.createGeneration;this.createAttachmentUploadCount+=1,this.attachmentsUploading=!0,this.createAttachmentError="";try{let r=await this.uploadPendingAttachments(s);if(!this.createOpen||this.createGeneration!==n)return;this.createAttachments=[...this.createAttachments,...r].slice(0,10)}catch(r){this.createOpen&&this.createGeneration===n&&(this.createAttachmentError=r?.message||String(r))}finally{this.createGeneration===n&&(this.createAttachmentUploadCount=Math.max(0,this.createAttachmentUploadCount-1),this.attachmentsUploading=this.createAttachmentUploadCount>0)}},async onCreateAttachmentInput(e){let t=Array.from(e.target.files||[]);e.target.value="",await this.addCreateAttachments(t)},async onCreateRequirementPaste(e){let t=this.clipboardFiles(e);t.length!==0&&(this.clipboardIncludesText(e)||e.preventDefault(),await this.addCreateAttachments(t))},removeCreateAttachment(e){this.createAttachments=this.createAttachments.filter((t,s)=>s!==e)},discardPendingMessageEnvelope(){this.clearPendingMessageEnvelope()&&this.saveComposerDraft()},async addWorkItemMessageAttachments(e){if(!this.workItemAttachmentsSupported){this.workItemMessageError=this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments.");return}if(!e.length)return;let t=this.workItemComposerScope;if(!t)return;let s=this.pendingEnvelopeAttachmentRecovery,n=Array.isArray(this.selected?.attachments)?this.selected.attachments.length:0,r=Math.max(0,10-n-(s?0:this.workItemMessageAttachments.length)),i=Array.from(e).slice(0,r);if(i.length===0)return;let o=this.workItemComposerGeneration;this.workItemMessageAttachmentUploadCount+=1,this.workItemMessageAttachmentsUploading=!0,this.workItemMessageError="";try{let a=(await this.uploadPendingAttachments(i)).slice(0,Math.max(0,10-n));if(this.workItemComposerScope!==t||this.workItemComposerGeneration!==o)return;if(s){let l=this.store.replaceWorkCenterMessageEnvelopeAttachments(this.agentId,this.selectedId,a);if(!l)throw new Error(this.tr("workCenter.pendingEnvelopeChanged","The pending request changed; reopen this Work Item and try again."));this.workItemMessageAttachments=[...l.attachments],this.workItemMessageError=""}else this.workItemMessageAttachments=[...this.workItemMessageAttachments,...a].slice(0,Math.max(0,10-n)),this.saveComposerDraft()}catch(a){this.workItemComposerScope===t&&this.workItemComposerGeneration===o&&(this.workItemMessageError=a?.message||String(a))}finally{this.workItemComposerScope===t&&this.workItemComposerGeneration===o&&(this.workItemMessageAttachmentUploadCount=Math.max(0,this.workItemMessageAttachmentUploadCount-1),this.workItemMessageAttachmentsUploading=this.workItemMessageAttachmentUploadCount>0)}},async onWorkItemMessageAttachmentInput(e){let t=Array.from(e.target.files||[]);e.target.value="",await this.addWorkItemMessageAttachments(t)},async onWorkItemMessagePaste(e){let t=this.clipboardFiles(e);t.length!==0&&(this.clipboardIncludesText(e)||e.preventDefault(),await this.addWorkItemMessageAttachments(t))},removeWorkItemMessageAttachment(e){this.workItemMessageAttachments=this.workItemMessageAttachments.filter((t,s)=>s!==e),this.saveComposerDraft()},async previewAttachment(e,t=null){if(!this.selected?.id||!e?.id||this.previewingAttachmentId)return;let s=this.agentId,n=this.selected.id,r=this.selectedActionId||"",i=`${s}:${n}:${r}`,o=(Number(this.attachmentPreviewGeneration)||0)+1;this.attachmentPreviewGeneration=o;let a=()=>this.attachmentPreviewGeneration===o&&`${this.agentId}:${this.selected?.id||""}:${this.selectedActionId||""}`===i,l=e.isImage?null:window.open("","_blank");if(!e.isImage&&!l){this.attachmentPreviewError=this.tr("workCenter.attachmentOpenBlocked","The browser blocked the attachment window. Allow pop-ups and try again.");return}l&&(l.opener=null),this.previewingAttachmentId=e.id,this.attachmentPreviewError="";try{let c=await this.store.previewWorkItemAttachment(n,e.id,s);if(!a()){l?.close();return}c?.preview&&c.attachment?.isImage?Fs(c.preview,{alt:e.name||this.tr("workCenter.previewAttachment","Open attachment"),closeLabel:this.tr("common.close","Close"),trigger:t}):c?.preview&&l?l.location.replace(c.preview):l?.close()}catch(c){l?.close(),a()&&(this.attachmentPreviewError=c?.message||this.tr("workCenter.attachmentPreviewFailed","Could not open the attachment. Try again."))}finally{a()&&(this.previewingAttachmentId=null)}},isExternalOutput(e){return["link","pr"].includes(e?.kind)&&/^https?:\/\//i.test(String(e?.ref||""))},formatAttachmentSize(e){let t=Math.max(0,Number(e)||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`},openCreate(){this.createGeneration=(Number(this.createGeneration)||0)+1,this.createAttachmentUploadCount=0,this.attachmentsUploading=!1,this.createOpen=!0,this.workDirTouched=!1,this.startTouched=!1,this.createAttachmentError="",this.applyCreateDefaults()},closeCreate(){this.saving||(this.createGeneration=(Number(this.createGeneration)||0)+1,this.createAttachmentUploadCount=0,this.attachmentsUploading=!1,this.closeFolderPicker(),this.createOpen=!1,this.createAttachments=[],this.createAttachmentError="",this.store.workCenterCreateDraft=null)},async submitCreate(){let e=String(this.form.requirement||this.form.goal||this.form.title||"").trim();if(!e||!this.form.workDir.trim())return;let t=this.agentId,s=(Number(this.createGeneration)||0)+1;this.createGeneration=s,this.saving=!0;try{let n=this.store.workCenterCreateDraft,r=n?.sourceAgentId===t,i=await this.store.createWorkItem({requirement:e,title:e.replace(/\s+/g," ").slice(0,80),titleSource:"coordinator_pending",goal:e,acceptanceCriteria:[],workItemType:"auto",workDir:this.form.workDir.trim(),deliveryTarget:this.form.deliveryTarget||null,origin:r&&n.origin||null,linkedSessionIds:r?n.linkedSessionIds||[]:[],attachments:this.workItemAttachmentsSupported?(this.createAttachments||[]).map(o=>({fileId:o.fileId,name:o.name,mimeType:o.mimeType,size:o.size})):[],reuseMemory:this.form.reuseMemory,start:this.form.start},t);if(this.agentId!==t||this.createGeneration!==s)return;this.openWorkItem(i.id),this.form={requirement:"",workDir:"",deliveryTarget:"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.store.workCenterCreateDraft=null,this.createAttachments=[],this.workDirTouched=!1,this.startTouched=!1,this.createOpen=!1}finally{this.agentId===t&&this.createGeneration===s&&(this.saving=!1)}},async startSelected(){this.selected&&await this.store.startWorkItem(this.selected.id,this.agentId)},async sendSelectedWorkItemMessage(){if(!this.selected||!this.composerCanSend)return;let e=this.workItemComposerScope,t=this.composerTargetValue,s=this.composerTargetAction;if(!this.composerTargetIsCoordinator&&!s)return;let n=this.selected.id,r=this.selected.revision,i=this.workItemMessage.trim(),o=Mt(this.workItemMessageQuote),a=this.workItemMessageAttachments.map(c=>({fileId:c.fileId,name:c.name,mimeType:c.mimeType,size:c.size})),l=(Number(this.actionInputRequestGeneration)||0)+1;this.actionInputRequestGeneration=l,this.workItemMessageSending=!0,this.workItemMessageError="",this.saveComposerDraft();try{let c={planRevision:this.selected.planRevision,ledgerRevision:this.selected.ledgerRevision,coordinatorRevision:this.selected.coordinatorRevision};this.canonicalMessageWireSupported?await this.store.postWorkItemMessage(n,i,s?{kind:"action",actionId:s.id,generation:s.generation}:{kind:"coordinator"},r,a,this.agentId,c,o):s?await this.store.sendWorkItemActionInput(n,i,s.id,r,s.generation,a,this.agentId,o):await this.store.sendWorkItemMessage(n,i,r,a,this.agentId,c,o),this.workItemComposerScope===e&&this.actionInputRequestGeneration===l&&this.composerTargetValue===t&&this.workItemMessage.trim()===i&&!this.store.loadWorkCenterMessageEnvelope(this.agentId,n)&&(this.workItemMessage="",this.workItemMessageQuote=null,this.workItemMessageAttachments=[],this.store.removeWorkCenterComposerDraft(this.agentId,n))}catch(c){this.workItemComposerScope===e&&this.actionInputRequestGeneration===l&&(this.workItemMessageError=c?.message||String(c),this.saveComposerDraft())}finally{this.workItemComposerScope===e&&this.actionInputRequestGeneration===l&&(this.workItemMessageSending=!1)}},workItemCanDelete(e){return["done","cancelled","draft","needs_attention"].includes(e?.status)},workItemDeleting(e){return!!this.deletingWorkItemIds[e?.id]},async deleteWorkItem(e){if(!e||this.workItemDeleting(e))return;let t=this.tr("workCenter.deleteConfirm","Permanently delete this Work Item, its execution history, and attachments?");if(await We(t,{destructive:!0})){this.deleteWorkItemError="",this.deletingWorkItemIds={...this.deletingWorkItemIds,[e.id]:!0};try{let s=await this.store.deleteWorkItem(e.id,e.revision,this.agentId);s?.cleanupWarning&&(this.deleteWorkItemError=s.cleanupWarning),this.selectedId===e.id&&this.showItemsPane()}catch(s){this.deleteWorkItemError=s?.message||String(s)}finally{let s={...this.deletingWorkItemIds};delete s[e.id],this.deletingWorkItemIds=s}}},async cancelSelected(){if(!this.selected||["done","cancelled"].includes(this.selected.status))return;let e=this.tr("workCenter.cancelConfirm","Stop this work item and its unfinished Actions?");await We(e,{destructive:!0})&&await this.store.cancelWorkItem(this.selected.id,this.agentId)},async resumeSelected(){!this.selected||this.selected.status!=="cancelled"||await this.store.resumeWorkItem(this.selected.id,this.selected.revision,this.agentId,this.selected.executionControl?.revision)}},template:`
6737
6737
  <main class="work-center-main" :class="{ 'navigation-open': sidebarExpanded && mobileNavigation }" :aria-label="tr('workCenter.title', 'Work Center')">
6738
6738
  <WorkCenterSidebar ref="navigation" :agents="sidebarAgents" :agent-id="agentId" :item-id="selectedId"
6739
6739
  :action-id="selectedActionId" :expanded="sidebarExpanded"
@@ -7223,6 +7223,7 @@ ${String(e||"").trim()}
7223
7223
  :send-label="$t('workCenter.sendToTarget', { target: composerTargetLabel })"
7224
7224
  @input="onWorkItemMessageInput"
7225
7225
  @keydown="onWorkItemMessageKeydown"
7226
+ @paste="onWorkItemMessagePaste"
7226
7227
  @send="sendSelectedWorkItemMessage"
7227
7228
  >
7228
7229
  <template #start-actions>
@@ -7337,7 +7338,7 @@ ${String(e||"").trim()}
7337
7338
  <div class="work-center-modal-body">
7338
7339
  <section class="work-center-form-section work-center-requirement-section">
7339
7340
  <label>{{ tr('workCenter.requirement', 'Requirement') }}
7340
- <textarea v-model="form.requirement" rows="8" required autofocus :placeholder="tr('workCenter.requirementHint', 'Describe the problem, desired outcome, and any constraints in your own words')"></textarea>
7341
+ <textarea v-model="form.requirement" rows="8" required autofocus @paste="onCreateRequirementPaste" :placeholder="tr('workCenter.requirementHint', 'Describe the problem, desired outcome, and any constraints in your own words')"></textarea>
7341
7342
  <small class="work-center-field-help">{{ tr('workCenter.requirementHelp', 'The Coordinator will refine the goal and acceptance criteria, then create Actions dynamically as evidence arrives.') }}</small>
7342
7343
  </label>
7343
7344
  </section>
@@ -7351,6 +7352,7 @@ ${String(e||"").trim()}
7351
7352
  {{ attachmentsUploading ? tr('workCenter.attachmentsUploading', 'Uploading\u2026') : tr('workCenter.addAttachments', 'Add files') }}
7352
7353
  </label>
7353
7354
  <p v-else class="work-center-muted">{{ tr('workCenter.attachmentsUnsupported', 'The selected Agent does not support Work Item attachments.') }}</p>
7355
+ <p v-if="createAttachmentError" class="work-center-error" role="alert">{{ createAttachmentError }}</p>
7354
7356
  <div v-if="workItemAttachmentsSupported && createAttachments.length" class="work-center-attachment-list">
7355
7357
  <span v-for="(attachment, index) in createAttachments" :key="attachment.fileId" class="work-center-attachment-chip">
7356
7358
  <span>{{ attachment.name }}</span>
Binary file
@@ -17,6 +17,6 @@
17
17
  </head>
18
18
  <body>
19
19
  <div id="app"></div>
20
- <script type="module" src="app.bundle.js?v=6dcbc90b"></script>
20
+ <script type="module" src="app.bundle.js?v=243b681d"></script>
21
21
  </body>
22
22
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.558",
3
+ "version": "1.0.559",
4
4
  "description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
5
5
  "main": "index.js",
6
6
  "type": "module",