@yeaft/webchat-agent 1.0.189 → 1.0.190
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.
|
|
1
|
+
{"version":"1.0.190"}
|
|
@@ -4999,7 +4999,7 @@ ${String(e||"").trim()}
|
|
|
4999
4999
|
</div>
|
|
5000
5000
|
</div>
|
|
5001
5001
|
</div>
|
|
5002
|
-
`,directives:{"click-outside":{mounted(e,t){e._clickOutside=s=>{e.contains(s.target)||t.value()},document.addEventListener("click",e._clickOutside)},unmounted(e){document.removeEventListener("click",e._clickOutside)}}},data(){return{loading:!1,loadError:null,localProviders:[],providerModelsText:[],localPrimaryModel:null,localFastModel:null,isDirty:!1,saving:!1,openDropdown:null,showApiKey:{},showPresetPicker:!1,discoveringModels:!1,modelDiscoveryWarning:null,modelDiscoveryError:null}},computed:{chatStore(){return Pinia.useChatStore()},effectiveAgentId(){return this.chatStore.currentAgent},agentOnline(){let e=this.effectiveAgentId;if(!e)return!1;if(this.context==="yeaft")return!0;let t=this.chatStore.agents.find(s=>s.id===e);return t?t.online:!1},currentConfig(){let e=this.effectiveAgentId;return e&&this.chatStore.llmConfig[e]||null},editableProviders(){return this.localProviders},allModelRefs(){let e=this.localProviders,t=[];for(let s of e){if(!s.name)continue;let n=this.parseModelsFromProvider(s);for(let i of n)t.push(`${s.name}/${i}`)}return t}},watch:{effectiveAgentId:{handler(e){e&&this.requestConfig()},immediate:!0},agentOnline(e){e&&!this.currentConfig&&this.effectiveAgentId&&this.requestConfig()},currentConfig:{handler(e){e&&e.loaded&&this.loadFromConfig(e)},deep:!0}},methods:{async copyText(e){try{await navigator.clipboard.writeText(e),this.$emit("message",this.$t("settings.msg.copiedClipboard"),!1)}catch{this.$emit("message",this.$t("settings.msg.copyFailed"),!0)}},async useGitHubCopilotPreset(){let e=this.effectiveAgentId;if(!e||!this.agentOnline)return;this.discoveringModels=!0,this.modelDiscoveryWarning=null,this.modelDiscoveryError=null;let t=`llm-discovery-${Date.now()}-${Math.random().toString(36).slice(2)}`;this.chatStore.sendWsMessage({type:"discover_llm_models",agentId:e,requestId:t,providerType:"github-copilot"});let s=await this.waitForModelDiscovery(e,t);if(this.discoveringModels=!1,s.error){this.modelDiscoveryError=s.error;return}this.applyDiscoveredProvider(s),this.modelDiscoveryWarning=s.warning||null},waitForModelDiscovery(e,t){return new Promise(s=>{let n=Date.now(),i=setInterval(()=>{let r=this.chatStore.llmModelDiscovery?.[e];if(r?.requestId===t){clearInterval(i),s(r);return}Date.now()-n>1e4&&(clearInterval(i),s({error:"Timed out while refreshing provider models."}))},100)})},applyDiscoveredProvider(e){let t={name:e.provider?.name||"github-copilot",credentialProvider:e.provider?.credentialProvider||"github-copilot",managed:e.provider?.managed||"github-copilot",models:Array.isArray(e.providerModels)&&e.providerModels.length?e.providerModels:e.models||[]},s=[...this.localProviders],n=s.findIndex(r=>r?.name===t.name);n>=0?s[n]=t:s.push(t),this.localProviders=s,this.refreshProviderModelsText();let i=this.parseModelsFromProvider(t)[0];i&&!this.localPrimaryModel&&(this.localPrimaryModel=`${t.name}/${i}`),this.markDirty()},requestConfig(){let e=this.effectiveAgentId;if(e){if(!this.agentOnline){this.loading=!1,this.loadError=null;return}this.loading=!0,this.loadError=null,this.chatStore.sendWsMessage({type:"get_llm_config",agentId:e}),this._loadTimeout=setTimeout(()=>{this.loading&&(this.loading=!1,this.loadError="Timeout")},5e3)}},loadFromConfig(e){if(this._loadTimeout&&(clearTimeout(this._loadTimeout),this._loadTimeout=null),this.loading=!1,e.error){this.loadError=e.error;return}this.loadError=null,this.localProviders=(e.agentConfig?.providers||e.providers||[]).map(t=>this.cloneProvider(t)),this.refreshProviderModelsText(),this.localPrimaryModel=e.agentConfig?.primaryModel||e.primaryModel||null,this.localFastModel=e.agentConfig?.fastModel||e.fastModel||null,this.isDirty=!1,this.showApiKey={}},cloneProvider(e){return{type:e.type||"api-key",scope:"agent",name:e.originalName||e.name||"",baseUrl:e.baseUrl||"",apiKey:e.apiKey||"",githubToken:e.githubToken||"",protocol:e.protocol||"openai-responses",credentialProvider:e.credentialProvider||null,models:Array.isArray(e.models)?e.models.map(t=>t&&typeof t=="object"?{...t}:t):[]}},refreshProviderModelsText(){this.providerModelsText=this.editableProviders.map(e=>(e.models||[]).map(t=>this._modelId(t)).join(", "))},parseModelsFromProvider(e){return this.isManagedProvider(e)&&(!Array.isArray(e.models)||e.models.length===0)?this.fallbackCopilotModels():Array.isArray(e.models)?e.models.map(t=>this._modelId(t)).filter(t=>t):[]},_modelId(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.id=="string"?e.id:""},isManagedProvider(e){return e?.managed==="github-copilot"||e?.credentialProvider==="github-copilot"||e?.name==="github-copilot"},fallbackCopilotModels(){return["gpt-5.5","gpt-5.4","gpt-5.4-mini","gpt-5-mini","gpt-5.3-codex","gpt-5.2-codex","gpt-4.1","gpt-4o","gpt-4o-mini","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-sonnet-4.6","claude-sonnet-4.5","claude-haiku-4.5","gemini-2.5-pro"]},addProvider(){this.editableProviders.push({name:"",baseUrl:"",apiKey:"",protocol:"openai",credentialProvider:null,models:[]}),this.providerModelsText.push(""),this.markDirty()},onPresetPick(e){if(this.showPresetPicker=!1,!e||!e.name)return;let t=new Set(this.editableProviders.map(r=>(r.name||"").trim())),s=e.name,n=2;for(;t.has(s);)s=`${e.name}-${n++}`;let i=Array.isArray(e.models)?e.models.filter(Boolean):[];this.editableProviders.push({name:s,baseUrl:e.baseUrl||"",apiKey:"",protocol:e.protocol||"openai",credentialProvider:null,models:i}),this.providerModelsText.push(i.join(", ")),this.markDirty()},removeProvider(e){this.editableProviders.splice(e,1),this.providerModelsText.splice(e,1);let t={};for(let s=0;s<this.editableProviders.length;s++)s<e?t[s]=this.showApiKey[s]:t[s]=this.showApiKey[s+1];this.showApiKey=t,this.markDirty()},onModelsTextChange(e,t){let s=t.target.value;this.providerModelsText[e]=s;let n=Array.isArray(this.editableProviders[e].models)?this.editableProviders[e].models:[],i=new Map;for(let r of n){let o=this._modelId(r);o&&i.set(o,r)}this.editableProviders[e].models=s.split(/[\n,]+/).map(r=>r.trim()).filter(r=>r).map(r=>i.has(r)?i.get(r):r),this.markDirty()},setProtocol(e,t){let s=this.editableProviders[e].protocol;if(this.editableProviders[e].protocol=t,this.markDirty(),(this.editableProviders[e].models||[]).filter(i=>i).length===0&&t!==s){let i=this._getModelPresets(t);i.length>0&&(this.editableProviders[e].models=[...i],this.providerModelsText[e]=i.join(", "))}},protocolLabel(e){return e==="anthropic"?this.$t("settings.llm.protocolAnthropic"):e==="openai-responses"?this.$t("settings.llm.protocolOpenAIResponses"):this.$t("settings.llm.protocolOpenAI")},protocolHint(e){return e==="anthropic"?this.$t("settings.llm.protocolHint.anthropic"):e==="openai-responses"?this.$t("settings.llm.protocolHint.openaiResponses"):this.$t("settings.llm.protocolHint.openai")},_getModelPresets(e){return vo[e]||vo.openai},toggleApiKeyVisibility(e){this.showApiKey={...this.showApiKey,[e]:!this.showApiKey[e]}},toggleDropdown(e){this.openDropdown=this.openDropdown===e?null:e},closeDropdown(e){this.openDropdown===e&&(this.openDropdown=null)},markDirty(){this.isDirty=!0},saveConfig(){let e=this.effectiveAgentId;if(!e||this.saving)return;this.saving=!0;let s={providers:this.editableProviders.filter(i=>i.name&&(this.isManagedProvider(i)||i.baseUrl)).map(i=>{if(this.isManagedProvider(i))return{name:i.name.trim()||"github-copilot",credentialProvider:"github-copilot",managed:i.managed||"github-copilot",models:(i.models||[]).filter(o=>this._modelId(o))};let r={type:i.type||"api-key",name:i.name.trim(),baseUrl:i.baseUrl.trim(),apiKey:i.apiKey||"",githubToken:i.githubToken||"",models:(i.models||[]).filter(o=>this._modelId(o))};return i.protocol&&i.protocol!=="openai"&&(r.protocol=i.protocol),i.credentialProvider&&(r.credentialProvider=i.credentialProvider,r.apiKey=""),r}),primaryModel:this.localPrimaryModel||null};this.context!=="yeaft"&&(s.fastModel=this.localFastModel||null),this.chatStore.sendWsMessage({type:"update_llm_config",agentId:e,config:s}),this._saveTimeout=setTimeout(()=>{this.saving=!1,this.$emit("message",this.$t("settings.llm.saveFailed"),!0)},1e4);let n=this.$watch("currentConfig",i=>{i&&i.loaded&&(this._saveTimeout&&(clearTimeout(this._saveTimeout),this._saveTimeout=null),this.saving=!1,i.error?this.$emit("message",i.error,!0):(this.isDirty=!1,this.$emit("message",this.$t("settings.llm.saved"),!1),this.$emit("saved")),n())},{deep:!0})}},beforeUnmount(){this._loadTimeout&&clearTimeout(this._loadTimeout),this._saveTimeout&&clearTimeout(this._saveTimeout)}}});function gm(){return Eu+=1,`folder-picker-${Date.now()}-${Eu}`}var bo,Eu,wo,mm,_u,ko=N(()=>{bo=()=>({folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",_folderPickerTimer:null,_folderPickerRequestId:null,_folderPickerRequestAgentId:null}),Eu=0;wo={openFolderPicker(){if(!this.folderPickerAgentId||!this.chat||typeof this.chat.sendWsMessage!="function")return;this.folderPickerOpen=!0,this.folderPickerSelected="",this.folderPickerLoading=!0;let t=typeof this.folderPickerInitialDir=="function"?this.folderPickerInitialDir()||"":this.defaultWorkDir||"";this.folderPickerPath=t,this.folderPickerEntries=[],this.requestFolderPickerDir(t)},invalidateFolderPickerRequest(){this._folderPickerRequestId=null,this._folderPickerRequestAgentId=null,this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null)},closeFolderPicker(){this.folderPickerOpen=!1,this.invalidateFolderPickerRequest()},requestFolderPickerDir(e){let t=this.folderPickerAgentId;if(!t||!this.chat||typeof this.chat.sendWsMessage!="function")return;let s=gm();this._folderPickerRequestId=s,this._folderPickerRequestAgentId=t,this.chat.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",requestId:s,agentId:t,dirPath:e,workDir:this.defaultWorkDir||""}),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&this._folderPickerRequestId===s&&this.folderPickerAgentId===t&&this.requestFolderPickerDir(e)},5e3)},loadFolderPickerDir(e){this.folderPickerLoading=!0,this.folderPickerSelected="",this.folderPickerEntries=[],this.requestFolderPickerDir(e)},folderPickerNavigateUp(){if(!this.folderPickerPath)return;let e=this.folderPickerPath.includes("\\"),t=e?"\\":"/",s=this.folderPickerPath.replace(/[/\\]$/,"").split(/[/\\]/);if(s.pop(),s.length===0)this.folderPickerPath="",this.loadFolderPickerDir("");else if(e&&s.length===1&&/^[A-Za-z]:$/.test(s[0]))this.folderPickerPath=s[0]+"\\",this.loadFolderPickerDir(this.folderPickerPath);else{let n=s.join(t);this.folderPickerPath=n,this.loadFolderPickerDir(n)}},folderPickerSelectItem(e){this.folderPickerSelected=e.name},folderPickerEnter(e){let s=this.folderPickerPath.includes("\\")||/^[A-Z]:/.test(e.name)?"\\":"/",n;this.folderPickerPath?n=this.folderPickerPath.replace(/[/\\]$/,"")+s+e.name:n=/^[A-Z]:$/.test(e.name)?e.name+"\\":"/"+e.name,this.folderPickerPath=n,this.loadFolderPickerDir(n)},confirmFolderPicker(){let e=this.folderPickerPath;if(e){if(this.folderPickerSelected){let t=e.includes("\\")?"\\":"/";e=e.replace(/[/\\]$/,"")+t+this.folderPickerSelected}typeof this.folderPickerSetWorkDir=="function"&&this.folderPickerSetWorkDir(e),this.closeFolderPicker()}},handleFolderPickerMessage(e){let t=e.detail;!t||t.type!=="directory_listing"||t.conversationId!=="_workdir_picker"||!this.folderPickerOpen||!this._folderPickerRequestId||t.requestId!==this._folderPickerRequestId||this.folderPickerAgentId!==this._folderPickerRequestAgentId||(this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null),this._folderPickerRequestId=null,this._folderPickerRequestAgentId=null,this.folderPickerLoading=!1,this.folderPickerEntries=(t.entries||[]).filter(s=>s.type==="directory").sort((s,n)=>s.name.localeCompare(n.name)),t.dirPath!=null&&(this.folderPickerPath=t.dirPath))}},mm={data(){return bo()},methods:{...wo},mounted(){window.addEventListener("workbench-message",this.handleFolderPickerMessage)},beforeUnmount(){window.removeEventListener("workbench-message",this.handleFolderPickerMessage),this.invalidateFolderPickerRequest()}},_u=mm});var ki,So=N(()=>{Au();Tu();yo();ko();jn();dr();go();Wt();ki={name:"WorkCenterPage",components:{WorkCenterActionDetail:Iu,WorkCenterSettingsModal:xu,LlmTab:wi},mixins:[_u],data(){return{selectedId:null,selectedActionId:null,narrowPane:"items",actionDetailTab:"messages",actionInputSending:!1,actionInputError:"",actionComposerGeneration:0,detailLoading:!1,detailError:"",createOpen:!1,settingsOpen:!1,saving:!1,llmConfigOpen:!1,filter:"open",search:"",actionGuidance:"",expandedActions:{},actionsExpanded:!1,workDirTouched:!1,startTouched:!1,createAttachments:[],guidanceAttachments:[],attachmentsUploading:!1,guidanceAttachmentsUploading:!1,previewingAttachmentId:null,form:{title:"",goal:"",acceptanceCriteriaText:"",workItemType:"auto",workDir:"",reuseMemory:!0,start:!0}}},computed:{store(){return Pinia.useChatStore()},agentId(){return this.store.workCenterAgentId||this.store.currentAgent},agents(){return this.store.agents||[]},onlineAgents(){return this.agents.filter(e=>e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("work_center"))},watcher(){return this.store.workCenterWatcherByAgent[this.agentId]||null},settings(){return this.store.workCenterSettingsByAgent[this.agentId]||null},runtime(){return this.store.workCenterRuntimeByAgent[this.agentId]||null},workItemTypes(){return Array.isArray(this.runtime?.workItemTypes)?this.runtime.workItemTypes:[]},workItemAttachmentsSupported(){return this.runtime?.workItemAttachments===!0},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},selectedAction(){return(Array.isArray(this.selected?.actions)?this.selected.actions:[]).find(t=>t.id===this.selectedActionId)||null},actionRequestKey(){return this.selected?.id&&this.selectedAction?.id?`${this.agentId}:${this.selected.id}:${this.selectedAction.id}`:""},actionComposerScope(){return this.selected?.id&&this.selectedAction?.id?`${this.agentId}:${this.selected.id}:${this.selectedAction.id}:${this.actionComposerGeneration}`:""},actionMessages(){let e=Array.isArray(this.selectedAction?.messages)?this.selectedAction.messages:[],t=this.store.workCenterActionMessages[this.actionRequestKey]?.messages||[];return Dn(t,e,this.selectedAction?.liveMessage)},actionMessagesNextCursor(){let e=this.store.workCenterActionMessages[this.actionRequestKey];return e?e.nextCursor:this.selectedAction?.messageCursor},actionMessagesLoading(){return!!this.store.workCenterActionMessagesLoading[this.actionRequestKey]},actionMessagesError(){return this.store.workCenterActionMessagesError[this.actionRequestKey]||""},actionRequests(){return this.store.workCenterActionRequests[this.actionRequestKey]||[]},actionRequestDetails(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=Ut(e);return[t,this.store.workCenterActionRequestDetails[`${this.actionRequestKey}:${t}`]||null]})):{}},actionRequestDetailsLoading(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=Ut(e);return[t,!!this.store.workCenterActionRequestDetailsLoading[`${this.actionRequestKey}:${t}`]]})):{}},actionRequestDetailsError(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=Ut(e);return[t,this.store.workCenterActionRequestDetailsError[`${this.actionRequestKey}:${t}`]||""]})):{}},actionRequestsLoading(){return!!this.store.workCenterActionRequestsLoading[this.actionRequestKey]},actionRequestsError(){return this.store.workCenterActionRequestsError[this.actionRequestKey]||""},visibleItems(){let e=this.search.trim().toLowerCase();return this.items.filter(t=>this.filter==="open"&&["done","cancelled"].includes(t.status)||this.filter==="done"&&t.status!=="done"?!1:e?String(t.title||"").toLowerCase().includes(e)||String(t.goal||"").toLowerCase().includes(e):!0)},listHeading(){return this.filter==="done"?this.tr("workCenter.completedItems","Completed"):this.filter==="all"?this.tr("workCenter.allItems","All work items"):this.tr("workCenter.activeItems","Active work")},emptyState(){return this.search.trim()?{title:this.tr("workCenter.noMatchesTitle","No matching work items"),body:this.tr("workCenter.noMatchesBody","Try a different search or filter."),canCreate:!1}:this.filter==="done"?{title:this.tr("workCenter.noCompletedTitle","No completed work items"),body:this.tr("workCenter.noCompletedBody","Completed work items will appear here."),canCreate:!1}:this.filter==="open"&&this.items.length>0?{title:this.tr("workCenter.noOpenTitle","No open work items"),body:this.tr("workCenter.noOpenBody","Open work items will appear here."),canCreate:!0}:{title:this.tr("workCenter.emptyTitle","No work items yet"),body:this.tr("workCenter.emptyBody","Create a persistent task when work must continue beyond one conversation turn."),canCreate:!0}}},watch:{agentId:{immediate:!0,handler(e,t){this.selectedId=null,this.selectedActionId=null,this.resetActionComposer?.(),this.narrowPane="items",t&&e!==t&&(this.closeFolderPicker(),this.resetCreateExecutionContext(e)),e&&(this.store.listWorkItems(e).catch(()=>{}),this.store.loadWorkCenterSettings(e).catch(()=>{}))}},createDefaultWorkDir(){this.applyCreateDefaults()},createDefaultStart(){this.applyCreateDefaults()},detail:{deep:!0,handler(e){if(!e||e.id!==this.selectedId)return;let t=Array.isArray(e.actions)?e.actions:[];if(!t.some(s=>s.id===this.selectedActionId)){let s=e.currentActionId||t[0]?.id||null;s!==this.selectedActionId&&this.resetActionComposer(),this.selectedActionId=s}}}},mounted(){let e=this.store.workCenterCreateDraft;e&&(this.form={title:e.title||"",goal:e.goal||"",acceptanceCriteriaText:"",workItemType:"auto",workDir:e.workDir||"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.createOpen=!0,this.workDirTouched=!!String(e.workDir||"").trim(),this.startTouched=!1,this.applyCreateDefaults())},methods:{trackOverlayPointerDown:tt,trackOverlayPointerUp:st,clearOverlayPointerGesture:nt,closeLlmConfigFromOverlay(e){Ze(e)&&(this.llmConfigOpen=!1)},tr(e,t){let s=this.$t?this.$t(e):e;return s&&s!==e?s:t},agentName(e){return this.agents.find(s=>s.id===e)?.name||e||this.tr("workCenter.agent","Agent")},statusLabel(e){return this.tr(`workCenter.status.${e}`,String(e||"").replace("_"," "))},actionLabel(e){return this.tr(`workCenter.action.${e}`,e||"\u2014")},time(e){if(!e)return"";try{return new Date(Number(e)).toLocaleString()}catch{return""}},refresh(){return this.store.listWorkItems(this.agentId).catch(()=>{})},resetActionComposer(){this.actionComposerGeneration+=1,this.actionGuidance="",this.actionInputError="",this.guidanceAttachments=[],this.guidanceAttachmentsUploading=!1,this.actionInputSending=!1},async selectItem(e){this.selectedId=e.id,this.selectedActionId=null,this.narrowPane="actions",this.resetActionComposer(),this.expandedActions={},this.actionsExpanded=!1,this.detailError="",this.detailLoading=!0;try{let t=await this.store.getWorkItem(e.id,this.agentId);this.selectedId===e.id&&(this.selectedActionId=t?.currentActionId||t?.actions?.[0]?.id||null)}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.resetActionComposer(),this.selectedActionId=e.id,this.narrowPane="action",this.loadLatestActionMessages(e)},loadLatestActionMessages(e=this.selectedAction){if(!this.selected?.id||!e?.id||Array.isArray(e.messages))return null;let t=`${this.agentId}:${this.selected.id}:${e.id}`;return this.store.workCenterActionMessages[t]?null:this.store.loadWorkItemActionMessages(this.selected.id,e.id,null,this.agentId).catch(()=>null)},showItemsPane(){this.narrowPane="items"},showActionsPane(){this.narrowPane="actions"},loadEarlierActionMessages(){return!this.selected?.id||!this.selectedAction?.id||this.actionMessagesNextCursor==null?null:this.store.loadWorkItemActionMessages(this.selected.id,this.selectedAction.id,this.actionMessagesNextCursor,this.agentId).catch(()=>null)},async refreshActionRequests(){return!this.selected?.id||!this.selectedAction?.id?[]:this.store.loadWorkItemActionRequests(this.selected.id,this.selectedAction.id,this.agentId).catch(()=>[])},loadActionRequest(e){return!this.selected?.id||!this.selectedAction?.id||!e?.id?null:this.store.loadWorkItemActionRequest(this.selected.id,this.selectedAction.id,e.runId,e.id,this.agentId).catch(()=>null)},actionHasDetail(e){return!!e?.brief||Array.isArray(e?.messages)&&e.messages.length>0||!!String(e?.response||"").trim()||!!String(e?.failureReason||"").trim()},actionExpanded(e){return!!this.expandedActions[e?.id]},toggleAction(e){this.actionHasDetail(e)&&(this.expandedActions={...this.expandedActions,[e.id]:!this.expandedActions[e.id]})},actionResponseText(e){return String(e?.response||"").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,title:s.title||"",goal:s.goal||"",workDir:"",origin:null,linkedSessionIds:[]}),this.form.workDir="",this.form.start=!0,this.workDirTouched=!1,this.startTouched=!1,t&&(this.createOpen=!1),this.applyCreateDefaults()},applyCreateDefaults(){this.createOpen&&(!this.workDirTouched&&!this.form.workDir.trim()&&(this.form.workDir=this.createDefaultWorkDir),this.startTouched||(this.form.start=this.createDefaultStart))},folderPickerInitialDir(){return this.form.workDir.trim()||this.createDefaultWorkDir},folderPickerSetWorkDir(e){this.form.workDir=e,this.workDirTouched=!0},onCreateStartInput(){this.startTouched=!0},async onCreateAttachmentInput(e){if(!this.workItemAttachmentsSupported)throw e.target.value="",new Error(this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments."));let t=Array.from(e.target.files||[]);if(e.target.value="",t.length===0)return;let s=Math.max(0,10-this.createAttachments.length),n=t.slice(0,s);if(n.length!==0){this.attachmentsUploading=!0;try{let i=new FormData;for(let d of n)i.append("files",d,d.name||"attachment");let r=Pinia.useAuthStore(),o=r.getActiveToken?.()||r.token||null,a=o?{Authorization:`Bearer ${o}`}:{},l=await fetch("/api/upload",{method:"POST",headers:a,body:i});if((l.status===401||l.status===403)&&r.handleAuthFailure?.(void 0,o),!l.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let c=await l.json();this.createAttachments=[...this.createAttachments,...Array.isArray(c.files)?c.files:[]].slice(0,10)}finally{this.attachmentsUploading=!1}}},removeCreateAttachment(e){this.createAttachments=this.createAttachments.filter((t,s)=>s!==e)},async onGuidanceAttachmentInput(e){if(!this.workItemAttachmentsSupported)throw e.target.value="",new Error(this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments."));let t=Array.from(e.target.files||[]);if(e.target.value="",t.length===0)return;let s=this.actionComposerScope;if(!s)return;let n=Array.isArray(this.selected?.attachments)?this.selected.attachments.length:0,i=Math.max(0,10-n-this.guidanceAttachments.length),r=t.slice(0,i);if(r.length!==0){this.guidanceAttachmentsUploading=!0,this.actionInputError="";try{let o=new FormData;for(let f of r)o.append("files",f,f.name||"attachment");let a=Pinia.useAuthStore(),l=a.getActiveToken?.()||a.token||null,c=l?{Authorization:`Bearer ${l}`}:{},d=await fetch("/api/upload",{method:"POST",headers:c,body:o});if((d.status===401||d.status===403)&&a.handleAuthFailure?.(void 0,l),!d.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let u=await d.json();if(this.actionComposerScope!==s)return;this.guidanceAttachments=[...this.guidanceAttachments,...Array.isArray(u.files)?u.files:[]].slice(0,Math.max(0,10-n))}catch(o){this.actionComposerScope===s&&(this.actionInputError=o?.message||String(o))}finally{this.actionComposerScope===s&&(this.guidanceAttachmentsUploading=!1)}}},removeGuidanceAttachment(e){this.guidanceAttachments=this.guidanceAttachments.filter((t,s)=>s!==e)},async previewAttachment(e){if(!this.selected?.id||!e?.id||this.previewingAttachmentId)return;let t=e.isImage?null:window.open("","_blank");t&&(t.opener=null),this.previewingAttachmentId=e.id;try{let s=await this.store.previewWorkItemAttachment(this.selected.id,e.id,this.agentId);s?.preview&&s.attachment?.isImage?ds(s.preview):s?.preview&&t?t.location.replace(s.preview):t?.close()}catch(s){throw t?.close(),s}finally{this.previewingAttachmentId=null}},formatAttachmentSize(e){let t=Math.max(0,Number(e)||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`},openCreate(){this.createOpen=!0,this.workDirTouched=!1,this.startTouched=!1,this.applyCreateDefaults()},closeCreate(){this.saving||(this.closeFolderPicker(),this.createOpen=!1,this.store.workCenterCreateDraft=null)},onLlmConfigSaved(){let e=this.agentId;if(e)return this.store.refreshWorkCenterRuntime(e).catch(()=>{})},async submitCreate(){if(!(!this.form.title.trim()||!this.form.goal.trim()||!this.form.workDir.trim())){this.saving=!0;try{let e=this.store.workCenterCreateDraft,t=e?.sourceAgentId===this.agentId,s=await this.store.createWorkItem({title:this.form.title.trim(),goal:this.form.goal.trim(),acceptanceCriteria:this.form.acceptanceCriteriaText.split(`
|
|
5002
|
+
`,directives:{"click-outside":{mounted(e,t){e._clickOutside=s=>{e.contains(s.target)||t.value()},document.addEventListener("click",e._clickOutside)},unmounted(e){document.removeEventListener("click",e._clickOutside)}}},data(){return{loading:!1,loadError:null,localProviders:[],providerModelsText:[],localPrimaryModel:null,localFastModel:null,isDirty:!1,saving:!1,openDropdown:null,showApiKey:{},showPresetPicker:!1,discoveringModels:!1,modelDiscoveryWarning:null,modelDiscoveryError:null}},computed:{chatStore(){return Pinia.useChatStore()},effectiveAgentId(){return this.chatStore.currentAgent},agentOnline(){let e=this.effectiveAgentId;if(!e)return!1;if(this.context==="yeaft")return!0;let t=this.chatStore.agents.find(s=>s.id===e);return t?t.online:!1},currentConfig(){let e=this.effectiveAgentId;return e&&this.chatStore.llmConfig[e]||null},editableProviders(){return this.localProviders},allModelRefs(){let e=this.localProviders,t=[];for(let s of e){if(!s.name)continue;let n=this.parseModelsFromProvider(s);for(let i of n)t.push(`${s.name}/${i}`)}return t}},watch:{effectiveAgentId:{handler(e){e&&this.requestConfig()},immediate:!0},agentOnline(e){e&&!this.currentConfig&&this.effectiveAgentId&&this.requestConfig()},currentConfig:{handler(e){e&&e.loaded&&this.loadFromConfig(e)},deep:!0}},methods:{async copyText(e){try{await navigator.clipboard.writeText(e),this.$emit("message",this.$t("settings.msg.copiedClipboard"),!1)}catch{this.$emit("message",this.$t("settings.msg.copyFailed"),!0)}},async useGitHubCopilotPreset(){let e=this.effectiveAgentId;if(!e||!this.agentOnline)return;this.discoveringModels=!0,this.modelDiscoveryWarning=null,this.modelDiscoveryError=null;let t=`llm-discovery-${Date.now()}-${Math.random().toString(36).slice(2)}`;this.chatStore.sendWsMessage({type:"discover_llm_models",agentId:e,requestId:t,providerType:"github-copilot"});let s=await this.waitForModelDiscovery(e,t);if(this.discoveringModels=!1,s.error){this.modelDiscoveryError=s.error;return}this.applyDiscoveredProvider(s),this.modelDiscoveryWarning=s.warning||null},waitForModelDiscovery(e,t){return new Promise(s=>{let n=Date.now(),i=setInterval(()=>{let r=this.chatStore.llmModelDiscovery?.[e];if(r?.requestId===t){clearInterval(i),s(r);return}Date.now()-n>1e4&&(clearInterval(i),s({error:"Timed out while refreshing provider models."}))},100)})},applyDiscoveredProvider(e){let t={name:e.provider?.name||"github-copilot",credentialProvider:e.provider?.credentialProvider||"github-copilot",managed:e.provider?.managed||"github-copilot",models:Array.isArray(e.providerModels)&&e.providerModels.length?e.providerModels:e.models||[]},s=[...this.localProviders],n=s.findIndex(r=>r?.name===t.name);n>=0?s[n]=t:s.push(t),this.localProviders=s,this.refreshProviderModelsText();let i=this.parseModelsFromProvider(t)[0];i&&!this.localPrimaryModel&&(this.localPrimaryModel=`${t.name}/${i}`),this.markDirty()},requestConfig(){let e=this.effectiveAgentId;if(e){if(!this.agentOnline){this.loading=!1,this.loadError=null;return}this.loading=!0,this.loadError=null,this.chatStore.sendWsMessage({type:"get_llm_config",agentId:e}),this._loadTimeout=setTimeout(()=>{this.loading&&(this.loading=!1,this.loadError="Timeout")},5e3)}},loadFromConfig(e){if(this._loadTimeout&&(clearTimeout(this._loadTimeout),this._loadTimeout=null),this.loading=!1,e.error){this.loadError=e.error;return}this.loadError=null,this.localProviders=(e.agentConfig?.providers||e.providers||[]).map(t=>this.cloneProvider(t)),this.refreshProviderModelsText(),this.localPrimaryModel=e.agentConfig?.primaryModel||e.primaryModel||null,this.localFastModel=e.agentConfig?.fastModel||e.fastModel||null,this.isDirty=!1,this.showApiKey={}},cloneProvider(e){return{type:e.type||"api-key",scope:"agent",name:e.originalName||e.name||"",baseUrl:e.baseUrl||"",apiKey:e.apiKey||"",githubToken:e.githubToken||"",protocol:e.protocol||"openai-responses",credentialProvider:e.credentialProvider||null,models:Array.isArray(e.models)?e.models.map(t=>t&&typeof t=="object"?{...t}:t):[]}},refreshProviderModelsText(){this.providerModelsText=this.editableProviders.map(e=>(e.models||[]).map(t=>this._modelId(t)).join(", "))},parseModelsFromProvider(e){return this.isManagedProvider(e)&&(!Array.isArray(e.models)||e.models.length===0)?this.fallbackCopilotModels():Array.isArray(e.models)?e.models.map(t=>this._modelId(t)).filter(t=>t):[]},_modelId(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.id=="string"?e.id:""},isManagedProvider(e){return e?.managed==="github-copilot"||e?.credentialProvider==="github-copilot"||e?.name==="github-copilot"},fallbackCopilotModels(){return["gpt-5.5","gpt-5.4","gpt-5.4-mini","gpt-5-mini","gpt-5.3-codex","gpt-5.2-codex","gpt-4.1","gpt-4o","gpt-4o-mini","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-sonnet-4.6","claude-sonnet-4.5","claude-haiku-4.5","gemini-2.5-pro"]},addProvider(){this.editableProviders.push({name:"",baseUrl:"",apiKey:"",protocol:"openai",credentialProvider:null,models:[]}),this.providerModelsText.push(""),this.markDirty()},onPresetPick(e){if(this.showPresetPicker=!1,!e||!e.name)return;let t=new Set(this.editableProviders.map(r=>(r.name||"").trim())),s=e.name,n=2;for(;t.has(s);)s=`${e.name}-${n++}`;let i=Array.isArray(e.models)?e.models.filter(Boolean):[];this.editableProviders.push({name:s,baseUrl:e.baseUrl||"",apiKey:"",protocol:e.protocol||"openai",credentialProvider:null,models:i}),this.providerModelsText.push(i.join(", ")),this.markDirty()},removeProvider(e){this.editableProviders.splice(e,1),this.providerModelsText.splice(e,1);let t={};for(let s=0;s<this.editableProviders.length;s++)s<e?t[s]=this.showApiKey[s]:t[s]=this.showApiKey[s+1];this.showApiKey=t,this.markDirty()},onModelsTextChange(e,t){let s=t.target.value;this.providerModelsText[e]=s;let n=Array.isArray(this.editableProviders[e].models)?this.editableProviders[e].models:[],i=new Map;for(let r of n){let o=this._modelId(r);o&&i.set(o,r)}this.editableProviders[e].models=s.split(/[\n,]+/).map(r=>r.trim()).filter(r=>r).map(r=>i.has(r)?i.get(r):r),this.markDirty()},setProtocol(e,t){let s=this.editableProviders[e].protocol;if(this.editableProviders[e].protocol=t,this.markDirty(),(this.editableProviders[e].models||[]).filter(i=>i).length===0&&t!==s){let i=this._getModelPresets(t);i.length>0&&(this.editableProviders[e].models=[...i],this.providerModelsText[e]=i.join(", "))}},protocolLabel(e){return e==="anthropic"?this.$t("settings.llm.protocolAnthropic"):e==="openai-responses"?this.$t("settings.llm.protocolOpenAIResponses"):this.$t("settings.llm.protocolOpenAI")},protocolHint(e){return e==="anthropic"?this.$t("settings.llm.protocolHint.anthropic"):e==="openai-responses"?this.$t("settings.llm.protocolHint.openaiResponses"):this.$t("settings.llm.protocolHint.openai")},_getModelPresets(e){return vo[e]||vo.openai},toggleApiKeyVisibility(e){this.showApiKey={...this.showApiKey,[e]:!this.showApiKey[e]}},toggleDropdown(e){this.openDropdown=this.openDropdown===e?null:e},closeDropdown(e){this.openDropdown===e&&(this.openDropdown=null)},markDirty(){this.isDirty=!0},saveConfig(){let e=this.effectiveAgentId;if(!e||this.saving)return;this.saving=!0;let s={providers:this.editableProviders.filter(i=>i.name&&(this.isManagedProvider(i)||i.baseUrl)).map(i=>{if(this.isManagedProvider(i))return{name:i.name.trim()||"github-copilot",credentialProvider:"github-copilot",managed:i.managed||"github-copilot",models:(i.models||[]).filter(o=>this._modelId(o))};let r={type:i.type||"api-key",name:i.name.trim(),baseUrl:i.baseUrl.trim(),apiKey:i.apiKey||"",githubToken:i.githubToken||"",models:(i.models||[]).filter(o=>this._modelId(o))};return i.protocol&&i.protocol!=="openai"&&(r.protocol=i.protocol),i.credentialProvider&&(r.credentialProvider=i.credentialProvider,r.apiKey=""),r}),primaryModel:this.localPrimaryModel||null};this.context!=="yeaft"&&(s.fastModel=this.localFastModel||null),this.chatStore.sendWsMessage({type:"update_llm_config",agentId:e,config:s}),this._saveTimeout=setTimeout(()=>{this.saving=!1,this.$emit("message",this.$t("settings.llm.saveFailed"),!0)},1e4);let n=this.$watch("currentConfig",i=>{i&&i.loaded&&(this._saveTimeout&&(clearTimeout(this._saveTimeout),this._saveTimeout=null),this.saving=!1,i.error?this.$emit("message",i.error,!0):(this.isDirty=!1,this.$emit("message",this.$t("settings.llm.saved"),!1),this.$emit("saved")),n())},{deep:!0})}},beforeUnmount(){this._loadTimeout&&clearTimeout(this._loadTimeout),this._saveTimeout&&clearTimeout(this._saveTimeout)}}});function gm(){return Eu+=1,`folder-picker-${Date.now()}-${Eu}`}var bo,Eu,wo,mm,_u,ko=N(()=>{bo=()=>({folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",_folderPickerTimer:null,_folderPickerRequestId:null,_folderPickerRequestAgentId:null}),Eu=0;wo={openFolderPicker(){if(!this.folderPickerAgentId||!this.chat||typeof this.chat.sendWsMessage!="function")return;this.folderPickerOpen=!0,this.folderPickerSelected="",this.folderPickerLoading=!0;let t=typeof this.folderPickerInitialDir=="function"?this.folderPickerInitialDir()||"":this.defaultWorkDir||"";this.folderPickerPath=t,this.folderPickerEntries=[],this.requestFolderPickerDir(t)},invalidateFolderPickerRequest(){this._folderPickerRequestId=null,this._folderPickerRequestAgentId=null,this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null)},closeFolderPicker(){this.folderPickerOpen=!1,this.invalidateFolderPickerRequest()},requestFolderPickerDir(e){let t=this.folderPickerAgentId;if(!t||!this.chat||typeof this.chat.sendWsMessage!="function")return;let s=gm();this._folderPickerRequestId=s,this._folderPickerRequestAgentId=t,this.chat.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",requestId:s,agentId:t,dirPath:e,workDir:this.defaultWorkDir||""}),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&this._folderPickerRequestId===s&&this.folderPickerAgentId===t&&this.requestFolderPickerDir(e)},5e3)},loadFolderPickerDir(e){this.folderPickerLoading=!0,this.folderPickerSelected="",this.folderPickerEntries=[],this.requestFolderPickerDir(e)},folderPickerNavigateUp(){if(!this.folderPickerPath)return;let e=this.folderPickerPath.includes("\\"),t=e?"\\":"/",s=this.folderPickerPath.replace(/[/\\]$/,"").split(/[/\\]/);if(s.pop(),s.length===0)this.folderPickerPath="",this.loadFolderPickerDir("");else if(e&&s.length===1&&/^[A-Za-z]:$/.test(s[0]))this.folderPickerPath=s[0]+"\\",this.loadFolderPickerDir(this.folderPickerPath);else{let n=s.join(t);this.folderPickerPath=n,this.loadFolderPickerDir(n)}},folderPickerSelectItem(e){this.folderPickerSelected=e.name},folderPickerEnter(e){let s=this.folderPickerPath.includes("\\")||/^[A-Z]:/.test(e.name)?"\\":"/",n;this.folderPickerPath?n=this.folderPickerPath.replace(/[/\\]$/,"")+s+e.name:n=/^[A-Z]:$/.test(e.name)?e.name+"\\":"/"+e.name,this.folderPickerPath=n,this.loadFolderPickerDir(n)},confirmFolderPicker(){let e=this.folderPickerPath;if(e){if(this.folderPickerSelected){let t=e.includes("\\")?"\\":"/";e=e.replace(/[/\\]$/,"")+t+this.folderPickerSelected}typeof this.folderPickerSetWorkDir=="function"&&this.folderPickerSetWorkDir(e),this.closeFolderPicker()}},handleFolderPickerMessage(e){let t=e.detail;!t||t.type!=="directory_listing"||t.conversationId!=="_workdir_picker"||!this.folderPickerOpen||!this._folderPickerRequestId||t.requestId!==this._folderPickerRequestId||this.folderPickerAgentId!==this._folderPickerRequestAgentId||(this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null),this._folderPickerRequestId=null,this._folderPickerRequestAgentId=null,this.folderPickerLoading=!1,this.folderPickerEntries=(t.entries||[]).filter(s=>s.type==="directory").sort((s,n)=>s.name.localeCompare(n.name)),t.dirPath!=null&&(this.folderPickerPath=t.dirPath))}},mm={data(){return bo()},methods:{...wo},mounted(){window.addEventListener("workbench-message",this.handleFolderPickerMessage)},beforeUnmount(){window.removeEventListener("workbench-message",this.handleFolderPickerMessage),this.invalidateFolderPickerRequest()}},_u=mm});var ki,So=N(()=>{Au();Tu();yo();ko();jn();dr();go();Wt();ki={name:"WorkCenterPage",components:{WorkCenterActionDetail:Iu,WorkCenterSettingsModal:xu,LlmTab:wi},mixins:[_u],data(){return{selectedId:null,selectedActionId:null,narrowPane:"items",actionDetailTab:"messages",actionInputSending:!1,actionInputError:"",actionComposerGeneration:0,detailLoading:!1,detailError:"",createOpen:!1,settingsOpen:!1,saving:!1,llmConfigOpen:!1,filter:"open",search:"",actionGuidance:"",expandedActions:{},actionsExpanded:!1,workDirTouched:!1,startTouched:!1,createAttachments:[],guidanceAttachments:[],attachmentsUploading:!1,guidanceAttachmentsUploading:!1,previewingAttachmentId:null,form:{title:"",goal:"",acceptanceCriteriaText:"",workItemType:"auto",workDir:"",reuseMemory:!0,start:!0}}},computed:{store(){return Pinia.useChatStore()},chat(){return this.store},agentId(){return this.store.workCenterAgentId||this.store.currentAgent},agents(){return this.store.agents||[]},onlineAgents(){return this.agents.filter(e=>e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("work_center"))},watcher(){return this.store.workCenterWatcherByAgent[this.agentId]||null},settings(){return this.store.workCenterSettingsByAgent[this.agentId]||null},runtime(){return this.store.workCenterRuntimeByAgent[this.agentId]||null},workItemTypes(){return Array.isArray(this.runtime?.workItemTypes)?this.runtime.workItemTypes:[]},workItemAttachmentsSupported(){return this.runtime?.workItemAttachments===!0},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},selectedAction(){return(Array.isArray(this.selected?.actions)?this.selected.actions:[]).find(t=>t.id===this.selectedActionId)||null},actionRequestKey(){return this.selected?.id&&this.selectedAction?.id?`${this.agentId}:${this.selected.id}:${this.selectedAction.id}`:""},actionComposerScope(){return this.selected?.id&&this.selectedAction?.id?`${this.agentId}:${this.selected.id}:${this.selectedAction.id}:${this.actionComposerGeneration}`:""},actionMessages(){let e=Array.isArray(this.selectedAction?.messages)?this.selectedAction.messages:[],t=this.store.workCenterActionMessages[this.actionRequestKey]?.messages||[];return Dn(t,e,this.selectedAction?.liveMessage)},actionMessagesNextCursor(){let e=this.store.workCenterActionMessages[this.actionRequestKey];return e?e.nextCursor:this.selectedAction?.messageCursor},actionMessagesLoading(){return!!this.store.workCenterActionMessagesLoading[this.actionRequestKey]},actionMessagesError(){return this.store.workCenterActionMessagesError[this.actionRequestKey]||""},actionRequests(){return this.store.workCenterActionRequests[this.actionRequestKey]||[]},actionRequestDetails(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=Ut(e);return[t,this.store.workCenterActionRequestDetails[`${this.actionRequestKey}:${t}`]||null]})):{}},actionRequestDetailsLoading(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=Ut(e);return[t,!!this.store.workCenterActionRequestDetailsLoading[`${this.actionRequestKey}:${t}`]]})):{}},actionRequestDetailsError(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=Ut(e);return[t,this.store.workCenterActionRequestDetailsError[`${this.actionRequestKey}:${t}`]||""]})):{}},actionRequestsLoading(){return!!this.store.workCenterActionRequestsLoading[this.actionRequestKey]},actionRequestsError(){return this.store.workCenterActionRequestsError[this.actionRequestKey]||""},visibleItems(){let e=this.search.trim().toLowerCase();return this.items.filter(t=>this.filter==="open"&&["done","cancelled"].includes(t.status)||this.filter==="done"&&t.status!=="done"?!1:e?String(t.title||"").toLowerCase().includes(e)||String(t.goal||"").toLowerCase().includes(e):!0)},listHeading(){return this.filter==="done"?this.tr("workCenter.completedItems","Completed"):this.filter==="all"?this.tr("workCenter.allItems","All work items"):this.tr("workCenter.activeItems","Active work")},emptyState(){return this.search.trim()?{title:this.tr("workCenter.noMatchesTitle","No matching work items"),body:this.tr("workCenter.noMatchesBody","Try a different search or filter."),canCreate:!1}:this.filter==="done"?{title:this.tr("workCenter.noCompletedTitle","No completed work items"),body:this.tr("workCenter.noCompletedBody","Completed work items will appear here."),canCreate:!1}:this.filter==="open"&&this.items.length>0?{title:this.tr("workCenter.noOpenTitle","No open work items"),body:this.tr("workCenter.noOpenBody","Open work items will appear here."),canCreate:!0}:{title:this.tr("workCenter.emptyTitle","No work items yet"),body:this.tr("workCenter.emptyBody","Create a persistent task when work must continue beyond one conversation turn."),canCreate:!0}}},watch:{agentId:{immediate:!0,handler(e,t){this.selectedId=null,this.selectedActionId=null,this.resetActionComposer?.(),this.narrowPane="items",t&&e!==t&&(this.closeFolderPicker(),this.resetCreateExecutionContext(e)),e&&(this.store.listWorkItems(e).catch(()=>{}),this.store.loadWorkCenterSettings(e).catch(()=>{}))}},createDefaultWorkDir(){this.applyCreateDefaults()},createDefaultStart(){this.applyCreateDefaults()},detail:{deep:!0,handler(e){if(!e||e.id!==this.selectedId)return;let t=Array.isArray(e.actions)?e.actions:[];if(!t.some(s=>s.id===this.selectedActionId)){let s=e.currentActionId||t[0]?.id||null;s!==this.selectedActionId&&this.resetActionComposer(),this.selectedActionId=s}}}},mounted(){let e=this.store.workCenterCreateDraft;e&&(this.form={title:e.title||"",goal:e.goal||"",acceptanceCriteriaText:"",workItemType:"auto",workDir:e.workDir||"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.createOpen=!0,this.workDirTouched=!!String(e.workDir||"").trim(),this.startTouched=!1,this.applyCreateDefaults())},methods:{trackOverlayPointerDown:tt,trackOverlayPointerUp:st,clearOverlayPointerGesture:nt,closeLlmConfigFromOverlay(e){Ze(e)&&(this.llmConfigOpen=!1)},tr(e,t){let s=this.$t?this.$t(e):e;return s&&s!==e?s:t},agentName(e){return this.agents.find(s=>s.id===e)?.name||e||this.tr("workCenter.agent","Agent")},statusLabel(e){return this.tr(`workCenter.status.${e}`,String(e||"").replace("_"," "))},actionLabel(e){return this.tr(`workCenter.action.${e}`,e||"\u2014")},time(e){if(!e)return"";try{return new Date(Number(e)).toLocaleString()}catch{return""}},refresh(){return this.store.listWorkItems(this.agentId).catch(()=>{})},resetActionComposer(){this.actionComposerGeneration+=1,this.actionGuidance="",this.actionInputError="",this.guidanceAttachments=[],this.guidanceAttachmentsUploading=!1,this.actionInputSending=!1},async selectItem(e){this.selectedId=e.id,this.selectedActionId=null,this.narrowPane="actions",this.resetActionComposer(),this.expandedActions={},this.actionsExpanded=!1,this.detailError="",this.detailLoading=!0;try{let t=await this.store.getWorkItem(e.id,this.agentId);this.selectedId===e.id&&(this.selectedActionId=t?.currentActionId||t?.actions?.[0]?.id||null)}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.resetActionComposer(),this.selectedActionId=e.id,this.narrowPane="action",this.loadLatestActionMessages(e)},loadLatestActionMessages(e=this.selectedAction){if(!this.selected?.id||!e?.id||Array.isArray(e.messages))return null;let t=`${this.agentId}:${this.selected.id}:${e.id}`;return this.store.workCenterActionMessages[t]?null:this.store.loadWorkItemActionMessages(this.selected.id,e.id,null,this.agentId).catch(()=>null)},showItemsPane(){this.narrowPane="items"},showActionsPane(){this.narrowPane="actions"},loadEarlierActionMessages(){return!this.selected?.id||!this.selectedAction?.id||this.actionMessagesNextCursor==null?null:this.store.loadWorkItemActionMessages(this.selected.id,this.selectedAction.id,this.actionMessagesNextCursor,this.agentId).catch(()=>null)},async refreshActionRequests(){return!this.selected?.id||!this.selectedAction?.id?[]:this.store.loadWorkItemActionRequests(this.selected.id,this.selectedAction.id,this.agentId).catch(()=>[])},loadActionRequest(e){return!this.selected?.id||!this.selectedAction?.id||!e?.id?null:this.store.loadWorkItemActionRequest(this.selected.id,this.selectedAction.id,e.runId,e.id,this.agentId).catch(()=>null)},actionHasDetail(e){return!!e?.brief||Array.isArray(e?.messages)&&e.messages.length>0||!!String(e?.response||"").trim()||!!String(e?.failureReason||"").trim()},actionExpanded(e){return!!this.expandedActions[e?.id]},toggleAction(e){this.actionHasDetail(e)&&(this.expandedActions={...this.expandedActions,[e.id]:!this.expandedActions[e.id]})},actionResponseText(e){return String(e?.response||"").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,title:s.title||"",goal:s.goal||"",workDir:"",origin:null,linkedSessionIds:[]}),this.form.workDir="",this.form.start=!0,this.workDirTouched=!1,this.startTouched=!1,t&&(this.createOpen=!1),this.applyCreateDefaults()},applyCreateDefaults(){this.createOpen&&(!this.workDirTouched&&!this.form.workDir.trim()&&(this.form.workDir=this.createDefaultWorkDir),this.startTouched||(this.form.start=this.createDefaultStart))},folderPickerInitialDir(){return this.form.workDir.trim()||this.createDefaultWorkDir},folderPickerSetWorkDir(e){this.form.workDir=e,this.workDirTouched=!0},onCreateWorkDirInput(){this.workDirTouched=!0},onCreateStartInput(){this.startTouched=!0},async onCreateAttachmentInput(e){if(!this.workItemAttachmentsSupported)throw e.target.value="",new Error(this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments."));let t=Array.from(e.target.files||[]);if(e.target.value="",t.length===0)return;let s=Math.max(0,10-this.createAttachments.length),n=t.slice(0,s);if(n.length!==0){this.attachmentsUploading=!0;try{let i=new FormData;for(let d of n)i.append("files",d,d.name||"attachment");let r=Pinia.useAuthStore(),o=r.getActiveToken?.()||r.token||null,a=o?{Authorization:`Bearer ${o}`}:{},l=await fetch("/api/upload",{method:"POST",headers:a,body:i});if((l.status===401||l.status===403)&&r.handleAuthFailure?.(void 0,o),!l.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let c=await l.json();this.createAttachments=[...this.createAttachments,...Array.isArray(c.files)?c.files:[]].slice(0,10)}finally{this.attachmentsUploading=!1}}},removeCreateAttachment(e){this.createAttachments=this.createAttachments.filter((t,s)=>s!==e)},async onGuidanceAttachmentInput(e){if(!this.workItemAttachmentsSupported)throw e.target.value="",new Error(this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments."));let t=Array.from(e.target.files||[]);if(e.target.value="",t.length===0)return;let s=this.actionComposerScope;if(!s)return;let n=Array.isArray(this.selected?.attachments)?this.selected.attachments.length:0,i=Math.max(0,10-n-this.guidanceAttachments.length),r=t.slice(0,i);if(r.length!==0){this.guidanceAttachmentsUploading=!0,this.actionInputError="";try{let o=new FormData;for(let f of r)o.append("files",f,f.name||"attachment");let a=Pinia.useAuthStore(),l=a.getActiveToken?.()||a.token||null,c=l?{Authorization:`Bearer ${l}`}:{},d=await fetch("/api/upload",{method:"POST",headers:c,body:o});if((d.status===401||d.status===403)&&a.handleAuthFailure?.(void 0,l),!d.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let u=await d.json();if(this.actionComposerScope!==s)return;this.guidanceAttachments=[...this.guidanceAttachments,...Array.isArray(u.files)?u.files:[]].slice(0,Math.max(0,10-n))}catch(o){this.actionComposerScope===s&&(this.actionInputError=o?.message||String(o))}finally{this.actionComposerScope===s&&(this.guidanceAttachmentsUploading=!1)}}},removeGuidanceAttachment(e){this.guidanceAttachments=this.guidanceAttachments.filter((t,s)=>s!==e)},async previewAttachment(e){if(!this.selected?.id||!e?.id||this.previewingAttachmentId)return;let t=e.isImage?null:window.open("","_blank");t&&(t.opener=null),this.previewingAttachmentId=e.id;try{let s=await this.store.previewWorkItemAttachment(this.selected.id,e.id,this.agentId);s?.preview&&s.attachment?.isImage?ds(s.preview):s?.preview&&t?t.location.replace(s.preview):t?.close()}catch(s){throw t?.close(),s}finally{this.previewingAttachmentId=null}},formatAttachmentSize(e){let t=Math.max(0,Number(e)||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`},openCreate(){this.createOpen=!0,this.workDirTouched=!1,this.startTouched=!1,this.applyCreateDefaults()},closeCreate(){this.saving||(this.closeFolderPicker(),this.createOpen=!1,this.store.workCenterCreateDraft=null)},onLlmConfigSaved(){let e=this.agentId;if(e)return this.store.refreshWorkCenterRuntime(e).catch(()=>{})},async submitCreate(){if(!(!this.form.title.trim()||!this.form.goal.trim()||!this.form.workDir.trim())){this.saving=!0;try{let e=this.store.workCenterCreateDraft,t=e?.sourceAgentId===this.agentId,s=await this.store.createWorkItem({title:this.form.title.trim(),goal:this.form.goal.trim(),acceptanceCriteria:this.form.acceptanceCriteriaText.split(`
|
|
5003
5003
|
`).map(n=>n.trim()).filter(Boolean),workItemType:this.form.workItemType||"auto",workDir:this.form.workDir.trim(),origin:t&&e.origin||null,linkedSessionIds:t?e.linkedSessionIds||[]:[],attachments:this.workItemAttachmentsSupported?(this.createAttachments||[]).map(n=>({fileId:n.fileId,name:n.name,mimeType:n.mimeType,size:n.size})):[],reuseMemory:this.form.reuseMemory,start:this.form.start},this.agentId);this.selectedId=s.id,this.form={title:"",goal:"",acceptanceCriteriaText:"",workItemType:"auto",workDir:"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.store.workCenterCreateDraft=null,this.createAttachments=[],this.workDirTouched=!1,this.startTouched=!1,this.createOpen=!1}finally{this.saving=!1}}},async startSelected(){this.selected&&await this.store.startWorkItem(this.selected.id,this.agentId)},async guideSelectedAction(){if(!this.selected||!this.selectedAction||!this.actionGuidance.trim()&&this.guidanceAttachments.length===0)return;let e=this.selected.workflowSnapshot?.executionMode==="graph"&&["waiting","failed"].includes(this.selectedAction.status);if(this.selected.currentActionId!==this.selectedAction.id&&!e)return;let t=this.actionComposerScope,s=this.selected.id,n=this.selectedAction.id,i=this.selected.revision,r=this.actionGuidance.trim(),o=this.guidanceAttachments.map(a=>({fileId:a.fileId,name:a.name,mimeType:a.mimeType,size:a.size}));this.actionInputSending=!0,this.actionInputError="";try{let a=await this.store.sendWorkItemActionInput(s,r,n,i,o,this.agentId);if(this.actionComposerScope!==t)return;this.actionGuidance="",this.guidanceAttachments=[];let l=a?.currentActionId||this.selectedActionId;l!==this.selectedActionId&&this.resetActionComposer(),this.selectedActionId=l}catch(a){this.actionComposerScope===t&&(this.actionInputError=a?.message||String(a))}finally{this.actionComposerScope===t&&(this.actionInputSending=!1)}},async cancelSelected(){this.selected&&await this.store.cancelWorkItem(this.selected.id,this.agentId)}},template:`
|
|
5004
5004
|
<main class="work-center-main" :class="{ 'workbench-maximized': store.workbenchMaximized && store.workbenchExpanded }">
|
|
5005
5005
|
<div class="work-center-shell">
|
|
@@ -5286,7 +5286,7 @@ ${String(e||"").trim()}
|
|
|
5286
5286
|
</div>
|
|
5287
5287
|
<label>{{ tr('workCenter.workDir', 'Working directory') }}
|
|
5288
5288
|
<div class="work-center-workdir-picker">
|
|
5289
|
-
<input v-model="form.workDir" type="text" required
|
|
5289
|
+
<input v-model="form.workDir" type="text" required @input="onCreateWorkDirInput" :placeholder="tr('workCenter.workDirHint', 'Choose an existing project directory')">
|
|
5290
5290
|
<button class="btn-secondary" type="button" @click="openFolderPicker" :disabled="!folderPickerAgentId">
|
|
5291
5291
|
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true"><path fill="currentColor" d="M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2Z"/></svg>
|
|
5292
5292
|
{{ tr('workCenter.chooseFolder', 'Choose folder') }}
|
|
Binary file
|
package/package.json
CHANGED