@yeaft/webchat-agent 1.0.569 → 1.0.570

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.569"}
1
+ {"version":"1.0.570"}
@@ -6345,6 +6345,7 @@ ${String(e||"").trim()}
6345
6345
  <path v-else-if="name === 'menu'" fill="currentColor" d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
6346
6346
  <path v-else-if="name === 'collapse'" fill="currentColor" d="M3 18h13v-2H3v2zm0-5h10v-2H3v2zm0-7v2h13V6H3zm18 9.59L17.42 12 21 8.41 19.59 7l-5 5 5 5L21 15.59z"/>
6347
6347
  <path v-else-if="name === 'workbench'" fill="currentColor" d="M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H4V5h16v14zM6 7h5v2H6V7zm0 4h5v2H6v-2zm0 4h5v2H6v-2zm7-8h5v10h-5V7z"/>
6348
+ <path v-else-if="name === 'settings'" fill="currentColor" d="M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.07.62-.07.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"/>
6348
6349
  <g v-else fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
6349
6350
  <template v-if="name === 'activity'"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="M8 9h8M8 14h5"/></template>
6350
6351
  <template v-else-if="name === 'search'"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></template>
@@ -6700,7 +6701,7 @@ ${String(e||"").trim()}
6700
6701
  @pointerdown="startDrag" @pointermove="moveDrag" @pointerup="finishDrag"
6701
6702
  @pointercancel="finishDrag" @lostpointercapture="finishDrag"
6702
6703
  @keydown="onKeydown" @dblclick="setSize(defaultSize)"></div>
6703
- `}});var jv,Kv=F(()=>{Dr();$o();jv={components:{NavigationIcon:ks},name:"WorkCenterSidebar",props:{agents:{type:Array,default:()=>[]},agentId:{type:String,default:null},itemId:{type:String,default:null},actionId:{type:String,default:null},expanded:{type:Boolean,default:!0}},emits:["back","collapse","select-agent","select-item"],data(){return{activityExpanded:!0,collapsedItems:{}}},computed:{store(){return Pinia.useChatStore()},activity(){return this.store.workCenterActivityByAgent?.[this.agentId]||[]},loading(){return!!this.store.workCenterActivityLoadingByAgent?.[this.agentId]},error(){return this.store.workCenterActivityErrorByAgent?.[this.agentId]},online(){return this.store.connectionState==="connected"&&this.store.workCenterActivityConnectionGeneration===Number(this.store.chatHistoryConnectionGeneration||0)&&this.agents.some(e=>e.id===this.agentId&&e.online)},connectionKey(){return this.online?`${this.agentId}:${this.store.workCenterActivityConnectionGeneration}`:""}},watch:{connectionKey:{immediate:!0,handler(e){e&&this.refresh()}}},methods:{refresh(){return this.store.loadWorkCenterActivity?.(this.agentId).catch(()=>{})},focusReturn(){this.$refs.back?.focus({preventScroll:!0})},actions(e){return Ig(e)},itemKey(e){return JSON.stringify([this.agentId,e.id])},itemExpanded(e){return!this.collapsedItems[this.itemKey(e)]},toggleItem(e){let t=this.itemKey(e);this.collapsedItems={...this.collapsedItems,[t]:!this.collapsedItems[t]}},timeValue(e,t=!1){return t?Ag(e):Ro(e)},timeIso(e,t=!1){return new Date(this.timeValue(e,t)).toISOString()},timeLabel(e,t=!1){return new Date(this.timeValue(e,t)).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})},timeTitle(e,t=!1){return new Date(this.timeValue(e,t)).toLocaleString()},actionLabel(e,t,s){return t.contentSummary||t.objective||e.currentAction?.id===t.id&&e.currentAction.objective||this.$t("workCenter.actionNumber",{number:t.sequence||s+1})},status(e){let t=`workCenter.status.${e}`,s=this.$t(t);return s===t?e:s},onKeydown(e){if(e.key==="Escape"&&(e.preventDefault(),this.$emit("collapse")),e.key!=="Tab"||!this.expanded||window.innerWidth>1100)return;let t=[...this.$el.querySelectorAll("button:not(:disabled)")].filter(n=>n.getClientRects().length),s=e.shiftKey&&document.activeElement===t[0]?t.at(-1):!e.shiftKey&&document.activeElement===t.at(-1)?t[0]:null;s&&(e.preventDefault(),s.focus())}},template:`
6704
+ `}});var jv,Kv=F(()=>{Dr();$o();jv={components:{NavigationIcon:ks},name:"WorkCenterSidebar",props:{agents:{type:Array,default:()=>[]},agentId:{type:String,default:null},itemId:{type:String,default:null},actionId:{type:String,default:null},expanded:{type:Boolean,default:!0}},emits:["back","collapse","create","select-agent","select-item"],data(){return{activityExpanded:!0,collapsedItems:{}}},computed:{store(){return Pinia.useChatStore()},activity(){return this.store.workCenterActivityByAgent?.[this.agentId]||[]},loading(){return!!this.store.workCenterActivityLoadingByAgent?.[this.agentId]},error(){return this.store.workCenterActivityErrorByAgent?.[this.agentId]},online(){return this.store.connectionState==="connected"&&this.store.workCenterActivityConnectionGeneration===Number(this.store.chatHistoryConnectionGeneration||0)&&this.agents.some(e=>e.id===this.agentId&&e.online)},connectionKey(){return this.online?`${this.agentId}:${this.store.workCenterActivityConnectionGeneration}`:""}},watch:{connectionKey:{immediate:!0,handler(e){e&&this.refresh()}}},methods:{refresh(){return this.store.loadWorkCenterActivity?.(this.agentId).catch(()=>{})},focusReturn(){this.$refs.back?.focus({preventScroll:!0})},actions(e){return Ig(e)},itemKey(e){return JSON.stringify([this.agentId,e.id])},itemExpanded(e){return!this.collapsedItems[this.itemKey(e)]},toggleItem(e){let t=this.itemKey(e);this.collapsedItems={...this.collapsedItems,[t]:!this.collapsedItems[t]}},timeValue(e,t=!1){return t?Ag(e):Ro(e)},timeIso(e,t=!1){return new Date(this.timeValue(e,t)).toISOString()},timeLabel(e,t=!1){return new Date(this.timeValue(e,t)).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})},timeTitle(e,t=!1){return new Date(this.timeValue(e,t)).toLocaleString()},actionLabel(e,t,s){return t.contentSummary||t.objective||e.currentAction?.id===t.id&&e.currentAction.objective||this.$t("workCenter.actionNumber",{number:t.sequence||s+1})},status(e){let t=`workCenter.status.${e}`,s=this.$t(t);return s===t?e:s},onKeydown(e){if(e.key==="Escape"&&(e.preventDefault(),this.$emit("collapse")),e.key!=="Tab"||!this.expanded||window.innerWidth>1100)return;let t=[...this.$el.querySelectorAll("button:not(:disabled)")].filter(n=>n.getClientRects().length),s=e.shiftKey&&document.activeElement===t[0]?t.at(-1):!e.shiftKey&&document.activeElement===t.at(-1)?t[0]:null;s&&(e.preventDefault(),s.focus())}},template:`
6704
6705
  <aside id="work-center-sidebar" class="work-center-sidebar" :class="{ collapsed: !expanded }"
6705
6706
  :aria-label="$t('workCenter.navigation')" @keydown="onKeydown">
6706
6707
  <div class="work-center-sidebar-header">
@@ -6715,6 +6716,11 @@ ${String(e||"").trim()}
6715
6716
  <NavigationIcon :name="expanded ? 'collapse' : 'menu'" :size="18" />
6716
6717
  </button>
6717
6718
  </div>
6719
+ <button class="btn-secondary work-center-sidebar-create" type="button" :disabled="!agentId || !agents.some(agent => agent.online)"
6720
+ :title="$t('workCenter.newWorkItem')" :aria-label="$t('workCenter.newWorkItem')" @click="$emit('create')">
6721
+ <NavigationIcon name="add" :size="18" />
6722
+ <span v-if="expanded">{{ $t('workCenter.newWorkItem') }}</span>
6723
+ </button>
6718
6724
  <div v-if="expanded" class="work-center-sidebar-scroll">
6719
6725
  <nav class="work-center-agent-list" :aria-label="$t('workCenter.selectAgent')">
6720
6726
  <h2>{{ $t('workCenter.agents') }}</h2>
@@ -6871,13 +6877,13 @@ ${String(e||"").trim()}
6871
6877
  </div>
6872
6878
  <p class="work-center-field-help">{{ $t(modelValue.frequency === 'once' ? 'workCenter.scheduling.onceHint' : 'workCenter.scheduling.recurringHint') }}</p>
6873
6879
  </div>
6874
- `}});function $r(e){return typeof e=="string"?e.trim():""}function LC(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t.href:""}catch{return""}}function sy(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 Wd(e,t){let s=$r(e?.ref);if(!s)return null;let n=LC(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=sy(t),i=/^(?:[A-Za-z]:[\\/]|[\\/])/.test(s),o=sy(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 ny({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=$C.filter(u=>!n(o.agentId,u)),c=s===!0&&!!(a&&i)&&l.length===0,d=c?Ds(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=Wd(u,i);return g?.type!=="file"?!1:(window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:g.filePath,agentId:o.agentId,conversationId:$n(a),workbenchRoute:o,workbenchRouteKey:a,workspaceGeneration:d}})),!0)}}}var $C,ry=F(()=>{gs();$C=Object.freeze(["workbench_session_routes","workbench_request_correlation","workbench_terminal_cleanup_fence","work_center_workbench"])});function OC(){try{let e=Number(localStorage.getItem("work-center-actions-width"));if(Number.isFinite(e)&&e>=280&&e<=1e4)return e}catch{}return 400}function Ga(e){let t=(Number(e?.workCenterUrlRestoreGeneration)||0)+1;return e&&(e.workCenterUrlRestoreGeneration=t),t}var Ya,Ud=F(()=>{xi();Dr();Zc();It();Ua();Lv();qv();Nv();cd();la();aa();La();Vn();_a();Uv();Kv();ty();Nd();ry();Ai();tn();Mi();$o();Ya={name:"WorkCenterPage",components:{FolderPickerDialog:rn,NavigationIcon:ks,MessageComposer:wa,UserTurnBlock:kr,VpTurnBlock:wr,WorkCenterActionDetail:$v,WorkCenterActionReference:Er,WorkCenterSettingsModal:Hv,AgentSettingsPanel:_r,ModernSelect:Wt,WorkCenterResourceControl:Fv,WorkbenchPanel:Mr,PaneResizeHandle:Wv,WorkCenterSidebar:jv,WorkCenterScheduleEditor:ey},mixins:[Xo],data(){return{sidebarExpanded:window.innerWidth>1100,mobileNavigation:window.innerWidth<=1100,selectedId:null,infoTab:"requirement",workbenchExpanded:!1,selectedActionId:null,narrowPane:"items",contentPanelOpen:!1,actionsPaneWidth:OC(),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,createError:"",scheduleSaving:!1,scheduleDraftStarted:!1,scheduleError:"",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:"",deliveryInstructionOptions:[],deliveryInstructionsGeneration:0,previewingAttachmentId:null,attachmentPreviewError:"",attachmentPreviewGeneration:0,form:{requirement:"",workDir:"",deliveryTarget:"",deliveryInstructions:"",reuseMemory:!0,start:!0,scheduled:!1,scheduleDraft:Qi()}}},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},recurringSchedulesSupported(){return this.runtime?.recurringSchedules===!0},createScheduleResult(){return this.form.scheduled?Xi(this.form.scheduleDraft,this.actionNowMs):{}},executionMode(){return this.form.scheduled?"scheduled":this.form.start?"now":"draft"},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 ny({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"},waitingPrompt(){if(this.selected?.status!=="waiting")return null;let e=this.selected.messages?.findLast(r=>r.role==="assistant"&&r.decision),t=this.selected.actions||[];if(e?.role==="assistant"&&e.decision?.kind==="request_human"){let r=t.find(i=>i.id===e.recovery?.actionId&&i.generation===e.recovery?.actionGeneration&&i.status==="waiting");return{question:e.decision.question||this.selected.waitingReason||e.text,action:r||null}}let s=t.find(r=>r.id===this.selected.currentActionId&&r.status==="waiting"),n=s?.canonicalResult?.waitingReason||this.selected.waitingReason;return n?{question:n,action:s||null}:null},replyEntryDisabled(){return this.coordinatorReadOnly||this.detailLoading||!!this.detailError||this.workItemMessageSending||this.workItemMessageAttachmentsUploading||!!this.pendingMessageEnvelope},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?dr(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(`
6880
+ `}});function $r(e){return typeof e=="string"?e.trim():""}function LC(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t.href:""}catch{return""}}function sy(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 Wd(e,t){let s=$r(e?.ref);if(!s)return null;let n=LC(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=sy(t),i=/^(?:[A-Za-z]:[\\/]|[\\/])/.test(s),o=sy(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 ny({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=$C.filter(u=>!n(o.agentId,u)),c=s===!0&&!!(a&&i)&&l.length===0,d=c?Ds(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=Wd(u,i);return g?.type!=="file"?!1:(window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:g.filePath,agentId:o.agentId,conversationId:$n(a),workbenchRoute:o,workbenchRouteKey:a,workspaceGeneration:d}})),!0)}}}var $C,ry=F(()=>{gs();$C=Object.freeze(["workbench_session_routes","workbench_request_correlation","workbench_terminal_cleanup_fence","work_center_workbench"])});function OC(){try{let e=Number(localStorage.getItem("work-center-actions-width"));if(Number.isFinite(e)&&e>=280&&e<=1e4)return e}catch{}return 400}function Ga(e){let t=(Number(e?.workCenterUrlRestoreGeneration)||0)+1;return e&&(e.workCenterUrlRestoreGeneration=t),t}var Ya,Ud=F(()=>{xi();Dr();Zc();It();Ua();Lv();qv();Nv();cd();la();aa();La();Vn();_a();Uv();Kv();ty();Nd();ry();Ai();tn();Mi();$o();Ya={name:"WorkCenterPage",components:{FolderPickerDialog:rn,NavigationIcon:ks,MessageComposer:wa,UserTurnBlock:kr,VpTurnBlock:wr,WorkCenterActionDetail:$v,WorkCenterActionReference:Er,WorkCenterSettingsModal:Hv,AgentSettingsPanel:_r,ModernSelect:Wt,WorkCenterResourceControl:Fv,WorkbenchPanel:Mr,PaneResizeHandle:Wv,WorkCenterSidebar:jv,WorkCenterScheduleEditor:ey},mixins:[Xo],data(){return{sidebarExpanded:window.innerWidth>1100,mobileNavigation:window.innerWidth<=1100,selectedId:null,infoTab:"requirement",workbenchExpanded:!1,selectedActionId:null,narrowPane:"items",contentPanelOpen:!1,actionsPaneWidth:OC(),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,createError:"",scheduleSaving:!1,scheduleDraftStarted:!1,scheduleError:"",createGeneration:0,llmConfigOpen:!1,agentSettingsOpen:!1,agentSettingsTargetId:null,unavailableAgentStateGeneration:0,unavailableAgentStateLoading:!1,unavailableAgentStateError:"",search:"",filtersOpen:!1,createAgentSelection:null,boardVpId:"",boardWorkItemType:"",boardUpdatedRange:"week",mobileBoardLane:"active",deletingWorkItemIds:{},deleteWorkItemError:"",boardQueryTimer:null,actionNowMs:Date.now(),workDirTouched:!1,startTouched:!1,createAttachments:[],createAttachmentUploadCount:0,attachmentsUploading:!1,createAttachmentError:"",deliveryInstructionOptions:[],deliveryInstructionsGeneration:0,previewingAttachmentId:null,attachmentPreviewError:"",attachmentPreviewGeneration:0,form:{requirement:"",workDir:"",deliveryTarget:"",deliveryInstructions:"",reuseMemory:!0,start:!0,scheduled:!1,scheduleDraft:Qi()}}},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},recurringSchedulesSupported(){return this.runtime?.recurringSchedules===!0},createScheduleResult(){return this.form.scheduled?Xi(this.form.scheduleDraft,this.actionNowMs):{}},executionMode(){return this.form.scheduled?"scheduled":this.form.start?"now":"draft"},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 ny({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"},waitingPrompt(){if(this.selected?.status!=="waiting")return null;let e=this.selected.messages?.findLast(r=>r.role==="assistant"&&r.decision),t=this.selected.actions||[];if(e?.role==="assistant"&&e.decision?.kind==="request_human"){let r=t.find(i=>i.id===e.recovery?.actionId&&i.generation===e.recovery?.actionGeneration&&i.status==="waiting");return{question:e.decision.question||this.selected.waitingReason||e.text,action:r||null}}let s=t.find(r=>r.id===this.selected.currentActionId&&r.status==="waiting"),n=s?.canonicalResult?.waitingReason||this.selected.waitingReason;return n?{question:n,action:s||null}:null},replyEntryDisabled(){return this.coordinatorReadOnly||this.detailLoading||!!this.detailError||this.workItemMessageSending||this.workItemMessageAttachmentsUploading||!!this.pendingMessageEnvelope},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?dr(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(`
6875
6881
 
6876
- `),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!!this.selected?.schedule?.recurrence||["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=gi(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 gi(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",this.scheduleError=""},"workbenchContext.workspaceGeneration"(){this.workbenchExpanded=!1},agents:{immediate:!0,deep:!0,handler(){this.loadUnavailableAgentStates()}},agentId:{immediate:!0,handler(e,t){if(Ga(this),this.createGeneration=(Number(this.createGeneration)||0)+1,this.createAttachmentUploadCount=0,this.attachmentsUploading=!1,this.deliveryInstructionOptions=[],this.deliveryInstructionsGeneration+=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(()=>{}),this.createOpen&&this.loadDeliveryInstructionOptions())}},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(){Ga(this),this.createGeneration=(Number(this.createGeneration)||0)+1,this.workItemComposerGeneration+=1,this.unavailableAgentStateGeneration+=1,this.deliveryInstructionsGeneration+=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||"",deliveryInstructions:e.deliveryInstructions||"",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")&&Wd(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 Ei(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){Ga(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=Ga(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=dr(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))},replyToWaitingPrompt(e=null){this.replyEntryDisabled||e&&!this.canMessageAction(e)||!e&&this.coordinatorThinking||(this.composerTargetValue=e?`action:${e.id}:${e.generation}`:"coordinator",this.staleComposerTarget=null,this.workItemMessageError="",this.saveComposerDraft(),(this.$refs.shell?.clientWidth||window.innerWidth)<=900&&this.closeContentPanel(),this.$nextTick(()=>{let t=this.$refs.workItemComposer?.getTextarea?.();t?.scrollIntoView?.({block:"nearest"}),t?.focus?.()}))},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||"",deliveryInstructions:s.deliveryInstructions||"",origin:null,linkedSessionIds:[]}),this.form.workDir="",this.form.start=!0,this.form.scheduled=!1,this.form.scheduleDraft=Qi(),this.scheduleDraftStarted=!1,this.createError="",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},setExecutionMode(e){e==="scheduled"&&!this.scheduleDraftStarted&&(this.form.scheduleDraft=Qi(),this.scheduleDraftStarted=!0),this.form.scheduled=e==="scheduled",this.form.start=e==="now",this.startTouched=!0},scheduleStatusLabel(e){return this.$t("workCenter.scheduling.status."+(e?.status||"scheduled"))},scheduleSummary(e){if(!e)return"";let t=[this.scheduleStatusLabel(e)];if(e.lastError&&e.status==="scheduled"&&t.push(this.$t("workCenter.scheduling.retrying")),e.recurrence&&t.push(this.$t("workCenter.scheduling."+e.recurrence.frequency)),e.scheduledFor&&!["completed","cancelled"].includes(e.status)){let s=e.recurrence?.timeZone;t.push(new Intl.DateTimeFormat(this.$locale?.value||this.$locale||"en",{timeZone:s,dateStyle:"medium",timeStyle:"short",hour12:!1}).format(e.scheduledFor)),s&&t.push(s.replaceAll("_"," "))}return t.join(" \xB7 ")},async setSelectedScheduleEnabled(e){let t=this.selected?.schedule;if(!this.selected||!t||this.selected.status!=="draft"||this.scheduleSaving)return;let s=this.agentId,n=this.selected.id;this.scheduleSaving=!0,this.scheduleError="";try{await this.store.updateWorkItemSchedule(n,{enabled:e,revision:this.selected.revision},s)}catch(r){this.agentId===s&&this.selectedId===n&&(this.scheduleError=r?.message||String(r))}finally{this.scheduleSaving=!1}},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`},async loadDeliveryInstructionOptions(){let e=this.agentId,t=++this.deliveryInstructionsGeneration;if(e)try{let s=await this.store.loadWorkCenterDeliveryInstructions(e);this.agentId===e&&this.deliveryInstructionsGeneration===t&&(this.deliveryInstructionOptions=s)}catch{this.agentId===e&&this.deliveryInstructionsGeneration===t&&(this.deliveryInstructionOptions=[])}},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(),this.loadDeliveryInstructionOptions()},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.createError="",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.form.scheduled?Xi(this.form.scheduleDraft):{};if(t.error||t.recurrence&&!this.recurringSchedulesSupported)return;this.createError="";let s=this.agentId,n=(Number(this.createGeneration)||0)+1;this.createGeneration=n,this.saving=!0;try{let r=this.store.workCenterCreateDraft,i=r?.sourceAgentId===s,o=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,deliveryInstructions:this.form.deliveryInstructions.trim()||null,origin:i&&r.origin||null,linkedSessionIds:i?r.linkedSessionIds||[]:[],attachments:this.workItemAttachmentsSupported?(this.createAttachments||[]).map(a=>({fileId:a.fileId,name:a.name,mimeType:a.mimeType,size:a.size})):[],reuseMemory:this.form.reuseMemory,start:this.form.scheduled?!1:this.form.start,scheduledFor:t.scheduledFor||null,recurrence:t.recurrence||null},s);if(this.agentId!==s||this.createGeneration!==n)return;this.openWorkItem(o.id),this.form={requirement:"",workDir:"",deliveryTarget:"",deliveryInstructions:"",reuseMemory:!0,start:this.settings?.startImmediately!==!1,scheduled:!1,scheduleDraft:Qi()},this.store.workCenterCreateDraft=null,this.createAttachments=[],this.workDirTouched=!1,this.startTouched=!1,this.scheduleDraftStarted=!1,this.createOpen=!1}catch(r){this.agentId===s&&this.createGeneration===n&&(this.createError=r?.message||String(r))}finally{this.agentId===s&&this.createGeneration===n&&(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){if(this.workItemComposerScope===e&&this.actionInputRequestGeneration===l)if(c?.code==="WORK_CENTER_INPUT_STALE"){if(this.clearPendingMessageEnvelope({preserveAttachments:!0}),await this.$nextTick(),this.workItemComposerScope!==e)return;this.workItemMessageError=this.$t("workCenter.inputStale"),this.saveComposerDraft(),this.store.getWorkItem(n,this.agentId).catch(()=>{})}else 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:`
6882
+ `),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!!this.selected?.schedule?.recurrence||["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=gi(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 gi(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",this.scheduleError=""},"workbenchContext.workspaceGeneration"(){this.workbenchExpanded=!1},agents:{immediate:!0,deep:!0,handler(){this.loadUnavailableAgentStates()}},agentId:{immediate:!0,handler(e,t){if(Ga(this),this.createGeneration=(Number(this.createGeneration)||0)+1,this.createAttachmentUploadCount=0,this.attachmentsUploading=!1,this.deliveryInstructionOptions=[],this.deliveryInstructionsGeneration+=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.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1,t&&e!==t&&(this.closeFolderPicker(),this.resetCreateExecutionContext(e,{keepOpen:!!e&&this.createAgentSelection===e})),this.createAgentSelection=null,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(()=>{}),this.createOpen&&this.loadDeliveryInstructionOptions())}},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(){Ga(this),this.createGeneration=(Number(this.createGeneration)||0)+1,this.workItemComposerGeneration+=1,this.unavailableAgentStateGeneration+=1,this.deliveryInstructionsGeneration+=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||"",deliveryInstructions:e.deliveryInstructions||"",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")&&Wd(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)},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 Ei(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){Ga(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=Ga(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=dr(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))},replyToWaitingPrompt(e=null){this.replyEntryDisabled||e&&!this.canMessageAction(e)||!e&&this.coordinatorThinking||(this.composerTargetValue=e?`action:${e.id}:${e.generation}`:"coordinator",this.staleComposerTarget=null,this.workItemMessageError="",this.saveComposerDraft(),(this.$refs.shell?.clientWidth||window.innerWidth)<=900&&this.closeContentPanel(),this.$nextTick(()=>{let t=this.$refs.workItemComposer?.getTextarea?.();t?.scrollIntoView?.({block:"nearest"}),t?.focus?.()}))},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,{keepOpen:t=!1}={}){let s=this.workDirTouched||this.startTouched,n=this.store.workCenterCreateDraft;n&&(this.store.workCenterCreateDraft={sourceAgentId:e||null,requirement:n.requirement||n.goal||n.title||"",workDir:"",deliveryTarget:n.deliveryTarget||"",deliveryInstructions:n.deliveryInstructions||"",origin:null,linkedSessionIds:[]}),this.createAttachments=[],this.createAttachmentError="",this.form.workDir="",this.form.start=!0,this.form.scheduled=!1,this.form.scheduleDraft=Qi(),this.scheduleDraftStarted=!1,this.createError="",this.workDirTouched=!1,this.startTouched=!1,s&&!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},setExecutionMode(e){e==="scheduled"&&!this.scheduleDraftStarted&&(this.form.scheduleDraft=Qi(),this.scheduleDraftStarted=!0),this.form.scheduled=e==="scheduled",this.form.start=e==="now",this.startTouched=!0},scheduleStatusLabel(e){return this.$t("workCenter.scheduling.status."+(e?.status||"scheduled"))},scheduleSummary(e){if(!e)return"";let t=[this.scheduleStatusLabel(e)];if(e.lastError&&e.status==="scheduled"&&t.push(this.$t("workCenter.scheduling.retrying")),e.recurrence&&t.push(this.$t("workCenter.scheduling."+e.recurrence.frequency)),e.scheduledFor&&!["completed","cancelled"].includes(e.status)){let s=e.recurrence?.timeZone;t.push(new Intl.DateTimeFormat(this.$locale?.value||this.$locale||"en",{timeZone:s,dateStyle:"medium",timeStyle:"short",hour12:!1}).format(e.scheduledFor)),s&&t.push(s.replaceAll("_"," "))}return t.join(" \xB7 ")},async setSelectedScheduleEnabled(e){let t=this.selected?.schedule;if(!this.selected||!t||this.selected.status!=="draft"||this.scheduleSaving)return;let s=this.agentId,n=this.selected.id;this.scheduleSaving=!0,this.scheduleError="";try{await this.store.updateWorkItemSchedule(n,{enabled:e,revision:this.selected.revision},s)}catch(r){this.agentId===s&&this.selectedId===n&&(this.scheduleError=r?.message||String(r))}finally{this.scheduleSaving=!1}},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`},async loadDeliveryInstructionOptions(){let e=this.agentId,t=++this.deliveryInstructionsGeneration;if(e)try{let s=await this.store.loadWorkCenterDeliveryInstructions(e);this.agentId===e&&this.deliveryInstructionsGeneration===t&&(this.deliveryInstructionOptions=s)}catch{this.agentId===e&&this.deliveryInstructionsGeneration===t&&(this.deliveryInstructionOptions=[])}},selectCreateAgent(e){this.saving||e===this.agentId||!this.onlineAgents.some(t=>t.id===e)||(this.createAgentSelection=e,this.selectWorkCenterAgent(e))},openCreate(){this.agentId&&(this.mobileNavigation&&(this.sidebarExpanded=!1),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(),this.loadDeliveryInstructionOptions(),this.$nextTick(()=>this.$refs.createRequirement?.focus()))},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.createError="",this.store.workCenterCreateDraft=null)},async submitCreate(){let e=String(this.form.requirement||this.form.goal||this.form.title||"").trim();if(this.saving||this.attachmentsUploading||!this.agentId||!e||!this.form.workDir.trim())return;let t=this.form.scheduled?Xi(this.form.scheduleDraft):{};if(t.error||t.recurrence&&!this.recurringSchedulesSupported)return;this.createError="";let s=this.agentId,n=(Number(this.createGeneration)||0)+1;this.createGeneration=n,this.saving=!0;try{let r=this.store.workCenterCreateDraft,i=r?.sourceAgentId===s,o=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,deliveryInstructions:this.form.deliveryInstructions.trim()||null,origin:i&&r.origin||null,linkedSessionIds:i?r.linkedSessionIds||[]:[],attachments:this.workItemAttachmentsSupported?(this.createAttachments||[]).map(a=>({fileId:a.fileId,name:a.name,mimeType:a.mimeType,size:a.size})):[],reuseMemory:this.form.reuseMemory,start:this.form.scheduled?!1:this.form.start,scheduledFor:t.scheduledFor||null,recurrence:t.recurrence||null},s);if(this.agentId!==s||this.createGeneration!==n)return;this.openWorkItem(o.id),this.form={requirement:"",workDir:"",deliveryTarget:"",deliveryInstructions:"",reuseMemory:!0,start:this.settings?.startImmediately!==!1,scheduled:!1,scheduleDraft:Qi()},this.store.workCenterCreateDraft=null,this.createAttachments=[],this.workDirTouched=!1,this.startTouched=!1,this.scheduleDraftStarted=!1,this.createOpen=!1}catch(r){this.agentId===s&&this.createGeneration===n&&(this.createError=r?.message||String(r))}finally{this.agentId===s&&this.createGeneration===n&&(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){if(this.workItemComposerScope===e&&this.actionInputRequestGeneration===l)if(c?.code==="WORK_CENTER_INPUT_STALE"){if(this.clearPendingMessageEnvelope({preserveAttachments:!0}),await this.$nextTick(),this.workItemComposerScope!==e)return;this.workItemMessageError=this.$t("workCenter.inputStale"),this.saveComposerDraft(),this.store.getWorkItem(n,this.agentId).catch(()=>{})}else 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:`
6877
6883
  <main class="work-center-main" :class="{ 'navigation-open': sidebarExpanded && mobileNavigation }" :aria-label="tr('workCenter.title', 'Work Center')">
6878
6884
  <WorkCenterSidebar ref="navigation" :agents="sidebarAgents" :agent-id="agentId" :item-id="selectedId"
6879
6885
  :action-id="selectedActionId" :expanded="sidebarExpanded"
6880
- @back="backToChat" @collapse="toggleNavigation" @select-agent="selectWorkCenterAgent" @select-item="selectActivity" />
6886
+ @back="backToChat" @collapse="toggleNavigation" @create="openCreate" @select-agent="selectWorkCenterAgent" @select-item="selectActivity" />
6881
6887
  <button v-if="mobileNavigation && sidebarExpanded" class="work-center-sidebar-scrim" type="button" tabindex="-1"
6882
6888
  :aria-label="$t('workCenter.hideNavigation')" @click="toggleNavigation"></button>
6883
6889
  <div ref="shell" class="work-center-shell" :inert="mobileNavigation && sidebarExpanded" :class="{ 'showing-detail': narrowPane !== 'items' }"
@@ -6958,19 +6964,10 @@ ${String(e||"").trim()}
6958
6964
  :title="tr('workCenter.refresh', 'Refresh')" :aria-label="tr('workCenter.refresh', 'Refresh')">
6959
6965
  <NavigationIcon name="refresh" :size="16" />
6960
6966
  </button>
6961
- <button v-if="agentId" class="work-center-icon-button work-center-header-create" type="button" @click="openCreate"
6962
- :title="tr('workCenter.newWorkItem', 'New work item')" :aria-label="tr('workCenter.newWorkItem', 'New work item')">
6963
- <NavigationIcon name="add" :size="16" />
6967
+ <button v-if="agentId" class="work-center-icon-button work-center-header-settings" type="button" @click="settingsOpen = true"
6968
+ :title="tr('workCenter.settings.title', 'Work Center settings')" :aria-label="tr('workCenter.settings.title', 'Work Center settings')">
6969
+ <NavigationIcon name="settings" :size="16" />
6964
6970
  </button>
6965
- <div v-if="agentId" class="work-center-header-menu" @keydown.esc.stop="headerMenuOpen = false; $refs.headerMenuButton.focus()">
6966
- <button ref="headerMenuButton" class="work-center-icon-button" type="button" :aria-expanded="headerMenuOpen" aria-controls="work-center-header-options" @click="headerMenuOpen = !headerMenuOpen"
6967
- :title="tr('workCenter.moreActions', 'More actions')" :aria-label="tr('workCenter.moreActions', 'More actions')">
6968
- <svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true"><g fill="currentColor"><circle cx="5" cy="12" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="19" cy="12" r="2"/></g></svg>
6969
- </button>
6970
- <div v-if="headerMenuOpen" id="work-center-header-options" class="work-center-header-popover">
6971
- <button type="button" @click="headerMenuOpen = false; settingsOpen = true">{{ tr('workCenter.settings.title', 'Work Center settings') }}</button>
6972
- </div>
6973
- </div>
6974
6971
  <template v-if="narrowPane !== 'items' && selected">
6975
6972
  <button
6976
6973
  ref="actionsButton"
@@ -7499,8 +7496,13 @@ ${String(e||"").trim()}
7499
7496
  </header>
7500
7497
  <div class="work-center-modal-body">
7501
7498
  <section class="work-center-form-section work-center-requirement-section">
7499
+ <label>{{ $t('workCenter.selectAgent') }}
7500
+ <select class="work-center-create-agent" :value="agentId" :disabled="saving" @change="selectCreateAgent($event.target.value)">
7501
+ <option v-for="agent in sidebarAgents" :key="agent.id" :value="agent.id" :disabled="!agent.online">{{ agent.name || agent.id }}{{ agent.online ? '' : ' \xB7 ' + $t('workCenter.offline') }}</option>
7502
+ </select>
7503
+ </label>
7502
7504
  <label>{{ tr('workCenter.requirement', 'Requirement') }}
7503
- <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>
7505
+ <textarea ref="createRequirement" 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>
7504
7506
  <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>
7505
7507
  </label>
7506
7508
  </section>
@@ -7562,7 +7564,7 @@ ${String(e||"").trim()}
7562
7564
  <p v-if="createError" class="work-center-error work-center-create-error" role="alert">{{ createError }}</p>
7563
7565
  <footer class="work-center-modal-footer">
7564
7566
  <button class="btn-secondary" type="button" @click="closeCreate">{{ tr('common.cancel', 'Cancel') }}</button>
7565
- <button class="btn-primary" type="submit" :disabled="saving || attachmentsUploading || !form.requirement.trim() || !form.workDir.trim() || !!createScheduleResult.error || (form.scheduled && form.scheduleDraft.frequency !== 'once' && !recurringSchedulesSupported)">
7567
+ <button class="btn-primary" type="submit" :disabled="saving || attachmentsUploading || !agentId || !form.requirement.trim() || !form.workDir.trim() || !!createScheduleResult.error || (form.scheduled && form.scheduleDraft.frequency !== 'once' && !recurringSchedulesSupported)">
7566
7568
  {{ saving ? tr('workCenter.creating', 'Creating\u2026') : form.scheduled ? $t('workCenter.scheduling.create') : tr('workCenter.create', 'Create') }}
7567
7569
  </button>
7568
7570
  </footer>
Binary file
@@ -6,7 +6,7 @@
6
6
  <title>Yeaft</title>
7
7
  <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='8' fill='%232c2c2c'/><path d='M16 22V13M16 13L10 8M16 13L22 8' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round' fill='none'/><circle cx='10' cy='8' r='2.4' fill='white'/><circle cx='22' cy='8' r='2.4' fill='white'/><circle cx='16' cy='22' r='2.4' fill='white'/></svg>">
8
8
  <link rel="stylesheet" href="vendor/katex/katex.min.css?v=b0d91614">
9
- <link rel="stylesheet" href="style.bundle.css?v=0348d229">
9
+ <link rel="stylesheet" href="style.bundle.css?v=5726a739">
10
10
  <script src="vendor.bundle.js?v=b4d2c175"></script>
11
11
  <script defer src="jszip.min.js"></script>
12
12
  <script defer src="docx-preview.min.js"></script>
@@ -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=003b0ae4"></script>
20
+ <script type="module" src="app.bundle.js?v=ed837297"></script>
21
21
  </body>
22
22
  </html>