@kern0x1b/penstock-cli 26.10.2 → 26.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/penstock.js +159 -159
- package/dist/web/assets/{AgentSettings-Iy9ZaTGR.js → AgentSettings-C-1YBic4.js} +1 -1
- package/dist/web/assets/{AgentsDialog-Dt09_TEw.js → AgentsDialog-CSu8pyh7.js} +1 -1
- package/dist/web/assets/{BpmnCanvas-CCRBnGIV.js → BpmnCanvas-DnBLxMNQ.js} +1 -1
- package/dist/web/assets/{BpmnDocument-D2lXXcnN.js → BpmnDocument-BPpyqTzJ.js} +8 -8
- package/dist/web/assets/{ConflictDialog-CaBNoJST.js → ConflictDialog-nygfF7Dn.js} +1 -1
- package/dist/web/assets/{DiffDocument-BjLzoDLL.js → DiffDocument-DUrje9io.js} +1 -1
- package/dist/web/assets/{DmnDocument-BSGTyR3r.js → DmnDocument-fn7AH7P1.js} +11 -11
- package/dist/web/assets/FormDocument-BbyRqjib.js +32 -0
- package/dist/web/assets/{FormStepView-BEDXMPef.js → FormStepView-BYRMBW0U.js} +1 -1
- package/dist/web/assets/{GraphAwareLayoutService-CZCVRb9X.js → GraphAwareLayoutService-BiLVDmB7.js} +1 -1
- package/dist/web/assets/{NewFileDialog-D9nTKDOT.js → NewFileDialog-Ce_cTeOv.js} +1 -1
- package/dist/web/assets/{QuickOpen-D3AkwBdF.js → QuickOpen-D-u9hdSt.js} +1 -1
- package/dist/web/assets/{ScriptPane-4TG-1RyI.js → ScriptPane-BQorfmyv.js} +2 -2
- package/dist/web/assets/{ScriptRunDialog-C2n9cLcf.js → ScriptRunDialog-DjBW0LRD.js} +1 -1
- package/dist/web/assets/{SettingsDialog-BUft2ulJ.js → SettingsDialog-DvYUAKpH.js} +1 -1
- package/dist/web/assets/{ShortcutsDialog-Naoea994.js → ShortcutsDialog-BQ5BYHj3.js} +1 -1
- package/dist/web/assets/{SourceDocument-PMA1dm6T.js → SourceDocument-BfHVXxuk.js} +1 -1
- package/dist/web/assets/{TextDocument-D4fl42FV.js → TextDocument-BPepqeGu.js} +1 -1
- package/dist/web/assets/UnreadableFileLayer-D5B6nixz.js +1 -0
- package/dist/web/assets/{UploadDialog-CEnwtJ3T.js → UploadDialog-BzIvQ1YS.js} +1 -1
- package/dist/web/assets/{apply-DwO6xN9h.js → apply-B0vauBJn.js} +1 -1
- package/dist/web/assets/{bpmnTheme-iB2hl29R.js → bpmnTheme-Divwrkjy.js} +1 -1
- package/dist/web/assets/{bridgeInstance-CJkr34d9.js → bridgeInstance-D0bzpNGz.js} +1 -1
- package/dist/web/assets/{commands-BMjdyegc.js → commands-N2yKHjf_.js} +1 -1
- package/dist/web/assets/de-izeWpfua.js +1 -0
- package/dist/web/assets/{dialog-wo7dFa5A.js → dialog-DSf66Ory.js} +1 -1
- package/dist/web/assets/{diff-BmEImmS0.js → diff-DkfgVbKD.js} +1 -1
- package/dist/web/assets/documentBridge-DSWBQZRP.js +240 -0
- package/dist/web/assets/{documents-BwU2MdUd.js → documents-C4vr2KnQ.js} +1 -1
- package/dist/web/assets/{duplicate-rWDlHiZr.js → duplicate-C-AiqE1T.js} +1 -1
- package/dist/web/assets/{engines-C3gTrVWJ.js → engines-DG8KgTeX.js} +1 -1
- package/dist/web/assets/es-CRMYEYWD.js +1 -0
- package/dist/web/assets/{formChecks-DXIRZuhX.js → formChecks-B_ZFz9DR.js} +1 -1
- package/dist/web/assets/fr-8pTyPyAI.js +1 -0
- package/dist/web/assets/{frontend-By89859W.js → frontend-BLfXy4OQ.js} +1 -1
- package/dist/web/assets/{httpHost-_QDw41Ka.js → httpHost-Cll6HteE.js} +1 -1
- package/dist/web/assets/{index.es-CVOua_f9.js → index.es-B0wi5_fv.js} +1 -1
- package/dist/web/assets/{index.es-DHW5-gbr.js → index.es-DQAdm_u9.js} +1 -1
- package/dist/web/assets/{intelligence-BnJILPl7.js → intelligence-glU4hcHy.js} +1 -1
- package/dist/web/assets/ja-I1fjeFMy.js +1 -0
- package/dist/web/assets/{jspdf.es.min-Yw43YJzU.js → jspdf.es.min-xdeBAA_m.js} +3 -3
- package/dist/web/assets/ko-CFd9C-RA.js +1 -0
- package/dist/web/assets/{lib-D6xZQFAF.js → lib-DJ1i09sd.js} +1 -1
- package/dist/web/assets/platform-BS7bgwr3.js +2 -0
- package/dist/web/assets/{preferences-C7SSy7Wf.js → preferences-C_EXTz45.js} +1 -1
- package/dist/web/assets/pt-BR-Dl_APu95.js +1 -0
- package/dist/web/assets/ru-_vhcOTod.js +1 -0
- package/dist/web/assets/{run-Dd_PjDF8.js → run-Df8AD_as.js} +1 -1
- package/dist/web/assets/{samples-DfOV2cQu.js → samples-chRLnLcq.js} +1 -1
- package/dist/web/assets/{testCaseRuns-6x2pl8U_.js → testCaseRuns-DLEqANBi.js} +1 -1
- package/dist/web/assets/translator-CS9eR0My.js +1 -0
- package/dist/web/assets/{ui-B2q39Bca.js → ui-AICOEtWR.js} +1 -1
- package/dist/web/assets/{useTrace-BbcYW5PF.js → useTrace-B3gDUL0X.js} +1 -1
- package/dist/web/assets/{web-D7xTiPek.js → web-BtxFF0jJ.js} +6 -6
- package/dist/web/assets/zh-Do_q1RZ2.js +1 -0
- package/dist/web/index.html +19 -19
- package/package.json +1 -1
- package/dist/web/assets/FormDocument-BdCKvI-7.js +0 -32
- package/dist/web/assets/UnreadableFileLayer-DuWtY1bx.js +0 -1
- package/dist/web/assets/de-BDwOyJ4E.js +0 -1
- package/dist/web/assets/documentBridge-uW6vNrY3.js +0 -240
- package/dist/web/assets/es-B4wrlqk9.js +0 -1
- package/dist/web/assets/fr-BqtYruiB.js +0 -1
- package/dist/web/assets/ja-B6eG6Wld.js +0 -1
- package/dist/web/assets/ko-Le3hTKqP.js +0 -1
- package/dist/web/assets/platform-PXoldsjF.js +0 -2
- package/dist/web/assets/pt-BR-aDlgSu84.js +0 -1
- package/dist/web/assets/ru-DJl9EFpu.js +0 -1
- package/dist/web/assets/translator-CTBxdhz9.js +0 -1
- package/dist/web/assets/zh-CaEk-YOk.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-B8BYMn-z.js";import{c as e,h as t,i as n,r,s as i,u as a}from"./vendor-NJP34MHU.js";import{i as o,n as s}from"./translator-CTBxdhz9.js";import{t as c}from"./bridgeInstance-CJkr34d9.js";import{n as l,r as u}from"./httpHost-_QDw41Ka.js";import{c as d,n as f}from"./ui-B2q39Bca.js";import{i as p,r as m}from"./preferences-C7SSy7Wf.js";var h=[`off`,`bottom`,`sidebar`],g=`bottom`;function aiChatPlaceOf(e){return h.find(t=>t===e)??`bottom`}function aiChatSurfaces(e){let t=e!==`off`;return{bottomInput:e===`bottom`,card:e===`bottom`,chatTab:t,chatsList:t,toolbarButton:t,paletteAction:t,agentProcess:t}}var _=null;function registerAgentsOpener(e){return _=e,()=>{_===e&&(_=null)}}async function openAgentsScreen(){if(_)_();else try{await c().agentsHost?.().openSettings()}catch(e){console.error(`The AI agents screen did not open:`,e)}}function normalise(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/+$/,``)}function pathsMatch(e,t){return normalise(e)===normalise(t)}function baseName(e){return normalise(e).split(`/`).filter(Boolean).pop()??e}var v=1e3,y=15e3,b=2e3,x={status:`loading`,entries:[],queue:[],permission:null,error:null,options:[]},S={text:``,mentions:[],dismissed:[],focus:0};function isLicenceRefusal(e){return e instanceof u&&e.status===402}function newClientId(){return`c${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`}function upsert(e,t){let n=e.findIndex(e=>e.id===t.id);if(n<0){let n=[...e,t];return n.length>b?n.slice(n.length-b):n}let r=e.slice();return r[n]=t,r}function withPlan(e,t){let n=-1;for(let t=e.length-1;t>=0;--t)if(e[t].kind===`plan`){n=t;break}if(n<0)return upsert(e,{kind:`plan`,id:`plan`,items:t});let r=e.slice();return r[n]={kind:`plan`,id:e[n].id,items:t},r}function withApproved(e,t){let n=e.status===`done`&&e.diffs.length===0?t?.get(l(e)):void 0;return n?{...e,diffs:n}:e}function applyToTranscript(e,t,n){switch(t.type){case`entry`:{let r=t.entry.kind===`tool`?{...t.entry,tool:withApproved(t.entry.tool,n)}:t.entry,i=e.entries.find(e=>e.id===r.id);return i&&JSON.stringify(i)===JSON.stringify(r)?e:{...e,entries:upsert(e.entries,r)}}case`tool`:return{...e,entries:upsert(e.entries,{kind:`tool`,id:l(t.tool),tool:withApproved(t.tool,n)})};case`plan`:return{...e,entries:withPlan(e.entries,t.items)};case`queue`:return{...e,queue:t.queue};case`permission`:return{...e,permission:t.permission};case`error`:return{...e,error:t.error};case`options`:return{...e,options:t.options};default:return e}}function sameChats(e,t){return e.length===t.length&&e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t[n]))}var AssistantStore=class{state;listeners=new Set;host;options;client;pending=new Map;approved=new Map;loading=new Map;openings=new Set;expected=null;waitingChat=null;manage;control=null;started=!1;disposed=!1;failures=0;resyncing=null;constructor(e,t={}){this.host=e,this.options=t,this.client=t.client??newClientId(),this.manage=t.onManageAgents??null;let n=t.place?t.place():g;this.state={enabled:n!==`off`,place:n,loaded:!1,connected:!1,choices:[],chats:[],transcripts:{},active:{},shown:{},folded:{},revealed:{},focused:null,agentId:null,drafts:{},picks:{},canManageAgents:!!t.onManageAgents,failure:null}}snapshot=()=>this.state;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});commit(e){this.state={...this.state,...e},this.recordOpenings();for(let e of[...this.listeners])try{e()}catch(e){console.error(`An assistant listener failed:`,e)}}recordOpenings(){for(let e of Object.keys(this.state.active))!this.openings.has(e)&&this.settled(e)&&this.openings.add(e)}settled(e){if(!this.state.loaded)return!1;let t=this.activeChat(e);if(t===null)return!0;let n=this.state.transcripts[t.id];return n!==void 0&&n.status!==`loading`}opened(e){return!this.state.enabled||this.openings.has(e)}describe(e){return e instanceof u&&e.failure?e.failure:{key:`app.agent.failed`,detail:e instanceof Error?e.message:String(e)}}wait(e){return this.options.wait?this.options.wait(e):new Promise(t=>setTimeout(t,e))}allowed(){return!this.options.place||this.options.place()!==`off`}setPlace(e){if(e===this.state.place)return;let t=e!==`off`;this.commit({place:e,enabled:t}),t?this.started&&this.begin():this.halt()}start(){return this.disposed?Promise.resolve():(this.started=!0,this.allowed()?(this.state.enabled||this.commit({enabled:!0}),this.control&&!this.control.signal.aborted?Promise.resolve():this.begin()):(this.state.enabled&&this.commit({enabled:!1}),Promise.resolve()))}begin(){let e=new AbortController;this.control=e;let t=this.resync();return this.pump(e),t}halt(){this.control?.abort(),this.control=null,this.commit({connected:!1})}dispose(){this.disposed=!0,this.started=!1,this.halt(),this.listeners.clear()}async pump(e){for(;!e.signal.aborted;)try{let t=await this.host.next(this.client,e.signal);if(e.signal.aborted)return;this.failures>0&&(this.failures=0,this.state.connected||this.commit({connected:!0})),t&&this.receive(t)}catch{if(e.signal.aborted)return;this.failures+=1,this.state.connected&&this.commit({connected:!1});let t=Math.min(this.options.maxRetryMs??y,(this.options.retryMs??v)*2**Math.min(this.failures-1,6));if(await this.wait(t),e.signal.aborted)return;await this.resync()}}resync(){if(this.resyncing)return this.resyncing;let e=(async()=>{try{let[e,t]=await Promise.all([this.host.choices().catch(()=>this.state.choices),this.host.chats()]);this.commit({choices:e,loaded:!0,connected:!0,enabled:t.enabled&&this.allowed(),failure:null}),this.takeChats(t.chats);let n=Object.keys(this.state.transcripts);await Promise.all(n.map(e=>this.fetchChat(e,!0)))}catch(e){this.state.loaded||this.commit({loaded:!0}),this.commit({failure:this.describe(e)})}finally{this.resyncing=null}})();return this.resyncing=e,e}takeChats(e){let t=new Set(e.map(e=>e.id)),n=Object.fromEntries(Object.entries(this.state.active).map(([e,n])=>[e,n!==null&&t.has(n)?n:null])),r=Object.fromEntries(Object.entries(this.state.transcripts).filter(([e])=>t.has(e))),i=this.state.chats,a=!sameChats(i,e),o=Object.entries(n).some(([e,t])=>t!==this.state.active[e])||Object.keys(r).length!==Object.keys(this.state.transcripts).length;if(a||o){for(let t of e){let e=i.find(e=>e.id===t.id);(t.state===`working`||t.state===`waiting`||t.state===`connecting`||t.state===`failed`)&&e?.state!==t.state&&(this.state={...this.state,shown:{...this.state.shown,[t.id]:!0}},t.state===`waiting`&&(this.state={...this.state,folded:{...this.state.folded,[t.id]:!1}}))}this.commit({chats:e,active:n,transcripts:r});for(let t of e){let e=i.find(e=>e.id===t.id);t.state===`waiting`&&e?.state!==`waiting`&&this.revealWaiting(t.id),t.state===`waiting`&&!this.state.transcripts[t.id]&&this.open(t.id)}}}receive(e){switch(e.type){case`sync`:this.resync();return;case`chats`:this.takeChats(e.chats);return;case`enabled`:this.commit({enabled:e.enabled&&this.allowed()});return;default:{let t=e.chatId,n=this.state.transcripts[t];if(!n){this.state.chats.some(e=>e.id===t)&&(this.pending.set(t,[...this.pending.get(t)??[],e]),this.open(t));return}if(n.status===`loading`){this.pending.set(t,[...this.pending.get(t)??[],e]);return}let r=applyToTranscript(n,e,this.approved);if(r===n)return;e.type===`options`&&this.learn(t);let i={transcripts:{...this.state.transcripts,[t]:r}};if(e.type===`permission`&&e.permission&&e.permission.id!==n.permission?.id){i.folded={...this.state.folded,[t]:!1},i.shown={...this.state.shown,[t]:!0},this.commit(i),this.revealWaiting(t);return}this.commit(i)}}}fetchChat(e,t){let n=this.loading.get(e);if(n)return n;let r=this.state.transcripts[e];!t||!r?this.commit({transcripts:{...this.state.transcripts,[e]:{...r??x,status:`loading`}}}):this.commit({transcripts:{...this.state.transcripts,[e]:{...r,status:`loading`}}});let i=(async()=>{try{let t=await this.host.chat(e),n={status:`ready`,entries:t.entries,queue:t.queue,permission:t.permission,error:t.error,options:t.options};for(let t of this.pending.get(e)??[])n=applyToTranscript(n,t,this.approved);this.pending.delete(e),this.state.chats.some(t=>t.id===e)&&this.commit({transcripts:{...this.state.transcripts,[e]:n}}),this.mergeSummary(t)}catch(t){this.pending.delete(e);let n=t instanceof u?t.status:null,r={...this.state.transcripts};n===404?delete r[e]:r[e]={...r[e]??x,status:`failed`},this.commit({transcripts:r})}finally{this.loading.delete(e)}})();return this.loading.set(e,i),i}mergeSummary(e){let t=this.state.chats.findIndex(t=>t.id===e.chat.id);if(t<0||JSON.stringify(this.state.chats[t])===JSON.stringify(e.chat))return;let n=this.state.chats.slice();n[t]=e.chat,this.commit({chats:n})}open(e){let t=this.state.transcripts[e];return t&&t.status!==`failed`&&t.status!==`missing`?this.loading.get(e)??Promise.resolve():this.fetchChat(e,!1)}focus(e){if(e!==this.state.focused&&(this.commit({focused:e}),e&&this.waitingChat)){let e=this.waitingChat;this.waitingChat=null,this.openChat(e)}}unfocus(e){this.state.focused===e&&this.commit({focused:null})}activeChat(e){let t=e?this.state.active[e]:null;return t?this.state.chats.find(e=>e.id===t)??null:null}select(e,t){this.commit({active:{...this.state.active,[e]:t}}),t&&this.open(t)}expectChat(e,t){this.expected={chatId:e,file:t}}settle(e,t){if(!this.state.loaded)return;if(this.expected&&t&&pathsMatch(this.expected.file,t)){let{chatId:t}=this.expected;this.expected=null,this.select(e,t);return}if(e in this.state.active)return;let n=(t?this.state.chats.filter(e=>e.files.some(e=>pathsMatch(e,t))):[]).reduce((e,t)=>e===null||t.updated>e.updated?t:e,null);this.select(e,n?.id??null)}get onManageAgents(){return this.manage}setManageAgents(e){return this.manage=e,this.commit({canManageAgents:e!==null}),()=>{this.manage===e&&(this.manage=null,this.commit({canManageAgents:!1}))}}changeAgent(e,t){this.activeChat(e)&&this.select(e,null),this.pickAgent(t)}pickAgent(e){this.commit({agentId:e,picks:{}})}learn(e){let t=this.state.chats.find(t=>t.id===e)?.agentId,n=this.state.choices.find(e=>e.id===t);!n||(n.options??[]).length>0||this.host.choices().then(e=>this.commit({choices:e}),()=>void 0)}async pickOption(e,t,n,r){if(!t){let t=this.agentFor(null);if(!t)return;let i=this.state.picks[e],a=i&&i.agentId===t?i.values:{};this.commit({picks:{...this.state.picks,[e]:{agentId:t,values:{...a,[n.id]:r}}}});return}let i=this.state.transcripts[t.id],chosen=e=>e.map(e=>e.id===n.id?{...e,current:r}:e);i&&this.commit({transcripts:{...this.state.transcripts,[t.id]:{...i,options:chosen(i.options)}}});try{let e=await this.host.setOption(t.id,n.id,r),i=this.state.transcripts[t.id];i&&this.commit({transcripts:{...this.state.transcripts,[t.id]:{...i,options:e}}})}catch(e){let n=this.state.transcripts[t.id];n&&i&&this.commit({transcripts:{...this.state.transcripts,[t.id]:{...n,options:i.options}}}),this.commit({failure:this.describe(e)})}}agentFor(e){return e?e.agentId:this.state.agentId?this.state.agentId:this.state.choices.find(e=>e.available)?.id??null}reveal(e){this.commit({revealed:{...this.state.revealed,[e]:(this.state.revealed[e]??0)+1}})}revealWaiting(e){if(this.state.place===`sidebar`)for(let[t,n]of Object.entries(this.state.active))n===e&&this.reveal(t)}openChat(e){let t=this.state.focused;t?(this.select(t,e),this.reveal(t)):this.waitingChat=e}showCard(e){this.commit({shown:{...this.state.shown,[e]:!0},folded:{...this.state.folded,[e]:!1}})}returnToCard(e){let t=this.activeChat(e);t&&this.state.place===`bottom`&&this.showCard(t.id)}setFolded(e,t){!!this.state.folded[e]!==t&&this.commit({folded:{...this.state.folded,[e]:t}})}dismissCard(e){this.commit({shown:{...this.state.shown,[e]:!1}})}draft(e){return this.state.drafts[e]??S}setDraft(e,t){this.commit({drafts:{...this.state.drafts,[e]:{...this.draft(e),...t}}})}setText(e,t){t!==this.draft(e).text&&this.setDraft(e,{text:t})}mention(e,t){let n=this.draft(e),r=mentionKey(t);n.mentions.some(e=>mentionKey(e)===r)||this.setDraft(e,{mentions:[...n.mentions,t],dismissed:n.dismissed.filter(e=>e!==r)})}unmention(e,t){let n=this.draft(e);this.setDraft(e,{mentions:n.mentions.filter(e=>mentionKey(e)!==t),dismissed:n.dismissed.includes(t)?n.dismissed:[...n.dismissed,t]})}releaseDismissed(e,t){let n=this.draft(e),r=n.dismissed.filter(e=>!e.startsWith(C)||t.includes(e.slice(C.length)));r.length!==n.dismissed.length&&this.setDraft(e,{dismissed:r})}focusInput(e){this.state.place===`sidebar`&&this.reveal(e),this.setDraft(e,{focus:this.draft(e).focus+1})}compose(e,t,n){let r=this.draft(e),i=r.text.trim()===``?n:r.text.includes(n)?r.text:`${r.text.trimEnd()}\n${n}`,a=mentionKey(t),o=r.mentions.some(e=>mentionKey(e)===a)?r.mentions:[...r.mentions,t];this.setDraft(e,{text:i,mentions:o,dismissed:r.dismissed.filter(e=>e!==a),focus:r.focus+1})}clearDraft(e){this.setDraft(e,{text:``,mentions:[]})}async create(e,t=null){try{let n=await this.host.create(t??this.agentFor(null));return this.takeChats([n,...this.state.chats.filter(e=>e.id!==n.id)]),this.commit({transcripts:{...this.state.transcripts,[n.id]:{status:`ready`,entries:[],queue:[],permission:null,error:null,options:[]}}}),e&&this.select(e,n.id),n}catch(e){return this.commit({failure:this.describe(e)}),null}}async rename(e,t){let n=t.trim();if(n)try{let t=await this.host.rename(e,n);this.takeChats(this.state.chats.map(e=>e.id===t.id?t:e))}catch(e){this.commit({failure:this.describe(e)})}}async remove(e){try{await this.host.remove(e)}catch(e){if(!(e instanceof u&&e.status===404)){this.commit({failure:this.describe(e)});return}}this.takeChats(this.state.chats.filter(t=>t.id!==e))}async send(e){let t=e.text.trim();if(!t)return`refused`;let n=this.activeChat(e.editor);if(!await e.authorize())return`refused`;let r=n===null;try{if(!n){if(n=await this.create(e.editor),!n)return`failed`;await this.applyPicks(e.editor,n)}let r=n.id;return this.state.place===`sidebar`?(this.reveal(e.editor),this.commit({failure:null})):this.commit({shown:{...this.state.shown,[r]:!0},folded:{...this.state.folded,[r]:!1},failure:null}),(await this.host.prompt(r,t,e.context)).queued?`queued`:`sent`}catch(t){return isLicenceRefusal(t)?(r&&n&&await this.discard(e.editor,n.id),await e.authorize(),`refused`):(this.commit({failure:this.describe(t)}),`failed`)}}async discard(e,t){this.select(e,null),await this.remove(t)}async applyPicks(e,t){let n=this.state.picks[e];if(!n)return;let{[e]:r,...i}=this.state.picks;if(this.commit({picks:i}),n.agentId===t.agentId)for(let[e,r]of Object.entries(n.values))try{let n=await this.host.setOption(t.id,e,r),i=this.state.transcripts[t.id];i&&this.commit({transcripts:{...this.state.transcripts,[t.id]:{...i,options:n}}})}catch{}}async tryAgain(e,t){let n=[...this.state.transcripts[e]?.entries??[]].reverse().find(e=>e.kind===`user`);if(!n||n.kind!==`user`||!await t())return`refused`;try{return this.commit({shown:{...this.state.shown,[e]:!0},folded:{...this.state.folded,[e]:!1},failure:null}),(await this.host.prompt(e,n.text,null)).queued?`queued`:`sent`}catch(e){return isLicenceRefusal(e)?(await t(),`refused`):(this.commit({failure:this.describe(e)}),`failed`)}}async unqueue(e,t,n){let r=this.state.transcripts[e],i=r?r.queue.findIndex(e=>e.id===t):-1,a=i>=0&&r?r.queue[i]:null;r&&this.commit({transcripts:{...this.state.transcripts,[e]:{...r,queue:r.queue.filter(e=>e.id!==t)}}});try{await this.host.unqueue(e,t)}catch(t){if(t instanceof u&&t.status===404)return;this.commit({failure:this.describe(t)});let n=this.state.transcripts[e];if(a&&n&&!n.queue.some(e=>e.id===a.id)){let t=[...n.queue];t.splice(Math.min(i,t.length),0,a),this.commit({transcripts:{...this.state.transcripts,[e]:{...n,queue:t}}})}return}if(!a)return;let o=this.draft(n),s=o.text.trim()===``?a.text:`${o.text.trimEnd()}\n${a.text}`;this.setDraft(n,{text:s,focus:o.focus+1})}async stop(e){try{await this.host.stop(e)}catch(e){this.commit({failure:this.describe(e)})}}async signIn(e,t){if(await t())try{await this.host.signIn(e)}catch(e){if(isLicenceRefusal(e)){await t();return}this.commit({failure:this.describe(e)})}}async answer(e,t,n){let r=this.state.transcripts[e];if(r?.permission?.id===t){r.permission.options.find(e=>e.id===n)?.kind===`allow`&&r.permission.tool.diffs.length>0&&this.approved.set(l(r.permission.tool),r.permission.tool.diffs),this.commit({transcripts:{...this.state.transcripts,[e]:{...r,permission:null}}});try{await this.host.answer(e,t,n)}catch(t){if(t instanceof u&&t.status===409)return;this.commit({failure:this.describe(t)}),this.fetchChat(e,!0)}}}retry(e,t){return t&&this.select(t,e),this.fetchChat(e,!0)}dismissFailure(){this.state.failure!==null&&this.commit({failure:null})}},C=`element:`;function mentionKey(e){return e.kind===`element`?`${C}${e.id}`:`file:${e.path}`}function optionsFor(e,t,n,r){if(n)return e.transcripts[n.id]?.options??[];let i=e.picks[t],a=i&&i.agentId===r?i.values:{};return(e.choices.find(e=>e.id===r)?.options??[]).map(e=>a[e.id]!==void 0&&e.values.some(t=>t.id===a[e.id])?{...e,current:a[e.id]}:e)}var w=null,T=!1,release=null;function aiChatPlace(){return aiChatPlaceOf(p().aiChat)}function aiChatOn(){return aiChatPlace()!==`off`}function createAssistant(e={}){let t=c().agentHost?.();return t?new AssistantStore(t,{place:aiChatPlace,onManageAgents:()=>void openAgentsScreen(),...e}):null}function setAssistant(e){if(release?.(),release=null,w=e,T=!0,!e)return;let t=m(()=>{e.setPlace(aiChatPlace())}),refocused=()=>{e.snapshot().enabled&&e.resync()},n=typeof window>`u`?null:window;n?.addEventListener(`focus`,refocused),release=()=>{t(),n?.removeEventListener(`focus`,refocused)}}function getAssistant(){if(!T){T=!0;try{setAssistant(createAssistant())}catch{w=null}}return w}function installOpenChat(){let e=globalThis,open=e=>getAssistant()?.openChat(e);if(e.penstockOpenChat=open,e.pendingOpenChat){let t=e.pendingOpenChat;delete e.pendingOpenChat,open(t)}return()=>{e.penstockOpenChat===open&&delete e.penstockOpenChat}}function useTick(t,r,i=Object.is){let[,o]=e(0),s=n(r);s.current=r;let c=n(r()),l=r();return c.current=l,a(()=>t(()=>{let e=s.current();i(c.current,e)||(c.current=e,o(e=>e+1))}),[t]),l}var E=6e4,D=60*E,O=24*D;function ago(e,t=Date.now()){let n=t-e,r;try{r=new Intl.RelativeTimeFormat(s(),{numeric:`auto`,style:`short`})}catch{r=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`,style:`short`})}return!Number.isFinite(n)||n<E?r.format(0,`minute`):n<D?r.format(-Math.floor(n/E),`minute`):n<O?r.format(-Math.floor(n/D),`hour`):r.format(-Math.floor(n/O),`day`)}var k=/(?:fill|stroke)\s*[:=]\s*["']?\s*(#[0-9a-fA-F]{3,8}|rgba?\([^)]*\)|[a-zA-Z]+)/g,A=new Set([`none`,`transparent`,`currentcolor`,`inherit`]),j=2e5,M=new Map;function isSingleColour(e){let t=new Set;for(let n of e.matchAll(k)){let e=n[1].toLowerCase().replace(/\s+/g,``);A.has(e)||t.add(e)}return t.size<=1&&!/<(?:linearGradient|radialGradient|image)\b/i.test(e)}var N=/^data:image\/svg\+xml;base64,([A-Za-z0-9+/=]+)$/,P=/^(?:data:image\/svg\+xml;base64,[A-Za-z0-9+/=]+|https?:\/\/\S+|\/[^\s/]\S*)$/;function loadable(e){return typeof e==`string`&&P.test(e)}function decoded(e){let t=N.exec(e);if(!t)return null;try{return atob(t[1])}catch{return``}}function singleColour(e){let t=decoded(e);if(t!==null)return Promise.resolve(t!==``&&t.length<=j&&isSingleColour(t));let n=M.get(e);return n||(n=fetch(e).then(e=>e.ok?e.text():``).then(t=>t!==``&&t.length<=j&&/\.svg(?:$|\?)/i.test(e)&&isSingleColour(t)).catch(()=>!1),M.set(e,n)),n}function monogramOf(e){return(Array.from(e.trim())[0]??`?`).toLocaleUpperCase()}function AgentLogo({name:t,icon:n,class:i,size:o=16}){let s=loadable(n)?n:null,[c,l]=e(null),[u,d]=e(!1);a(()=>{if(d(!1),l(null),!s)return;let e=!0;return singleColour(s).then(t=>{e&&l(t)}),()=>{e=!1}},[s]);let f=`agent-logo${o===20?` agent-logo--large`:``}${i?` ${i}`:``}`;return!s||u?r(`span`,{class:`${f} agent-logo--monogram type-badge`,"aria-hidden":`true`,children:monogramOf(t)}):c===!0?r(`span`,{class:`${f} agent-logo--mask`,style:{maskImage:`url("${s}")`,WebkitMaskImage:`url("${s}")`},"aria-hidden":`true`}):r(`img`,{class:f,src:s,alt:``,width:o,height:o,onError:()=>d(!0)})}var F=/^default\b/i,I=28,L=4;function settingsOf(e){let first=t=>e.find(e=>e.category===t)??null;return{model:first(`model`),level:first(`thought_level`),mode:first(`mode`)}}function currentOf(e){return e.values.find(t=>t.id===e.current)??null}function isDefaultValue(e){return F.test(e.id)||F.test(e.name)}function standsFor(e){let t=e.description?.trim()??``,n=t.split(/\s+/).length;return t!==``&&t.length<=I&&n<=L&&/^[A-Z0-9]/.test(t)&&!/[.!?]$/.test(t)?t:null}function rowName(e){let t=currentOf(e);return t?e.category===`model`?modelName(e)??t.name:isDefaultValue(t)?standsFor(t)??t.name:t.name:e.current}function modelName(e){let t=currentOf(e);return t?isDefaultValue(t)?standsFor(t):t.name:e.current}function levelName(e){let t=currentOf(e);return t?isDefaultValue(t)?null:t.name:e.current}function modelAndLevel(e){return[e.model?modelName(e.model):null,e.level?levelName(e.level):null].filter(e=>e!==null).join(` `)}function modeSuffix(e){let t=e.mode;if(!t)return null;let n=currentOf(t);return n&&isDefaultValue(n)?null:modeName(t)}function settingsLabel(e){return[modelAndLevel(e),modeSuffix(e)].filter(e=>e!==null&&e!==``).join(` · `)}function modeName(e){return currentOf(e)?.name??e.current}var R=6,z=22,B=2;function groupsOf(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.name===n.group?e.values.push(n):t.push({name:n.group,values:[n]})}return t}function isSegmented(e){let t=e.values;return t.length<2||t.length>R||!t.every(e=>!e.description&&!e.group)?!1:t.reduce((e,t)=>e+Array.from(t.name).length+B,0)<=z}var V=360,H=72,U=60,W=16,G={kind:`rows`};function Segmented({option:e,onPick:t}){return r(`div`,{class:`assistant-form__segments`,role:`radiogroup`,"aria-label":e.name,children:e.values.map(n=>r(`button`,{type:`button`,role:`radio`,"aria-checked":n.id===e.current,"data-nav":`segment`,class:`assistant-form__segment type-body`,onClick:()=>t(e,n.id),children:n.name},n.id))})}function Select({text:e,logo:t,onOpen:n,label:i,nav:a=`item`}){return r(`button`,{type:`button`,class:`assistant-form__select type-body`,"data-nav":a,"aria-label":`${i}: ${e}`,"aria-haspopup":`listbox`,onClick:n,children:[t,r(`span`,{class:`assistant-form__select-text`,children:e}),r(f,{name:`chevronDown`,class:`assistant-form__select-chevron`})]})}function Row({label:e,children:t}){return r(`div`,{class:`assistant-form__row`,children:[r(`span`,{class:`assistant-form__label type-help`,children:e}),r(`div`,{class:`assistant-form__control`,children:t})]})}function OptionList({option:e,onPick:t}){return r(`div`,{class:`assistant-form__choices`,role:`listbox`,"aria-label":e.name,children:groupsOf(e.values).map((n,i)=>r(`div`,{role:`presentation`,class:`assistant-form__group`,children:[n.name&&r(`div`,{class:`assistant-form__subheading type-help`,role:`presentation`,children:n.name}),n.values.map(n=>{let i=n.id===e.current;return r(`button`,{type:`button`,role:`option`,"aria-selected":i,"data-nav":`item`,"data-current":i?`true`:void 0,class:`assistant-form__item type-body`,onClick:()=>t(e,n.id),children:[r(`span`,{class:`assistant-form__check`,"aria-hidden":`true`,children:i&&r(f,{name:`check`})}),r(`span`,{class:`assistant-form__text`,children:[r(`span`,{class:`assistant-form__name`,children:n.name}),n.description&&r(`span`,{class:`assistant-form__description type-help`,children:n.description})]})]},n.id)})]},`${n.name??``}:${i}`))})}function navigate(e,t){let n=document.activeElement,r=Array.from(e.querySelectorAll(`[data-nav]`)),i=n?r.indexOf(n):-1;if(i<0)return!1;if(n?.dataset.nav===`segment`&&(t===`ArrowRight`||t===`ArrowLeft`)){let e=Array.from(n.parentElement?.querySelectorAll(`[data-nav="segment"]`)??[]);return e[(e.indexOf(n)+(t===`ArrowRight`?1:-1)+e.length)%e.length]?.focus(),!0}return t!==`ArrowDown`&&t!==`ArrowUp`?!1:(r[(i+(t===`ArrowDown`?1:-1)+r.length)%r.length]?.focus(),!0)}function listLimit(e,t){return Math.max(H,Math.min(V,Math.round(e-t-W-U)))}function AgentSettings({store:s,state:c,editor:l,chat:u,agentId:p,options:m,busy:h,started:g}){let _=n(null),v=n(null),y=n(null),[b,x]=e(!1),[S,C]=e(G),[w,T]=e(V),E=settingsOf(m),D=c.choices.find(e=>e.id===p),O=c.choices.filter(e=>e.available),k=D?.name??(p===``?o(`app.assistant.input.noAgent`):p),A=O.length===0&&c.canManageAgents,j=settingsLabel(E),M=[E.model,E.level,E.mode].filter(e=>e!==null),N=S.kind===`option`?M.find(e=>e.id===S.id)??null:null,close=()=>{x(!1),C(G)},back=()=>{C(G)},drill=e=>{y.current=document.activeElement,C(e)},pick=(e,t)=>{t!==e.current&&s.pickOption(l,u,e,t)},pickFromList=(e,t)=>{pick(e,t),back()},chooseAgent=e=>{e!==p&&s.changeAgent(l,e),back()},manage=()=>{close(),s.onManageAgents?.()};i(()=>{if(!b||S.kind===`rows`||!_.current)return;let e=_.current.closest(`.editor-canvas`);T(listLimit(_.current.getBoundingClientRect().top,e?e.getBoundingClientRect().top:0))},[b,S]),a(()=>{if(!b)return;let e=v.current;if(e){if(S.kind===`rows`){let t=y.current&&e.contains(y.current)?y.current:e.querySelector(`[data-nav]`);y.current=null,t?.focus()}else(e.querySelector(`[data-current="true"]`)??e.querySelector(`[data-nav="item"]:not(.assistant-form__back)`))?.focus()}},[b,S]);let P=S.kind===`agent`?o(`app.assistant.form.agent`):N?.name??``;return r(t,{children:[r(`button`,{ref:_,type:`button`,class:`assistant-settings type-body`,title:j===``?k:`${k}: ${j}`,"aria-label":j===``?k:o(`app.assistant.input.settingsLabel`,{agent:k,settings:j}),"aria-haspopup":A?void 0:`dialog`,"aria-expanded":A?void 0:b,onClick:()=>A?s.onManageAgents?.():b?close():x(!0),children:[r(AgentLogo,{name:k,icon:D?.icon}),j!==``&&r(`span`,{class:`assistant-settings__label`,children:j})]}),b&&r(d,{anchor:_.current,label:o(`app.assistant.form.title`),onClose:close,onEscape:()=>S.kind!==`rows`&&(back(),!0),width:320,class:`assistant-form`,children:[r(`div`,{ref:v,class:`assistant-form__body`,"data-view":S.kind,style:{"--assistant-form-list":`${w}px`},onKeyDown:e=>{let t=e.currentTarget;/^Arrow/.test(e.key)&&navigate(t,e.key)&&e.preventDefault()},children:[S.kind===`rows`&&r(t,{children:[r(Row,{label:o(`app.assistant.form.agent`),children:r(Select,{label:o(`app.assistant.form.agent`),text:k,logo:r(AgentLogo,{name:k,icon:D?.icon}),onOpen:()=>drill({kind:`agent`})})}),M.map(e=>{let t=rowName(e);return r(Row,{label:e.name,children:e.category!==`model`&&isSegmented(e)?r(Segmented,{option:e,onPick:pick}):r(Select,{label:e.name,text:t,onOpen:()=>drill({kind:`option`,id:e.id})})},e.id)}),h&&M.length>0&&r(`p`,{class:`assistant-form__note type-help`,children:o(`app.assistant.input.optionNextTurn`)})]}),S.kind!==`rows`&&r(t,{children:[r(`header`,{class:`assistant-form__head`,children:[r(`button`,{type:`button`,class:`assistant-form__back`,"data-nav":`item`,"aria-label":o(`app.assistant.form.back`),title:o(`app.assistant.form.back`),onClick:back,children:r(f,{name:`chevronLeft`})}),r(`h3`,{class:`assistant-form__title type-section-heading`,children:P})]}),r(`div`,{class:`assistant-form__scroll`,children:[S.kind===`agent`&&r(t,{children:[r(`div`,{class:`assistant-form__choices`,role:`listbox`,"aria-label":o(`app.assistant.form.agent`),children:O.map(e=>r(`button`,{type:`button`,role:`option`,"aria-selected":e.id===p,"data-nav":`item`,"data-current":e.id===p?`true`:void 0,class:`assistant-form__item type-body`,onClick:()=>chooseAgent(e.id),children:[r(`span`,{class:`assistant-form__check`,"aria-hidden":`true`,children:e.id===p&&r(f,{name:`check`})}),r(AgentLogo,{name:e.name,icon:e.icon}),r(`span`,{class:`assistant-form__text`,children:r(`span`,{class:`assistant-form__name`,children:e.name})})]},e.id))}),g&&r(`p`,{class:`assistant-form__note type-help`,children:o(`app.assistant.form.agentNew`)})]}),N&&r(OptionList,{option:N,onPick:pickFromList})]})]})]}),c.canManageAgents&&S.kind===`rows`&&r(`div`,{class:`assistant-form__foot`,children:r(`button`,{type:`button`,"data-nav":`item`,class:`assistant-form__manage type-body`,onClick:manage,children:o(`app.assistant.form.manage`)})})]})]})}export{aiChatPlaceOf as _,useTick as a,getAssistant as c,mentionKey as d,optionsFor as f,registerAgentsOpener as g,openAgentsScreen as h,ago as i,installOpenChat as l,pathsMatch as m,OptionList as n,aiChatOn as o,baseName as p,AgentLogo as r,createAssistant as s,AgentSettings as t,setAssistant as u,aiChatSurfaces as v};
|
|
1
|
+
import"./rolldown-runtime-B8BYMn-z.js";import{c as e,h as t,i as n,r,s as i,u as a}from"./vendor-NJP34MHU.js";import{i as o,n as s}from"./translator-CS9eR0My.js";import{t as c}from"./bridgeInstance-D0bzpNGz.js";import{n as l,r as u}from"./httpHost-Cll6HteE.js";import{c as d,n as f}from"./ui-AICOEtWR.js";import{i as p,r as m}from"./preferences-C_EXTz45.js";var h=[`off`,`bottom`,`sidebar`],g=`bottom`;function aiChatPlaceOf(e){return h.find(t=>t===e)??`bottom`}function aiChatSurfaces(e){let t=e!==`off`;return{bottomInput:e===`bottom`,card:e===`bottom`,chatTab:t,chatsList:t,toolbarButton:t,paletteAction:t,agentProcess:t}}var _=null;function registerAgentsOpener(e){return _=e,()=>{_===e&&(_=null)}}async function openAgentsScreen(){if(_)_();else try{await c().agentsHost?.().openSettings()}catch(e){console.error(`The AI agents screen did not open:`,e)}}function normalise(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/+$/,``)}function pathsMatch(e,t){return normalise(e)===normalise(t)}function baseName(e){return normalise(e).split(`/`).filter(Boolean).pop()??e}var v=1e3,y=15e3,b=2e3,x={status:`loading`,entries:[],queue:[],permission:null,error:null,options:[]},S={text:``,mentions:[],dismissed:[],focus:0};function isLicenceRefusal(e){return e instanceof u&&e.status===402}function newClientId(){return`c${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`}function upsert(e,t){let n=e.findIndex(e=>e.id===t.id);if(n<0){let n=[...e,t];return n.length>b?n.slice(n.length-b):n}let r=e.slice();return r[n]=t,r}function withPlan(e,t){let n=-1;for(let t=e.length-1;t>=0;--t)if(e[t].kind===`plan`){n=t;break}if(n<0)return upsert(e,{kind:`plan`,id:`plan`,items:t});let r=e.slice();return r[n]={kind:`plan`,id:e[n].id,items:t},r}function withApproved(e,t){let n=e.status===`done`&&e.diffs.length===0?t?.get(l(e)):void 0;return n?{...e,diffs:n}:e}function applyToTranscript(e,t,n){switch(t.type){case`entry`:{let r=t.entry.kind===`tool`?{...t.entry,tool:withApproved(t.entry.tool,n)}:t.entry,i=e.entries.find(e=>e.id===r.id);return i&&JSON.stringify(i)===JSON.stringify(r)?e:{...e,entries:upsert(e.entries,r)}}case`tool`:return{...e,entries:upsert(e.entries,{kind:`tool`,id:l(t.tool),tool:withApproved(t.tool,n)})};case`plan`:return{...e,entries:withPlan(e.entries,t.items)};case`queue`:return{...e,queue:t.queue};case`permission`:return{...e,permission:t.permission};case`error`:return{...e,error:t.error};case`options`:return{...e,options:t.options};default:return e}}function sameChats(e,t){return e.length===t.length&&e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t[n]))}var AssistantStore=class{state;listeners=new Set;host;options;client;pending=new Map;approved=new Map;loading=new Map;openings=new Set;expected=null;waitingChat=null;manage;control=null;started=!1;disposed=!1;failures=0;resyncing=null;constructor(e,t={}){this.host=e,this.options=t,this.client=t.client??newClientId(),this.manage=t.onManageAgents??null;let n=t.place?t.place():g;this.state={enabled:n!==`off`,place:n,loaded:!1,connected:!1,choices:[],chats:[],transcripts:{},active:{},shown:{},folded:{},revealed:{},focused:null,agentId:null,drafts:{},picks:{},canManageAgents:!!t.onManageAgents,failure:null}}snapshot=()=>this.state;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});commit(e){this.state={...this.state,...e},this.recordOpenings();for(let e of[...this.listeners])try{e()}catch(e){console.error(`An assistant listener failed:`,e)}}recordOpenings(){for(let e of Object.keys(this.state.active))!this.openings.has(e)&&this.settled(e)&&this.openings.add(e)}settled(e){if(!this.state.loaded)return!1;let t=this.activeChat(e);if(t===null)return!0;let n=this.state.transcripts[t.id];return n!==void 0&&n.status!==`loading`}opened(e){return!this.state.enabled||this.openings.has(e)}describe(e){return e instanceof u&&e.failure?e.failure:{key:`app.agent.failed`,detail:e instanceof Error?e.message:String(e)}}wait(e){return this.options.wait?this.options.wait(e):new Promise(t=>setTimeout(t,e))}allowed(){return!this.options.place||this.options.place()!==`off`}setPlace(e){if(e===this.state.place)return;let t=e!==`off`;this.commit({place:e,enabled:t}),t?this.started&&this.begin():this.halt()}start(){return this.disposed?Promise.resolve():(this.started=!0,this.allowed()?(this.state.enabled||this.commit({enabled:!0}),this.control&&!this.control.signal.aborted?Promise.resolve():this.begin()):(this.state.enabled&&this.commit({enabled:!1}),Promise.resolve()))}begin(){let e=new AbortController;this.control=e;let t=this.resync();return this.pump(e),t}halt(){this.control?.abort(),this.control=null,this.commit({connected:!1})}dispose(){this.disposed=!0,this.started=!1,this.halt(),this.listeners.clear()}async pump(e){for(;!e.signal.aborted;)try{let t=await this.host.next(this.client,e.signal);if(e.signal.aborted)return;this.failures>0&&(this.failures=0,this.state.connected||this.commit({connected:!0})),t&&this.receive(t)}catch{if(e.signal.aborted)return;this.failures+=1,this.state.connected&&this.commit({connected:!1});let t=Math.min(this.options.maxRetryMs??y,(this.options.retryMs??v)*2**Math.min(this.failures-1,6));if(await this.wait(t),e.signal.aborted)return;await this.resync()}}resync(){if(this.resyncing)return this.resyncing;let e=(async()=>{try{let[e,t]=await Promise.all([this.host.choices().catch(()=>this.state.choices),this.host.chats()]);this.commit({choices:e,loaded:!0,connected:!0,enabled:t.enabled&&this.allowed(),failure:null}),this.takeChats(t.chats);let n=Object.keys(this.state.transcripts);await Promise.all(n.map(e=>this.fetchChat(e,!0)))}catch(e){this.state.loaded||this.commit({loaded:!0}),this.commit({failure:this.describe(e)})}finally{this.resyncing=null}})();return this.resyncing=e,e}takeChats(e){let t=new Set(e.map(e=>e.id)),n=Object.fromEntries(Object.entries(this.state.active).map(([e,n])=>[e,n!==null&&t.has(n)?n:null])),r=Object.fromEntries(Object.entries(this.state.transcripts).filter(([e])=>t.has(e))),i=this.state.chats,a=!sameChats(i,e),o=Object.entries(n).some(([e,t])=>t!==this.state.active[e])||Object.keys(r).length!==Object.keys(this.state.transcripts).length;if(a||o){for(let t of e){let e=i.find(e=>e.id===t.id);(t.state===`working`||t.state===`waiting`||t.state===`connecting`||t.state===`failed`)&&e?.state!==t.state&&(this.state={...this.state,shown:{...this.state.shown,[t.id]:!0}},t.state===`waiting`&&(this.state={...this.state,folded:{...this.state.folded,[t.id]:!1}}))}this.commit({chats:e,active:n,transcripts:r});for(let t of e){let e=i.find(e=>e.id===t.id);t.state===`waiting`&&e?.state!==`waiting`&&this.revealWaiting(t.id),t.state===`waiting`&&!this.state.transcripts[t.id]&&this.open(t.id)}}}receive(e){switch(e.type){case`sync`:this.resync();return;case`chats`:this.takeChats(e.chats);return;case`enabled`:this.commit({enabled:e.enabled&&this.allowed()});return;default:{let t=e.chatId,n=this.state.transcripts[t];if(!n){this.state.chats.some(e=>e.id===t)&&(this.pending.set(t,[...this.pending.get(t)??[],e]),this.open(t));return}if(n.status===`loading`){this.pending.set(t,[...this.pending.get(t)??[],e]);return}let r=applyToTranscript(n,e,this.approved);if(r===n)return;e.type===`options`&&this.learn(t);let i={transcripts:{...this.state.transcripts,[t]:r}};if(e.type===`permission`&&e.permission&&e.permission.id!==n.permission?.id){i.folded={...this.state.folded,[t]:!1},i.shown={...this.state.shown,[t]:!0},this.commit(i),this.revealWaiting(t);return}this.commit(i)}}}fetchChat(e,t){let n=this.loading.get(e);if(n)return n;let r=this.state.transcripts[e];!t||!r?this.commit({transcripts:{...this.state.transcripts,[e]:{...r??x,status:`loading`}}}):this.commit({transcripts:{...this.state.transcripts,[e]:{...r,status:`loading`}}});let i=(async()=>{try{let t=await this.host.chat(e),n={status:`ready`,entries:t.entries,queue:t.queue,permission:t.permission,error:t.error,options:t.options};for(let t of this.pending.get(e)??[])n=applyToTranscript(n,t,this.approved);this.pending.delete(e),this.state.chats.some(t=>t.id===e)&&this.commit({transcripts:{...this.state.transcripts,[e]:n}}),this.mergeSummary(t)}catch(t){this.pending.delete(e);let n=t instanceof u?t.status:null,r={...this.state.transcripts};n===404?delete r[e]:r[e]={...r[e]??x,status:`failed`},this.commit({transcripts:r})}finally{this.loading.delete(e)}})();return this.loading.set(e,i),i}mergeSummary(e){let t=this.state.chats.findIndex(t=>t.id===e.chat.id);if(t<0||JSON.stringify(this.state.chats[t])===JSON.stringify(e.chat))return;let n=this.state.chats.slice();n[t]=e.chat,this.commit({chats:n})}open(e){let t=this.state.transcripts[e];return t&&t.status!==`failed`&&t.status!==`missing`?this.loading.get(e)??Promise.resolve():this.fetchChat(e,!1)}focus(e){if(e!==this.state.focused&&(this.commit({focused:e}),e&&this.waitingChat)){let e=this.waitingChat;this.waitingChat=null,this.openChat(e)}}unfocus(e){this.state.focused===e&&this.commit({focused:null})}activeChat(e){let t=e?this.state.active[e]:null;return t?this.state.chats.find(e=>e.id===t)??null:null}select(e,t){this.commit({active:{...this.state.active,[e]:t}}),t&&this.open(t)}expectChat(e,t){this.expected={chatId:e,file:t}}settle(e,t){if(!this.state.loaded)return;if(this.expected&&t&&pathsMatch(this.expected.file,t)){let{chatId:t}=this.expected;this.expected=null,this.select(e,t);return}if(e in this.state.active)return;let n=(t?this.state.chats.filter(e=>e.files.some(e=>pathsMatch(e,t))):[]).reduce((e,t)=>e===null||t.updated>e.updated?t:e,null);this.select(e,n?.id??null)}get onManageAgents(){return this.manage}setManageAgents(e){return this.manage=e,this.commit({canManageAgents:e!==null}),()=>{this.manage===e&&(this.manage=null,this.commit({canManageAgents:!1}))}}changeAgent(e,t){this.activeChat(e)&&this.select(e,null),this.pickAgent(t)}pickAgent(e){this.commit({agentId:e,picks:{}})}learn(e){let t=this.state.chats.find(t=>t.id===e)?.agentId,n=this.state.choices.find(e=>e.id===t);!n||(n.options??[]).length>0||this.host.choices().then(e=>this.commit({choices:e}),()=>void 0)}async pickOption(e,t,n,r){if(!t){let t=this.agentFor(null);if(!t)return;let i=this.state.picks[e],a=i&&i.agentId===t?i.values:{};this.commit({picks:{...this.state.picks,[e]:{agentId:t,values:{...a,[n.id]:r}}}});return}let i=this.state.transcripts[t.id],chosen=e=>e.map(e=>e.id===n.id?{...e,current:r}:e);i&&this.commit({transcripts:{...this.state.transcripts,[t.id]:{...i,options:chosen(i.options)}}});try{let e=await this.host.setOption(t.id,n.id,r),i=this.state.transcripts[t.id];i&&this.commit({transcripts:{...this.state.transcripts,[t.id]:{...i,options:e}}})}catch(e){let n=this.state.transcripts[t.id];n&&i&&this.commit({transcripts:{...this.state.transcripts,[t.id]:{...n,options:i.options}}}),this.commit({failure:this.describe(e)})}}agentFor(e){return e?e.agentId:this.state.agentId?this.state.agentId:this.state.choices.find(e=>e.available)?.id??null}reveal(e){this.commit({revealed:{...this.state.revealed,[e]:(this.state.revealed[e]??0)+1}})}revealWaiting(e){if(this.state.place===`sidebar`)for(let[t,n]of Object.entries(this.state.active))n===e&&this.reveal(t)}openChat(e){let t=this.state.focused;t?(this.select(t,e),this.reveal(t)):this.waitingChat=e}showCard(e){this.commit({shown:{...this.state.shown,[e]:!0},folded:{...this.state.folded,[e]:!1}})}returnToCard(e){let t=this.activeChat(e);t&&this.state.place===`bottom`&&this.showCard(t.id)}setFolded(e,t){!!this.state.folded[e]!==t&&this.commit({folded:{...this.state.folded,[e]:t}})}dismissCard(e){this.commit({shown:{...this.state.shown,[e]:!1}})}draft(e){return this.state.drafts[e]??S}setDraft(e,t){this.commit({drafts:{...this.state.drafts,[e]:{...this.draft(e),...t}}})}setText(e,t){t!==this.draft(e).text&&this.setDraft(e,{text:t})}mention(e,t){let n=this.draft(e),r=mentionKey(t);n.mentions.some(e=>mentionKey(e)===r)||this.setDraft(e,{mentions:[...n.mentions,t],dismissed:n.dismissed.filter(e=>e!==r)})}unmention(e,t){let n=this.draft(e);this.setDraft(e,{mentions:n.mentions.filter(e=>mentionKey(e)!==t),dismissed:n.dismissed.includes(t)?n.dismissed:[...n.dismissed,t]})}releaseDismissed(e,t){let n=this.draft(e),r=n.dismissed.filter(e=>!e.startsWith(C)||t.includes(e.slice(C.length)));r.length!==n.dismissed.length&&this.setDraft(e,{dismissed:r})}focusInput(e){this.state.place===`sidebar`&&this.reveal(e),this.setDraft(e,{focus:this.draft(e).focus+1})}compose(e,t,n){let r=this.draft(e),i=r.text.trim()===``?n:r.text.includes(n)?r.text:`${r.text.trimEnd()}\n${n}`,a=mentionKey(t),o=r.mentions.some(e=>mentionKey(e)===a)?r.mentions:[...r.mentions,t];this.setDraft(e,{text:i,mentions:o,dismissed:r.dismissed.filter(e=>e!==a),focus:r.focus+1})}clearDraft(e){this.setDraft(e,{text:``,mentions:[]})}async create(e,t=null){try{let n=await this.host.create(t??this.agentFor(null));return this.takeChats([n,...this.state.chats.filter(e=>e.id!==n.id)]),this.commit({transcripts:{...this.state.transcripts,[n.id]:{status:`ready`,entries:[],queue:[],permission:null,error:null,options:[]}}}),e&&this.select(e,n.id),n}catch(e){return this.commit({failure:this.describe(e)}),null}}async rename(e,t){let n=t.trim();if(n)try{let t=await this.host.rename(e,n);this.takeChats(this.state.chats.map(e=>e.id===t.id?t:e))}catch(e){this.commit({failure:this.describe(e)})}}async remove(e){try{await this.host.remove(e)}catch(e){if(!(e instanceof u&&e.status===404)){this.commit({failure:this.describe(e)});return}}this.takeChats(this.state.chats.filter(t=>t.id!==e))}async send(e){let t=e.text.trim();if(!t)return`refused`;let n=this.activeChat(e.editor);if(!await e.authorize())return`refused`;let r=n===null;try{if(!n){if(n=await this.create(e.editor),!n)return`failed`;await this.applyPicks(e.editor,n)}let r=n.id;return this.state.place===`sidebar`?(this.reveal(e.editor),this.commit({failure:null})):this.commit({shown:{...this.state.shown,[r]:!0},folded:{...this.state.folded,[r]:!1},failure:null}),(await this.host.prompt(r,t,e.context)).queued?`queued`:`sent`}catch(t){return isLicenceRefusal(t)?(r&&n&&await this.discard(e.editor,n.id),await e.authorize(),`refused`):(this.commit({failure:this.describe(t)}),`failed`)}}async discard(e,t){this.select(e,null),await this.remove(t)}async applyPicks(e,t){let n=this.state.picks[e];if(!n)return;let{[e]:r,...i}=this.state.picks;if(this.commit({picks:i}),n.agentId===t.agentId)for(let[e,r]of Object.entries(n.values))try{let n=await this.host.setOption(t.id,e,r),i=this.state.transcripts[t.id];i&&this.commit({transcripts:{...this.state.transcripts,[t.id]:{...i,options:n}}})}catch{}}async tryAgain(e,t){let n=[...this.state.transcripts[e]?.entries??[]].reverse().find(e=>e.kind===`user`);if(!n||n.kind!==`user`||!await t())return`refused`;try{return this.commit({shown:{...this.state.shown,[e]:!0},folded:{...this.state.folded,[e]:!1},failure:null}),(await this.host.prompt(e,n.text,null)).queued?`queued`:`sent`}catch(e){return isLicenceRefusal(e)?(await t(),`refused`):(this.commit({failure:this.describe(e)}),`failed`)}}async unqueue(e,t,n){let r=this.state.transcripts[e],i=r?r.queue.findIndex(e=>e.id===t):-1,a=i>=0&&r?r.queue[i]:null;r&&this.commit({transcripts:{...this.state.transcripts,[e]:{...r,queue:r.queue.filter(e=>e.id!==t)}}});try{await this.host.unqueue(e,t)}catch(t){if(t instanceof u&&t.status===404)return;this.commit({failure:this.describe(t)});let n=this.state.transcripts[e];if(a&&n&&!n.queue.some(e=>e.id===a.id)){let t=[...n.queue];t.splice(Math.min(i,t.length),0,a),this.commit({transcripts:{...this.state.transcripts,[e]:{...n,queue:t}}})}return}if(!a)return;let o=this.draft(n),s=o.text.trim()===``?a.text:`${o.text.trimEnd()}\n${a.text}`;this.setDraft(n,{text:s,focus:o.focus+1})}async stop(e){try{await this.host.stop(e)}catch(e){this.commit({failure:this.describe(e)})}}async signIn(e,t){if(await t())try{await this.host.signIn(e)}catch(e){if(isLicenceRefusal(e)){await t();return}this.commit({failure:this.describe(e)})}}async answer(e,t,n){let r=this.state.transcripts[e];if(r?.permission?.id===t){r.permission.options.find(e=>e.id===n)?.kind===`allow`&&r.permission.tool.diffs.length>0&&this.approved.set(l(r.permission.tool),r.permission.tool.diffs),this.commit({transcripts:{...this.state.transcripts,[e]:{...r,permission:null}}});try{await this.host.answer(e,t,n)}catch(t){if(t instanceof u&&t.status===409)return;this.commit({failure:this.describe(t)}),this.fetchChat(e,!0)}}}retry(e,t){return t&&this.select(t,e),this.fetchChat(e,!0)}dismissFailure(){this.state.failure!==null&&this.commit({failure:null})}},C=`element:`;function mentionKey(e){return e.kind===`element`?`${C}${e.id}`:`file:${e.path}`}function optionsFor(e,t,n,r){if(n)return e.transcripts[n.id]?.options??[];let i=e.picks[t],a=i&&i.agentId===r?i.values:{};return(e.choices.find(e=>e.id===r)?.options??[]).map(e=>a[e.id]!==void 0&&e.values.some(t=>t.id===a[e.id])?{...e,current:a[e.id]}:e)}var w=null,T=!1,release=null;function aiChatPlace(){return aiChatPlaceOf(p().aiChat)}function aiChatOn(){return aiChatPlace()!==`off`}function createAssistant(e={}){let t=c().agentHost?.();return t?new AssistantStore(t,{place:aiChatPlace,onManageAgents:()=>void openAgentsScreen(),...e}):null}function setAssistant(e){if(release?.(),release=null,w=e,T=!0,!e)return;let t=m(()=>{e.setPlace(aiChatPlace())}),refocused=()=>{e.snapshot().enabled&&e.resync()},n=typeof window>`u`?null:window;n?.addEventListener(`focus`,refocused),release=()=>{t(),n?.removeEventListener(`focus`,refocused)}}function getAssistant(){if(!T){T=!0;try{setAssistant(createAssistant())}catch{w=null}}return w}function installOpenChat(){let e=globalThis,open=e=>getAssistant()?.openChat(e);if(e.penstockOpenChat=open,e.pendingOpenChat){let t=e.pendingOpenChat;delete e.pendingOpenChat,open(t)}return()=>{e.penstockOpenChat===open&&delete e.penstockOpenChat}}function useTick(t,r,i=Object.is){let[,o]=e(0),s=n(r);s.current=r;let c=n(r()),l=r();return c.current=l,a(()=>t(()=>{let e=s.current();i(c.current,e)||(c.current=e,o(e=>e+1))}),[t]),l}var E=6e4,D=60*E,O=24*D;function ago(e,t=Date.now()){let n=t-e,r;try{r=new Intl.RelativeTimeFormat(s(),{numeric:`auto`,style:`short`})}catch{r=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`,style:`short`})}return!Number.isFinite(n)||n<E?r.format(0,`minute`):n<D?r.format(-Math.floor(n/E),`minute`):n<O?r.format(-Math.floor(n/D),`hour`):r.format(-Math.floor(n/O),`day`)}var k=/(?:fill|stroke)\s*[:=]\s*["']?\s*(#[0-9a-fA-F]{3,8}|rgba?\([^)]*\)|[a-zA-Z]+)/g,A=new Set([`none`,`transparent`,`currentcolor`,`inherit`]),j=2e5,M=new Map;function isSingleColour(e){let t=new Set;for(let n of e.matchAll(k)){let e=n[1].toLowerCase().replace(/\s+/g,``);A.has(e)||t.add(e)}return t.size<=1&&!/<(?:linearGradient|radialGradient|image)\b/i.test(e)}var N=/^data:image\/svg\+xml;base64,([A-Za-z0-9+/=]+)$/,P=/^(?:data:image\/svg\+xml;base64,[A-Za-z0-9+/=]+|https?:\/\/\S+|\/[^\s/]\S*)$/;function loadable(e){return typeof e==`string`&&P.test(e)}function decoded(e){let t=N.exec(e);if(!t)return null;try{return atob(t[1])}catch{return``}}function singleColour(e){let t=decoded(e);if(t!==null)return Promise.resolve(t!==``&&t.length<=j&&isSingleColour(t));let n=M.get(e);return n||(n=fetch(e).then(e=>e.ok?e.text():``).then(t=>t!==``&&t.length<=j&&/\.svg(?:$|\?)/i.test(e)&&isSingleColour(t)).catch(()=>!1),M.set(e,n)),n}function monogramOf(e){return(Array.from(e.trim())[0]??`?`).toLocaleUpperCase()}function AgentLogo({name:t,icon:n,class:i,size:o=16}){let s=loadable(n)?n:null,[c,l]=e(null),[u,d]=e(!1);a(()=>{if(d(!1),l(null),!s)return;let e=!0;return singleColour(s).then(t=>{e&&l(t)}),()=>{e=!1}},[s]);let f=`agent-logo${o===20?` agent-logo--large`:``}${i?` ${i}`:``}`;return!s||u?r(`span`,{class:`${f} agent-logo--monogram type-badge`,"aria-hidden":`true`,children:monogramOf(t)}):c===!0?r(`span`,{class:`${f} agent-logo--mask`,style:{maskImage:`url("${s}")`,WebkitMaskImage:`url("${s}")`},"aria-hidden":`true`}):r(`img`,{class:f,src:s,alt:``,width:o,height:o,onError:()=>d(!0)})}var F=/^default\b/i,I=28,L=4;function settingsOf(e){let first=t=>e.find(e=>e.category===t)??null;return{model:first(`model`),level:first(`thought_level`),mode:first(`mode`)}}function currentOf(e){return e.values.find(t=>t.id===e.current)??null}function isDefaultValue(e){return F.test(e.id)||F.test(e.name)}function standsFor(e){let t=e.description?.trim()??``,n=t.split(/\s+/).length;return t!==``&&t.length<=I&&n<=L&&/^[A-Z0-9]/.test(t)&&!/[.!?]$/.test(t)?t:null}function rowName(e){let t=currentOf(e);return t?e.category===`model`?modelName(e)??t.name:isDefaultValue(t)?standsFor(t)??t.name:t.name:e.current}function modelName(e){let t=currentOf(e);return t?isDefaultValue(t)?standsFor(t):t.name:e.current}function levelName(e){let t=currentOf(e);return t?isDefaultValue(t)?null:t.name:e.current}function modelAndLevel(e){return[e.model?modelName(e.model):null,e.level?levelName(e.level):null].filter(e=>e!==null).join(` `)}function modeSuffix(e){let t=e.mode;if(!t)return null;let n=currentOf(t);return n&&isDefaultValue(n)?null:modeName(t)}function settingsLabel(e){return[modelAndLevel(e),modeSuffix(e)].filter(e=>e!==null&&e!==``).join(` · `)}function modeName(e){return currentOf(e)?.name??e.current}var R=6,z=22,B=2;function groupsOf(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.name===n.group?e.values.push(n):t.push({name:n.group,values:[n]})}return t}function isSegmented(e){let t=e.values;return t.length<2||t.length>R||!t.every(e=>!e.description&&!e.group)?!1:t.reduce((e,t)=>e+Array.from(t.name).length+B,0)<=z}var V=360,H=72,U=60,W=16,G={kind:`rows`};function Segmented({option:e,onPick:t}){return r(`div`,{class:`assistant-form__segments`,role:`radiogroup`,"aria-label":e.name,children:e.values.map(n=>r(`button`,{type:`button`,role:`radio`,"aria-checked":n.id===e.current,"data-nav":`segment`,class:`assistant-form__segment type-body`,onClick:()=>t(e,n.id),children:n.name},n.id))})}function Select({text:e,logo:t,onOpen:n,label:i,nav:a=`item`}){return r(`button`,{type:`button`,class:`assistant-form__select type-body`,"data-nav":a,"aria-label":`${i}: ${e}`,"aria-haspopup":`listbox`,onClick:n,children:[t,r(`span`,{class:`assistant-form__select-text`,children:e}),r(f,{name:`chevronDown`,class:`assistant-form__select-chevron`})]})}function Row({label:e,children:t}){return r(`div`,{class:`assistant-form__row`,children:[r(`span`,{class:`assistant-form__label type-help`,children:e}),r(`div`,{class:`assistant-form__control`,children:t})]})}function OptionList({option:e,onPick:t}){return r(`div`,{class:`assistant-form__choices`,role:`listbox`,"aria-label":e.name,children:groupsOf(e.values).map((n,i)=>r(`div`,{role:`presentation`,class:`assistant-form__group`,children:[n.name&&r(`div`,{class:`assistant-form__subheading type-help`,role:`presentation`,children:n.name}),n.values.map(n=>{let i=n.id===e.current;return r(`button`,{type:`button`,role:`option`,"aria-selected":i,"data-nav":`item`,"data-current":i?`true`:void 0,class:`assistant-form__item type-body`,onClick:()=>t(e,n.id),children:[r(`span`,{class:`assistant-form__check`,"aria-hidden":`true`,children:i&&r(f,{name:`check`})}),r(`span`,{class:`assistant-form__text`,children:[r(`span`,{class:`assistant-form__name`,children:n.name}),n.description&&r(`span`,{class:`assistant-form__description type-help`,children:n.description})]})]},n.id)})]},`${n.name??``}:${i}`))})}function navigate(e,t){let n=document.activeElement,r=Array.from(e.querySelectorAll(`[data-nav]`)),i=n?r.indexOf(n):-1;if(i<0)return!1;if(n?.dataset.nav===`segment`&&(t===`ArrowRight`||t===`ArrowLeft`)){let e=Array.from(n.parentElement?.querySelectorAll(`[data-nav="segment"]`)??[]);return e[(e.indexOf(n)+(t===`ArrowRight`?1:-1)+e.length)%e.length]?.focus(),!0}return t!==`ArrowDown`&&t!==`ArrowUp`?!1:(r[(i+(t===`ArrowDown`?1:-1)+r.length)%r.length]?.focus(),!0)}function listLimit(e,t){return Math.max(H,Math.min(V,Math.round(e-t-W-U)))}function AgentSettings({store:s,state:c,editor:l,chat:u,agentId:p,options:m,busy:h,started:g}){let _=n(null),v=n(null),y=n(null),[b,x]=e(!1),[S,C]=e(G),[w,T]=e(V),E=settingsOf(m),D=c.choices.find(e=>e.id===p),O=c.choices.filter(e=>e.available),k=D?.name??(p===``?o(`app.assistant.input.noAgent`):p),A=O.length===0&&c.canManageAgents,j=settingsLabel(E),M=[E.model,E.level,E.mode].filter(e=>e!==null),N=S.kind===`option`?M.find(e=>e.id===S.id)??null:null,close=()=>{x(!1),C(G)},back=()=>{C(G)},drill=e=>{y.current=document.activeElement,C(e)},pick=(e,t)=>{t!==e.current&&s.pickOption(l,u,e,t)},pickFromList=(e,t)=>{pick(e,t),back()},chooseAgent=e=>{e!==p&&s.changeAgent(l,e),back()},manage=()=>{close(),s.onManageAgents?.()};i(()=>{if(!b||S.kind===`rows`||!_.current)return;let e=_.current.closest(`.editor-canvas`);T(listLimit(_.current.getBoundingClientRect().top,e?e.getBoundingClientRect().top:0))},[b,S]),a(()=>{if(!b)return;let e=v.current;if(e){if(S.kind===`rows`){let t=y.current&&e.contains(y.current)?y.current:e.querySelector(`[data-nav]`);y.current=null,t?.focus()}else(e.querySelector(`[data-current="true"]`)??e.querySelector(`[data-nav="item"]:not(.assistant-form__back)`))?.focus()}},[b,S]);let P=S.kind===`agent`?o(`app.assistant.form.agent`):N?.name??``;return r(t,{children:[r(`button`,{ref:_,type:`button`,class:`assistant-settings type-body`,title:j===``?k:`${k}: ${j}`,"aria-label":j===``?k:o(`app.assistant.input.settingsLabel`,{agent:k,settings:j}),"aria-haspopup":A?void 0:`dialog`,"aria-expanded":A?void 0:b,onClick:()=>A?s.onManageAgents?.():b?close():x(!0),children:[r(AgentLogo,{name:k,icon:D?.icon}),j!==``&&r(`span`,{class:`assistant-settings__label`,children:j})]}),b&&r(d,{anchor:_.current,label:o(`app.assistant.form.title`),onClose:close,onEscape:()=>S.kind!==`rows`&&(back(),!0),width:320,class:`assistant-form`,children:[r(`div`,{ref:v,class:`assistant-form__body`,"data-view":S.kind,style:{"--assistant-form-list":`${w}px`},onKeyDown:e=>{let t=e.currentTarget;/^Arrow/.test(e.key)&&navigate(t,e.key)&&e.preventDefault()},children:[S.kind===`rows`&&r(t,{children:[r(Row,{label:o(`app.assistant.form.agent`),children:r(Select,{label:o(`app.assistant.form.agent`),text:k,logo:r(AgentLogo,{name:k,icon:D?.icon}),onOpen:()=>drill({kind:`agent`})})}),M.map(e=>{let t=rowName(e);return r(Row,{label:e.name,children:e.category!==`model`&&isSegmented(e)?r(Segmented,{option:e,onPick:pick}):r(Select,{label:e.name,text:t,onOpen:()=>drill({kind:`option`,id:e.id})})},e.id)}),h&&M.length>0&&r(`p`,{class:`assistant-form__note type-help`,children:o(`app.assistant.input.optionNextTurn`)})]}),S.kind!==`rows`&&r(t,{children:[r(`header`,{class:`assistant-form__head`,children:[r(`button`,{type:`button`,class:`assistant-form__back`,"data-nav":`item`,"aria-label":o(`app.assistant.form.back`),title:o(`app.assistant.form.back`),onClick:back,children:r(f,{name:`chevronLeft`})}),r(`h3`,{class:`assistant-form__title type-section-heading`,children:P})]}),r(`div`,{class:`assistant-form__scroll`,children:[S.kind===`agent`&&r(t,{children:[r(`div`,{class:`assistant-form__choices`,role:`listbox`,"aria-label":o(`app.assistant.form.agent`),children:O.map(e=>r(`button`,{type:`button`,role:`option`,"aria-selected":e.id===p,"data-nav":`item`,"data-current":e.id===p?`true`:void 0,class:`assistant-form__item type-body`,onClick:()=>chooseAgent(e.id),children:[r(`span`,{class:`assistant-form__check`,"aria-hidden":`true`,children:e.id===p&&r(f,{name:`check`})}),r(AgentLogo,{name:e.name,icon:e.icon}),r(`span`,{class:`assistant-form__text`,children:r(`span`,{class:`assistant-form__name`,children:e.name})})]},e.id))}),g&&r(`p`,{class:`assistant-form__note type-help`,children:o(`app.assistant.form.agentNew`)})]}),N&&r(OptionList,{option:N,onPick:pickFromList})]})]})]}),c.canManageAgents&&S.kind===`rows`&&r(`div`,{class:`assistant-form__foot`,children:r(`button`,{type:`button`,"data-nav":`item`,class:`assistant-form__manage type-body`,onClick:manage,children:o(`app.assistant.form.manage`)})})]})]})}export{aiChatPlaceOf as _,useTick as a,getAssistant as c,mentionKey as d,optionsFor as f,registerAgentsOpener as g,openAgentsScreen as h,ago as i,installOpenChat as l,pathsMatch as m,OptionList as n,aiChatOn as o,baseName as p,AgentLogo as r,createAssistant as s,AgentSettings as t,setAssistant as u,aiChatSurfaces as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-B8BYMn-z.js";import{c as e,h as t,i as n,o as r,r as i,u as a}from"./vendor-NJP34MHU.js";import{i as o}from"./translator-CTBxdhz9.js";import{t as s}from"./bridgeInstance-CJkr34d9.js";import{a as c,c as l,i as u,n as d,r as f}from"./AgentSettings-Iy9ZaTGR.js";import{c as p,f as m,l as h,n as g,p as _,r as v,s as y}from"./ui-B2q39Bca.js";var b=`general`,x=700,S=1e4,C=4;function matches(e,t){let n=t.trim().toLowerCase();return n===``||`${e.name} ${e.id} ${e.description}`.toLowerCase().includes(n)}function sections(e){let t=(e.catalog?.agents??[]).filter(t=>matches(t,e.query)),running=e=>e.enabled&&e.installed;return{on:t.filter(running),rest:t.filter(e=>!running(e))}}var AgentsStore=class{state={status:`loading`,failure:null,catalog:null,refreshing:!1,query:``,selected:null,errors:{}};listeners=new Set;host;options;polling=!1;disposed=!1;started=null;constructor(e,t={}){this.host=e,this.options=t}snapshot=()=>this.state;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});commit(e){this.state={...this.state,...e};for(let e of[...this.listeners])try{e()}catch(e){console.error(`An agents listener failed:`,e)}}describe(e){return this.options.describe?this.options.describe(e):e instanceof Error?e.message:String(e)}start(){return this.started??=this.load(!0),this.started}reload(){return this.load(!1)}async load(e){try{let t=await this.host.catalog();if(this.disposed)return;this.commit({status:`ready`,failure:null,catalog:t,selected:this.state.selected??defaultSelection(t)}),this.watch(t),e&&t.stale&&this.refresh()}catch(e){if(this.disposed)return;this.commit({status:this.state.catalog?`ready`:`failed`,failure:this.describe(e)})}}async refresh(){if(!this.state.refreshing){this.commit({refreshing:!0});try{let e=await this.host.refresh();if(this.disposed)return;this.commit({status:`ready`,failure:null,refreshing:!1,catalog:e,selected:this.state.selected??defaultSelection(e)}),this.watch(e)}catch(e){if(this.disposed)return;this.commit({refreshing:!1,failure:this.describe(e),status:this.state.catalog?`ready`:`failed`})}}}select(e){this.commit({selected:e})}search(e){this.commit({query:e})}setError(e,t){let n={...this.state.errors};t===null?delete n[e]:n[e]=t,this.commit({errors:n})}replace(e){let t=this.state.catalog;if(!t)return;let n=t.agents.map(t=>t.id===e.id?e:t),r={...t,agents:n,busy:t.busy||e.job?.state===`running`};this.commit({catalog:r}),this.watch(r)}async act(e,t){this.setError(e,null);try{this.replace(await t()),this.options.changed?.()}catch(t){if(this.disposed)return;this.setError(e,this.describe(t)),this.load(!1)}}install(e){return this.act(e,()=>this.host.install(e))}uninstall(e){return this.act(e,()=>this.host.uninstall(e))}turn(e,t){return this.act(e,()=>this.host.turn(e,t))}refreshModels(e){return this.act(e,()=>this.host.refreshModels(e))}choose(e,t,n){return this.act(e,()=>this.host.choose(e,t,n))}watch(e){!e.busy||this.polling||this.disposed||(this.polling=!0,(async()=>{let e=0;try{for(;!this.disposed;){let t=Math.min((this.options.pollMs??x)*2**e,S);if(await(this.options.wait?this.options.wait(t):new Promise(e=>setTimeout(e,t))),this.disposed)return;let n;try{n=await this.host.catalog()}catch(t){e=Math.min(e+1,C),this.commit({failure:this.describe(t)});continue}if(this.disposed||(e=0,this.commit({catalog:n,failure:null}),!n.busy))return}}finally{this.polling=!1}})())}dispose(){this.disposed=!0,this.listeners.clear()}};function defaultSelection(e){return e.agents.find(e=>e.enabled&&e.installed)?.id??`general`}var w=280;function ValueSelect({id:r,option:a,chosen:s,onChoose:c}){let l=n(null),[u,f]=e(!1),m=a.values.find(e=>e.id===a.current)?.name??a.current,h=[{id:``,name:o(`app.agents.modelsOwn`,{value:m}),description:null,group:null},...a.values.map(e=>({id:e.id,name:e.name,description:null,group:null}))],_=h.find(e=>e.id===s)?.name??s,v={id:a.id,name:a.name,description:null,category:a.category??a.id,current:s,values:h};return i(t,{children:[i(`button`,{ref:l,id:r,type:`button`,class:`assistant-form__select type-body agents-select`,"aria-haspopup":`listbox`,"aria-expanded":u,onClick:()=>f(e=>!e),children:[i(`span`,{class:`assistant-form__select-text`,children:_}),i(g,{name:`chevronDown`,class:`assistant-form__select-chevron`})]}),u&&i(p,{anchor:l.current,label:a.name,onClose:()=>f(!1),width:320,class:`assistant-form`,children:i(`div`,{class:`assistant-form__scroll`,style:{"--assistant-form-list":`${w}px`},children:i(d,{option:v,onPick:(e,t)=>{f(!1),c(t===``?null:t)}})})})]})}var T=`https://nodejs.org/en/download`,E=`https://docs.astral.sh/uv/getting-started/installation/`,D=[`off`,`bottom`,`sidebar`],O={off:`app.agents.aiChatOff`,bottom:`app.agents.aiChatBottom`,sidebar:`app.agents.aiChatSidebar`},k={off:`app.agents.aiChatOffHelp`,bottom:`app.agents.aiChatBottomHelp`,sidebar:`app.agents.aiChatSidebarHelp`};function openLink(e){s().openExternalLink(e).catch(()=>void 0)}function reasonText(e){let t=o(e.key,e.params);return t===e.key?e.detail===``?o(`app.agents.reason.unknown`):e.detail:e.detail===``?t:`${t} ${e.detail}`}function stateWord(e){if(e.job?.state===`running`){if(e.job.kind===`install`)return e.job.percent===null?o(`app.agents.state.installing`):o(`app.agents.state.installingPercent`,{percent:e.job.percent});if(e.job.kind===`models`)return o(`app.agents.state.reading`)}return e.job?.state===`failed`&&e.job.kind!==`models`?o(`app.agents.state.failed`):e.updateAvailable?o(`app.agents.state.update`):e.enabled&&e.installed?o(`app.agents.state.on`):e.installed?o(`app.agents.state.installed`):``}function Row({agent:e,selected:t,onSelect:n}){let r=stateWord(e);return i(`button`,{type:`button`,role:`option`,"aria-selected":t,tabIndex:t?0:-1,"data-id":e.id,class:`agents-row type-body`,onClick:n,children:[i(f,{icon:e.icon,name:e.name}),i(`span`,{class:`agents-row__name`,children:e.name}),r!==``&&i(`span`,{class:`agents-row__state type-help${e.enabled&&e.installed?` is-on`:``}${e.job?.state===`failed`?` is-failed`:``}`,children:r})]})}function GeneralRow({selected:e,onSelect:t}){return i(`button`,{type:`button`,role:`option`,"aria-selected":e,tabIndex:e?0:-1,"data-id":b,class:`agents-row type-body`,onClick:t,children:[i(`span`,{class:`agents-general-icon`,"aria-hidden":`true`}),i(`span`,{class:`agents-row__name`,children:o(`app.agents.general`)})]})}function General({preferences:e}){let t=c(e.subscribe,e.aiChat);return i(`div`,{class:`agents-general`,children:i(`section`,{class:`agents-group`,"aria-labelledby":`agents-chat`,children:[i(`h3`,{id:`agents-chat`,class:`agents-group__heading type-section-heading`,children:o(`app.agents.aiChat`)}),i(`div`,{role:`radiogroup`,"aria-labelledby":`agents-chat`,class:`agents-group__choices`,children:D.map(n=>i(`div`,{children:[i(`label`,{class:`agents-check type-body`,children:[i(`input`,{type:`radio`,name:`agents-chat`,value:n,checked:t===n,"aria-describedby":`agents-chat-${n}`,onChange:()=>e.setAiChat(n)}),i(`span`,{children:o(O[n])})]}),i(`p`,{id:`agents-chat-${n}`,class:`agents-group__help type-help`,children:o(k[n])})]},n))})]})})}function Blocked({agent:e,node:n,uv:r}){if(e.blocked===null)return null;let a=e.blocked===`node`&&!n?T:e.blocked===`uv`&&!r?E:null;return i(`p`,{class:`agents-note type-help`,children:[o(`app.agents.blocked.${e.blocked}`),a&&i(t,{children:[` `,i(`a`,{class:`agents-link`,href:a,onClick:e=>{e.preventDefault(),openLink(a)},children:o(e.blocked===`node`?`app.agents.blocked.nodeLink`:`app.agents.blocked.uvLink`)})]})]})}function Progress({percent:e}){return i(`div`,{class:`agents-progress`,role:`progressbar`,"aria-label":o(`app.agents.state.installing`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e??void 0,children:i(`span`,{class:`agents-progress__bar${e===null?` is-unknown`:``}`,style:e===null?void 0:{width:`${e}%`}})})}function Models({store:e,agent:n,error:r}){let a=n.job?.kind===`models`&&n.job.state===`running`,s=n.job?.kind===`models`&&n.job.state===`failed`?n.job.error:null,c=n.options,l=c&&c.readAt!==``&&Number.isFinite(Date.parse(c.readAt))?u(Date.parse(c.readAt)):null;return i(`section`,{class:`agents-group`,"aria-labelledby":`agents-models-${n.id}`,children:[i(`div`,{class:`agents-group__head`,children:[i(`h3`,{id:`agents-models-${n.id}`,class:`agents-group__heading type-section-heading`,children:o(`app.agents.models`)}),i(`button`,{type:`button`,class:`ui-button type-button agents-refresh`,disabled:a,onClick:()=>void e.refreshModels(n.id),children:[a&&i(v,{}),i(`span`,{children:o(a?`app.agents.modelsReading`:`app.agents.modelsRefresh`)})]})]}),c===null&&!a&&!s&&i(t,{children:[i(`p`,{class:`agents-note type-body`,children:o(`app.agents.modelsEmpty`)}),i(`p`,{class:`agents-note type-help`,children:o(`app.agents.modelsEmptyHint`)})]}),c?.options.map(t=>{let r=t.category??t.id;return i(h,{label:t.name,children:a=>i(ValueSelect,{id:a.id,option:t,chosen:n.chosen[r]??``,onChoose:t=>void e.choose(n.id,r,t)})},t.id)}),l!==null&&!a&&i(`p`,{class:`agents-note type-help`,children:o(`app.agents.modelsRead`,{time:l})}),s&&i(`p`,{class:`agents-note type-error-message`,role:`alert`,children:[reasonText(s),s.key===`app.agent.authRequired`&&i(`span`,{class:`agents-note__more type-help`,children:o(`app.agents.signInHint`)})]}),r&&i(`p`,{class:`agents-note type-error-message`,role:`alert`,children:r})]})}function Detail({store:e,agent:n,state:r}){let a=r.catalog,s=n.job?.kind===`install`&&n.job.state===`running`,c=n.job?.state===`failed`&&n.job.kind!==`models`?n.job.error:null,l=r.errors[n.id]??null,u=!n.installed&&n.how!==`none`&&n.how!==`custom`&&n.blocked===null,d=n.installed&&(n.installedVia===`download`||n.installedVia===`package`);return i(`div`,{class:`agents-detail__page`,children:[i(`header`,{class:`agents-detail__head`,children:[i(f,{icon:n.icon,name:n.name,size:20}),i(`h2`,{class:`agents-detail__name type-dialog-title`,children:n.name}),n.version&&i(`span`,{class:`agents-detail__version type-help`,children:o(`app.agents.version`,{version:n.version})})]}),n.description!==``&&i(`p`,{class:`agents-detail__text type-body`,children:n.description}),i(`dl`,{class:`agents-meta type-help`,children:[n.license&&i(t,{children:[i(`dt`,{children:o(`app.agents.license`)}),i(`dd`,{children:n.license})]}),n.website&&i(t,{children:[i(`dt`,{children:o(`app.agents.website`)}),i(`dd`,{children:i(`a`,{class:`agents-link`,href:n.website,onClick:e=>{e.preventDefault(),openLink(n.website)},children:n.website})})]}),n.repository&&n.repository!==n.website&&i(t,{children:[i(`dt`,{children:o(`app.agents.repository`)}),i(`dd`,{children:i(`a`,{class:`agents-link`,href:n.repository,onClick:e=>{e.preventDefault(),openLink(n.repository)},children:n.repository})})]}),i(`dt`,{children:o(`app.agents.status`)}),i(`dd`,{children:n.installed?`${o(`app.agents.via.${n.installedVia??`path`}`)}${n.installedVersion?` · ${o(`app.agents.version`,{version:n.installedVersion})}`:``}`:n.how===`none`?o(`app.agents.cannotInstall`):o(`app.agents.how.${n.how}`)})]}),i(`div`,{class:`agents-actions`,children:[u&&!s&&i(`button`,{type:`button`,class:`ui-button ui-button--primary type-button`,onClick:()=>void e.install(n.id),children:o(c?`app.agents.tryAgain`:`app.agents.install`)}),s&&i(`button`,{type:`button`,class:`ui-button type-button`,disabled:!0,children:[i(v,{}),i(`span`,{children:o(`app.agents.state.installing`)})]}),n.installed&&!s&&n.updateAvailable&&d&&i(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>void e.install(n.id),children:o(`app.agents.update`)}),n.installed&&!s&&i(`button`,{type:`button`,class:`ui-button type-button${n.enabled?``:` ui-button--primary`}`,onClick:()=>void e.turn(n.id,!n.enabled),children:n.enabled?o(`app.agents.turnOff`):o(`app.agents.turnOn`)}),d&&!s&&i(`button`,{type:`button`,class:`ui-button ui-button--quiet ui-button--danger type-button`,onClick:()=>void e.uninstall(n.id),children:o(`app.agents.uninstall`)})]}),s&&i(Progress,{percent:n.job?.percent??null}),!n.installed&&a&&i(Blocked,{agent:n,node:a.node,uv:a.uv}),!n.installed&&n.blocked!==null&&n.install&&i(`p`,{class:`agents-note type-help`,children:[o(`app.agents.byHand`),` `,i(`code`,{class:`type-code`,children:n.install})]}),c&&i(`p`,{class:`agents-note type-error-message`,role:`alert`,children:reasonText(c)}),l&&i(`p`,{class:`agents-note type-error-message`,role:`alert`,children:l}),n.installed&&i(Models,{store:e,agent:n,error:null})]})}function ListFoot({store:e,state:t}){let n=t.catalog,r=n?.updated&&Number.isFinite(Date.parse(n.updated))?u(Date.parse(n.updated)):null,a=t.failure??(n?.refreshError?reasonText(n.refreshError):null);return i(`footer`,{class:`agents-list__foot`,children:[i(`p`,{class:`agents-list__updated type-help`,role:`status`,children:t.refreshing?o(`app.agents.updating`):r===null?o(`app.agents.neverUpdated`):n?.source===`snapshot`?o(`app.agents.updatedSnapshot`,{time:r}):o(`app.agents.updated`,{time:r})}),a&&!t.refreshing&&i(`p`,{class:`agents-list__problem type-warning-message`,children:a}),i(`button`,{type:`button`,class:`ui-button type-button agents-refresh`,disabled:t.refreshing,onClick:()=>void e.refresh(),children:[t.refreshing&&i(v,{}),i(`span`,{children:o(`app.agents.refresh`)})]})]})}function AgentsScreen({store:t,preferences:r}){let s=c(t.subscribe,t.snapshot),l=n(null),u=n(null),d=n(!1),[f,p]=e(null);a(()=>{t.start()},[t]),a(()=>{if(s.status!==`ready`||d.current)return;d.current=!0;let e=document.activeElement;(!e||e===document.body||e.classList.contains(`ui-dialog__close`)||e.classList.contains(`ui-dialog`))&&u.current?.focus()},[s.status]),a(()=>{f!==null&&(l.current?.querySelector(`[data-id="${CSS.escape(f)}"]`)?.focus(),p(null))},[f]);let{on:m,rest:h}=sections(s),g=[b,...m.map(e=>e.id),...h.map(e=>e.id)],_=s.selected??`general`,x=s.catalog?.agents.find(e=>e.id===_)??null,move=e=>{let n=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,r=e.key===`Home`?0:e.key===`End`?g.length-1:null;if(n===0&&r===null)return;e.preventDefault();let i=g.indexOf(_),a=r??Math.min(g.length-1,Math.max(0,(i<0?0:i)+n));g[a]!==void 0&&(t.select(g[a]),p(g[a]))};return s.status===`loading`?i(`div`,{class:`agents-screen is-loading`,role:`status`,children:[i(v,{}),i(`span`,{class:`type-help`,children:o(`app.agents.loading`)})]}):s.status===`failed`||!s.catalog?i(`div`,{class:`agents-screen is-empty`,children:i(y,{title:o(`app.agents.failed.title`),hint:s.failure??o(`app.agents.failed.hint`),actions:[{label:o(`app.assistant.tryAgain`),run:()=>void t.reload()}]})}):i(`div`,{class:`agents-screen`,children:[i(`nav`,{class:`agents-list`,"aria-label":o(`app.agents.list`),children:[i(`input`,{ref:u,type:`search`,class:`agents-list__search type-input`,value:s.query,placeholder:o(`app.agents.search`),"aria-label":o(`app.agents.search`),onInput:e=>t.search(e.currentTarget.value)}),i(`div`,{ref:l,class:`agents-list__scroll`,role:`listbox`,"aria-label":o(`app.agents.list`),onKeyDown:move,children:[i(GeneralRow,{selected:_===b,onSelect:()=>t.select(b)}),i(`h3`,{class:`agents-list__heading type-section-heading`,children:o(`app.agents.on`)}),m.length===0&&(s.query===``||h.length===0)&&i(`p`,{class:`agents-list__none type-help`,children:s.query===``?o(`app.agents.noneOn`):o(`app.agents.noMatch`)}),m.map(e=>i(Row,{agent:e,selected:_===e.id,onSelect:()=>t.select(e.id)},e.id)),i(`h3`,{class:`agents-list__heading type-section-heading`,children:o(`app.agents.all`)}),h.length===0&&m.length>0&&i(`p`,{class:`agents-list__none type-help`,children:o(`app.agents.allShown`)}),h.length===0&&m.length===0&&s.query!==``&&i(`p`,{class:`agents-list__none type-help`,children:o(`app.agents.noMatch`)}),h.map(e=>i(Row,{agent:e,selected:_===e.id,onSelect:()=>t.select(e.id)},e.id))]}),i(ListFoot,{store:t,state:s})]}),i(`section`,{class:`agents-detail`,"aria-label":x?.name??o(`app.agents.general`),children:_===`general`||x===null?i(General,{preferences:r}):i(Detail,{store:t,agent:x,state:s})})]})}function AgentsDialog({host:e,preferences:t,onClose:n}){let s=r(()=>new AgentsStore(e,{changed:()=>void l()?.resync()}),[e]);return a(()=>()=>s.dispose(),[s]),i(m,{title:o(`app.agents.title`),size:`large`,body:`split`,class:`agents-dialog`,onClose:n,footer:i(_,{actions:[{id:`done`,label:o(`app.common.done`),role:`primary`,onClick:n}]}),children:i(AgentsScreen,{store:s,preferences:t})})}export{AgentsDialog};
|
|
1
|
+
import"./rolldown-runtime-B8BYMn-z.js";import{c as e,h as t,i as n,o as r,r as i,u as a}from"./vendor-NJP34MHU.js";import{i as o}from"./translator-CS9eR0My.js";import{t as s}from"./bridgeInstance-D0bzpNGz.js";import{a as c,c as l,i as u,n as d,r as f}from"./AgentSettings-C-1YBic4.js";import{c as p,f as m,l as h,n as g,p as _,r as v,s as y}from"./ui-AICOEtWR.js";var b=`general`,x=700,S=1e4,C=4;function matches(e,t){let n=t.trim().toLowerCase();return n===``||`${e.name} ${e.id} ${e.description}`.toLowerCase().includes(n)}function sections(e){let t=(e.catalog?.agents??[]).filter(t=>matches(t,e.query)),running=e=>e.enabled&&e.installed;return{on:t.filter(running),rest:t.filter(e=>!running(e))}}var AgentsStore=class{state={status:`loading`,failure:null,catalog:null,refreshing:!1,query:``,selected:null,errors:{}};listeners=new Set;host;options;polling=!1;disposed=!1;started=null;constructor(e,t={}){this.host=e,this.options=t}snapshot=()=>this.state;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});commit(e){this.state={...this.state,...e};for(let e of[...this.listeners])try{e()}catch(e){console.error(`An agents listener failed:`,e)}}describe(e){return this.options.describe?this.options.describe(e):e instanceof Error?e.message:String(e)}start(){return this.started??=this.load(!0),this.started}reload(){return this.load(!1)}async load(e){try{let t=await this.host.catalog();if(this.disposed)return;this.commit({status:`ready`,failure:null,catalog:t,selected:this.state.selected??defaultSelection(t)}),this.watch(t),e&&t.stale&&this.refresh()}catch(e){if(this.disposed)return;this.commit({status:this.state.catalog?`ready`:`failed`,failure:this.describe(e)})}}async refresh(){if(!this.state.refreshing){this.commit({refreshing:!0});try{let e=await this.host.refresh();if(this.disposed)return;this.commit({status:`ready`,failure:null,refreshing:!1,catalog:e,selected:this.state.selected??defaultSelection(e)}),this.watch(e)}catch(e){if(this.disposed)return;this.commit({refreshing:!1,failure:this.describe(e),status:this.state.catalog?`ready`:`failed`})}}}select(e){this.commit({selected:e})}search(e){this.commit({query:e})}setError(e,t){let n={...this.state.errors};t===null?delete n[e]:n[e]=t,this.commit({errors:n})}replace(e){let t=this.state.catalog;if(!t)return;let n=t.agents.map(t=>t.id===e.id?e:t),r={...t,agents:n,busy:t.busy||e.job?.state===`running`};this.commit({catalog:r}),this.watch(r)}async act(e,t){this.setError(e,null);try{this.replace(await t()),this.options.changed?.()}catch(t){if(this.disposed)return;this.setError(e,this.describe(t)),this.load(!1)}}install(e){return this.act(e,()=>this.host.install(e))}uninstall(e){return this.act(e,()=>this.host.uninstall(e))}turn(e,t){return this.act(e,()=>this.host.turn(e,t))}refreshModels(e){return this.act(e,()=>this.host.refreshModels(e))}choose(e,t,n){return this.act(e,()=>this.host.choose(e,t,n))}watch(e){!e.busy||this.polling||this.disposed||(this.polling=!0,(async()=>{let e=0;try{for(;!this.disposed;){let t=Math.min((this.options.pollMs??x)*2**e,S);if(await(this.options.wait?this.options.wait(t):new Promise(e=>setTimeout(e,t))),this.disposed)return;let n;try{n=await this.host.catalog()}catch(t){e=Math.min(e+1,C),this.commit({failure:this.describe(t)});continue}if(this.disposed||(e=0,this.commit({catalog:n,failure:null}),!n.busy))return}}finally{this.polling=!1}})())}dispose(){this.disposed=!0,this.listeners.clear()}};function defaultSelection(e){return e.agents.find(e=>e.enabled&&e.installed)?.id??`general`}var w=280;function ValueSelect({id:r,option:a,chosen:s,onChoose:c}){let l=n(null),[u,f]=e(!1),m=a.values.find(e=>e.id===a.current)?.name??a.current,h=[{id:``,name:o(`app.agents.modelsOwn`,{value:m}),description:null,group:null},...a.values.map(e=>({id:e.id,name:e.name,description:null,group:null}))],_=h.find(e=>e.id===s)?.name??s,v={id:a.id,name:a.name,description:null,category:a.category??a.id,current:s,values:h};return i(t,{children:[i(`button`,{ref:l,id:r,type:`button`,class:`assistant-form__select type-body agents-select`,"aria-haspopup":`listbox`,"aria-expanded":u,onClick:()=>f(e=>!e),children:[i(`span`,{class:`assistant-form__select-text`,children:_}),i(g,{name:`chevronDown`,class:`assistant-form__select-chevron`})]}),u&&i(p,{anchor:l.current,label:a.name,onClose:()=>f(!1),width:320,class:`assistant-form`,children:i(`div`,{class:`assistant-form__scroll`,style:{"--assistant-form-list":`${w}px`},children:i(d,{option:v,onPick:(e,t)=>{f(!1),c(t===``?null:t)}})})})]})}var T=`https://nodejs.org/en/download`,E=`https://docs.astral.sh/uv/getting-started/installation/`,D=[`off`,`bottom`,`sidebar`],O={off:`app.agents.aiChatOff`,bottom:`app.agents.aiChatBottom`,sidebar:`app.agents.aiChatSidebar`},k={off:`app.agents.aiChatOffHelp`,bottom:`app.agents.aiChatBottomHelp`,sidebar:`app.agents.aiChatSidebarHelp`};function openLink(e){s().openExternalLink(e).catch(()=>void 0)}function reasonText(e){let t=o(e.key,e.params);return t===e.key?e.detail===``?o(`app.agents.reason.unknown`):e.detail:e.detail===``?t:`${t} ${e.detail}`}function stateWord(e){if(e.job?.state===`running`){if(e.job.kind===`install`)return e.job.percent===null?o(`app.agents.state.installing`):o(`app.agents.state.installingPercent`,{percent:e.job.percent});if(e.job.kind===`models`)return o(`app.agents.state.reading`)}return e.job?.state===`failed`&&e.job.kind!==`models`?o(`app.agents.state.failed`):e.updateAvailable?o(`app.agents.state.update`):e.enabled&&e.installed?o(`app.agents.state.on`):e.installed?o(`app.agents.state.installed`):``}function Row({agent:e,selected:t,onSelect:n}){let r=stateWord(e);return i(`button`,{type:`button`,role:`option`,"aria-selected":t,tabIndex:t?0:-1,"data-id":e.id,class:`agents-row type-body`,onClick:n,children:[i(f,{icon:e.icon,name:e.name}),i(`span`,{class:`agents-row__name`,children:e.name}),r!==``&&i(`span`,{class:`agents-row__state type-help${e.enabled&&e.installed?` is-on`:``}${e.job?.state===`failed`?` is-failed`:``}`,children:r})]})}function GeneralRow({selected:e,onSelect:t}){return i(`button`,{type:`button`,role:`option`,"aria-selected":e,tabIndex:e?0:-1,"data-id":b,class:`agents-row type-body`,onClick:t,children:[i(`span`,{class:`agents-general-icon`,"aria-hidden":`true`}),i(`span`,{class:`agents-row__name`,children:o(`app.agents.general`)})]})}function General({preferences:e}){let t=c(e.subscribe,e.aiChat);return i(`div`,{class:`agents-general`,children:i(`section`,{class:`agents-group`,"aria-labelledby":`agents-chat`,children:[i(`h3`,{id:`agents-chat`,class:`agents-group__heading type-section-heading`,children:o(`app.agents.aiChat`)}),i(`div`,{role:`radiogroup`,"aria-labelledby":`agents-chat`,class:`agents-group__choices`,children:D.map(n=>i(`div`,{children:[i(`label`,{class:`agents-check type-body`,children:[i(`input`,{type:`radio`,name:`agents-chat`,value:n,checked:t===n,"aria-describedby":`agents-chat-${n}`,onChange:()=>e.setAiChat(n)}),i(`span`,{children:o(O[n])})]}),i(`p`,{id:`agents-chat-${n}`,class:`agents-group__help type-help`,children:o(k[n])})]},n))})]})})}function Blocked({agent:e,node:n,uv:r}){if(e.blocked===null)return null;let a=e.blocked===`node`&&!n?T:e.blocked===`uv`&&!r?E:null;return i(`p`,{class:`agents-note type-help`,children:[o(`app.agents.blocked.${e.blocked}`),a&&i(t,{children:[` `,i(`a`,{class:`agents-link`,href:a,onClick:e=>{e.preventDefault(),openLink(a)},children:o(e.blocked===`node`?`app.agents.blocked.nodeLink`:`app.agents.blocked.uvLink`)})]})]})}function Progress({percent:e}){return i(`div`,{class:`agents-progress`,role:`progressbar`,"aria-label":o(`app.agents.state.installing`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e??void 0,children:i(`span`,{class:`agents-progress__bar${e===null?` is-unknown`:``}`,style:e===null?void 0:{width:`${e}%`}})})}function Models({store:e,agent:n,error:r}){let a=n.job?.kind===`models`&&n.job.state===`running`,s=n.job?.kind===`models`&&n.job.state===`failed`?n.job.error:null,c=n.options,l=c&&c.readAt!==``&&Number.isFinite(Date.parse(c.readAt))?u(Date.parse(c.readAt)):null;return i(`section`,{class:`agents-group`,"aria-labelledby":`agents-models-${n.id}`,children:[i(`div`,{class:`agents-group__head`,children:[i(`h3`,{id:`agents-models-${n.id}`,class:`agents-group__heading type-section-heading`,children:o(`app.agents.models`)}),i(`button`,{type:`button`,class:`ui-button type-button agents-refresh`,disabled:a,onClick:()=>void e.refreshModels(n.id),children:[a&&i(v,{}),i(`span`,{children:o(a?`app.agents.modelsReading`:`app.agents.modelsRefresh`)})]})]}),c===null&&!a&&!s&&i(t,{children:[i(`p`,{class:`agents-note type-body`,children:o(`app.agents.modelsEmpty`)}),i(`p`,{class:`agents-note type-help`,children:o(`app.agents.modelsEmptyHint`)})]}),c?.options.map(t=>{let r=t.category??t.id;return i(h,{label:t.name,children:a=>i(ValueSelect,{id:a.id,option:t,chosen:n.chosen[r]??``,onChoose:t=>void e.choose(n.id,r,t)})},t.id)}),l!==null&&!a&&i(`p`,{class:`agents-note type-help`,children:o(`app.agents.modelsRead`,{time:l})}),s&&i(`p`,{class:`agents-note type-error-message`,role:`alert`,children:[reasonText(s),s.key===`app.agent.authRequired`&&i(`span`,{class:`agents-note__more type-help`,children:o(`app.agents.signInHint`)})]}),r&&i(`p`,{class:`agents-note type-error-message`,role:`alert`,children:r})]})}function Detail({store:e,agent:n,state:r}){let a=r.catalog,s=n.job?.kind===`install`&&n.job.state===`running`,c=n.job?.state===`failed`&&n.job.kind!==`models`?n.job.error:null,l=r.errors[n.id]??null,u=!n.installed&&n.how!==`none`&&n.how!==`custom`&&n.blocked===null,d=n.installed&&(n.installedVia===`download`||n.installedVia===`package`);return i(`div`,{class:`agents-detail__page`,children:[i(`header`,{class:`agents-detail__head`,children:[i(f,{icon:n.icon,name:n.name,size:20}),i(`h2`,{class:`agents-detail__name type-dialog-title`,children:n.name}),n.version&&i(`span`,{class:`agents-detail__version type-help`,children:o(`app.agents.version`,{version:n.version})})]}),n.description!==``&&i(`p`,{class:`agents-detail__text type-body`,children:n.description}),i(`dl`,{class:`agents-meta type-help`,children:[n.license&&i(t,{children:[i(`dt`,{children:o(`app.agents.license`)}),i(`dd`,{children:n.license})]}),n.website&&i(t,{children:[i(`dt`,{children:o(`app.agents.website`)}),i(`dd`,{children:i(`a`,{class:`agents-link`,href:n.website,onClick:e=>{e.preventDefault(),openLink(n.website)},children:n.website})})]}),n.repository&&n.repository!==n.website&&i(t,{children:[i(`dt`,{children:o(`app.agents.repository`)}),i(`dd`,{children:i(`a`,{class:`agents-link`,href:n.repository,onClick:e=>{e.preventDefault(),openLink(n.repository)},children:n.repository})})]}),i(`dt`,{children:o(`app.agents.status`)}),i(`dd`,{children:n.installed?`${o(`app.agents.via.${n.installedVia??`path`}`)}${n.installedVersion?` · ${o(`app.agents.version`,{version:n.installedVersion})}`:``}`:n.how===`none`?o(`app.agents.cannotInstall`):o(`app.agents.how.${n.how}`)})]}),i(`div`,{class:`agents-actions`,children:[u&&!s&&i(`button`,{type:`button`,class:`ui-button ui-button--primary type-button`,onClick:()=>void e.install(n.id),children:o(c?`app.agents.tryAgain`:`app.agents.install`)}),s&&i(`button`,{type:`button`,class:`ui-button type-button`,disabled:!0,children:[i(v,{}),i(`span`,{children:o(`app.agents.state.installing`)})]}),n.installed&&!s&&n.updateAvailable&&d&&i(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>void e.install(n.id),children:o(`app.agents.update`)}),n.installed&&!s&&i(`button`,{type:`button`,class:`ui-button type-button${n.enabled?``:` ui-button--primary`}`,onClick:()=>void e.turn(n.id,!n.enabled),children:n.enabled?o(`app.agents.turnOff`):o(`app.agents.turnOn`)}),d&&!s&&i(`button`,{type:`button`,class:`ui-button ui-button--quiet ui-button--danger type-button`,onClick:()=>void e.uninstall(n.id),children:o(`app.agents.uninstall`)})]}),s&&i(Progress,{percent:n.job?.percent??null}),!n.installed&&a&&i(Blocked,{agent:n,node:a.node,uv:a.uv}),!n.installed&&n.blocked!==null&&n.install&&i(`p`,{class:`agents-note type-help`,children:[o(`app.agents.byHand`),` `,i(`code`,{class:`type-code`,children:n.install})]}),c&&i(`p`,{class:`agents-note type-error-message`,role:`alert`,children:reasonText(c)}),l&&i(`p`,{class:`agents-note type-error-message`,role:`alert`,children:l}),n.installed&&i(Models,{store:e,agent:n,error:null})]})}function ListFoot({store:e,state:t}){let n=t.catalog,r=n?.updated&&Number.isFinite(Date.parse(n.updated))?u(Date.parse(n.updated)):null,a=t.failure??(n?.refreshError?reasonText(n.refreshError):null);return i(`footer`,{class:`agents-list__foot`,children:[i(`p`,{class:`agents-list__updated type-help`,role:`status`,children:t.refreshing?o(`app.agents.updating`):r===null?o(`app.agents.neverUpdated`):n?.source===`snapshot`?o(`app.agents.updatedSnapshot`,{time:r}):o(`app.agents.updated`,{time:r})}),a&&!t.refreshing&&i(`p`,{class:`agents-list__problem type-warning-message`,children:a}),i(`button`,{type:`button`,class:`ui-button type-button agents-refresh`,disabled:t.refreshing,onClick:()=>void e.refresh(),children:[t.refreshing&&i(v,{}),i(`span`,{children:o(`app.agents.refresh`)})]})]})}function AgentsScreen({store:t,preferences:r}){let s=c(t.subscribe,t.snapshot),l=n(null),u=n(null),d=n(!1),[f,p]=e(null);a(()=>{t.start()},[t]),a(()=>{if(s.status!==`ready`||d.current)return;d.current=!0;let e=document.activeElement;(!e||e===document.body||e.classList.contains(`ui-dialog__close`)||e.classList.contains(`ui-dialog`))&&u.current?.focus()},[s.status]),a(()=>{f!==null&&(l.current?.querySelector(`[data-id="${CSS.escape(f)}"]`)?.focus(),p(null))},[f]);let{on:m,rest:h}=sections(s),g=[b,...m.map(e=>e.id),...h.map(e=>e.id)],_=s.selected??`general`,x=s.catalog?.agents.find(e=>e.id===_)??null,move=e=>{let n=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,r=e.key===`Home`?0:e.key===`End`?g.length-1:null;if(n===0&&r===null)return;e.preventDefault();let i=g.indexOf(_),a=r??Math.min(g.length-1,Math.max(0,(i<0?0:i)+n));g[a]!==void 0&&(t.select(g[a]),p(g[a]))};return s.status===`loading`?i(`div`,{class:`agents-screen is-loading`,role:`status`,children:[i(v,{}),i(`span`,{class:`type-help`,children:o(`app.agents.loading`)})]}):s.status===`failed`||!s.catalog?i(`div`,{class:`agents-screen is-empty`,children:i(y,{title:o(`app.agents.failed.title`),hint:s.failure??o(`app.agents.failed.hint`),actions:[{label:o(`app.assistant.tryAgain`),run:()=>void t.reload()}]})}):i(`div`,{class:`agents-screen`,children:[i(`nav`,{class:`agents-list`,"aria-label":o(`app.agents.list`),children:[i(`input`,{ref:u,type:`search`,class:`agents-list__search type-input`,value:s.query,placeholder:o(`app.agents.search`),"aria-label":o(`app.agents.search`),onInput:e=>t.search(e.currentTarget.value)}),i(`div`,{ref:l,class:`agents-list__scroll`,role:`listbox`,"aria-label":o(`app.agents.list`),onKeyDown:move,children:[i(GeneralRow,{selected:_===b,onSelect:()=>t.select(b)}),i(`h3`,{class:`agents-list__heading type-section-heading`,children:o(`app.agents.on`)}),m.length===0&&(s.query===``||h.length===0)&&i(`p`,{class:`agents-list__none type-help`,children:s.query===``?o(`app.agents.noneOn`):o(`app.agents.noMatch`)}),m.map(e=>i(Row,{agent:e,selected:_===e.id,onSelect:()=>t.select(e.id)},e.id)),i(`h3`,{class:`agents-list__heading type-section-heading`,children:o(`app.agents.all`)}),h.length===0&&m.length>0&&i(`p`,{class:`agents-list__none type-help`,children:o(`app.agents.allShown`)}),h.length===0&&m.length===0&&s.query!==``&&i(`p`,{class:`agents-list__none type-help`,children:o(`app.agents.noMatch`)}),h.map(e=>i(Row,{agent:e,selected:_===e.id,onSelect:()=>t.select(e.id)},e.id))]}),i(ListFoot,{store:t,state:s})]}),i(`section`,{class:`agents-detail`,"aria-label":x?.name??o(`app.agents.general`),children:_===`general`||x===null?i(General,{preferences:r}):i(Detail,{store:t,agent:x,state:s})})]})}function AgentsDialog({host:e,preferences:t,onClose:n}){let s=r(()=>new AgentsStore(e,{changed:()=>void l()?.resync()}),[e]);return a(()=>()=>s.dispose(),[s]),i(m,{title:o(`app.agents.title`),size:`large`,body:`split`,class:`agents-dialog`,onClose:n,footer:i(_,{actions:[{id:`done`,label:o(`app.common.done`),role:`primary`,onClick:n}]}),children:i(AgentsScreen,{store:s,preferences:t})})}export{AgentsDialog};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as t,i as r,n as a,o,r as s,t as u}from"./rolldown-runtime-B8BYMn-z.js";import{a as d,c as f,d as p,h,i as g,n as _,r as v,s as y,u as b}from"./vendor-NJP34MHU.js";import{i as x,n as S}from"./translator-CTBxdhz9.js";import{C,l as w,m as T,x as E}from"./frontend-By89859W.js";import{An as D,Bt as O,Gn as k,Kn as ee,Mn as A,Nn as j,Pn as te,Tn as ne,Un as re,Wn as M,bn as ie,ct as ae,jn as oe,kn as se,lt as ce,t as le,ut as ue,yn as de}from"./bridgeInstance-CJkr34d9.js";import{A as fe,C as pe,D as me,F as he,L as ge,M as _e,N as ve,O as ye,R as N,S as be,T as xe,_ as Se,a as Ce,b as we,c as Te,f as Ee,g as De,h as Oe,i as ke,k as Ae,l as je,m as P,n as Me,o as Ne,p as Pe,r as Fe,s as F,t as I,u as L,v as Ie,w as Le,x as Re,y as ze}from"./dist-CRJyslwo.js";import{t as Be}from"./dist-DgvQWhKm.js";import{C as Ve,S as He,T as Ue,g as We,x as Ge}from"./engine-BPUfS3r2.js";import{t as Ke}from"./dist-BqwyxNP3.js";import{t as qe}from"./platform-PXoldsjF.js";import{C as Je,D as Ye,E as Xe,O as Ze,T as Qe,b as $e,g as et,h as tt,p as nt,s as rt,t as it,w as at,x as ot}from"./bpmnTheme-iB2hl29R.js";import{u as st}from"./ui-B2q39Bca.js";import{a as ct,i as lt,r as ut}from"./lib-D6xZQFAF.js";import{i as dt,o as ft}from"./preferences-C7SSy7Wf.js";import{$ as pt,$t as mt,A as ht,An as gt,At as _t,B as vt,Bt as yt,C as bt,Cn as xt,Ct as St,D as Ct,Dn as wt,Dt as Tt,E as Et,En as Dt,Et as Ot,F as kt,Fn as At,Ft as jt,G as Mt,Gt as Nt,H as Pt,Ht as Ft,I as It,In as Lt,It as Rt,J as zt,Jt as Bt,K as Vt,Kt as Ht,L as Ut,M as Wt,Mn as Gt,Mt as Kt,N as qt,Nn as Jt,Nt as Yt,O as R,On as Xt,Ot as Zt,P as Qt,Pn as $t,Pt as en,Q as tn,Qt as nn,R as rn,Rt as an,S as sn,Sn as cn,St as ln,T as un,Tn as dn,Tt as pn,U as mn,Ut as hn,V as gn,Vt as _n,W as z,Wt as vn,X as yn,Xt as bn,Y as xn,Yt as Sn,Z as Cn,Zt as wn,_ as Tn,_n as En,_t as Dn,an as On,at as kn,b as An,bn as jn,bt as Mn,c as Nn,cn as Pn,ct as Fn,d as In,dn as Ln,dt as Rn,en as zn,et as Bn,f as Vn,fn as Hn,ft as Un,g as Wn,gn as Gn,gt as Kn,h as qn,hn as Jn,ht as Yn,i as Xn,in as Zn,it as B,j as Qn,jn as $n,jt as er,k as tr,kn as nr,kt as rr,l as ir,ln as ar,lt as sr,mn as cr,mt as lr,n as ur,nn as dr,nt as V,on as fr,ot as pr,p as mr,pn as hr,pt as gr,q as _r,qt as vr,rn as yr,rt as br,sn as xr,st as Sr,tn as Cr,tt as wr,u as Tr,un as Er,ut as Dr,v as Or,vn as kr,vt as Ar,w as jr,wn as Mr,wt as Nr,x as Pr,xn as Fr,xt as Ir,y as Lr,yn as Rr,yt as zr,z as H,zt as Br}from"./duplicate-rWDlHiZr.js";import{$ as Vr,$t as Hr,A as Ur,At as Wr,B as Gr,Bt as Kr,Ct as qr,D as Jr,E as Yr,Et as Xr,F as Zr,Ft as Qr,Gt as $r,H as ei,Ht as ti,I as ni,It as ri,J as U,Jt as ii,K as W,Kt as ai,L as oi,Lt as si,M as ci,Mt as li,N as ui,Nt as di,O as fi,Ot as pi,P as mi,Pt as hi,Qt as gi,R as _i,Rt as vi,S as yi,St as bi,T as xi,Tt as Si,U as Ci,V as wi,Vt as Ti,W as Ei,Wt as Di,Xt as Oi,Y as G,Yt as ki,_ as Ai,a as ji,bt as Mi,ct as Ni,dt as Pi,et as Fi,f as Ii,ft as Li,g as Ri,h as zi,in as K,j as Bi,jt as Vi,k as Hi,kt as Ui,lt as Wi,m as Gi,mt as Ki,nn as qi,nt as Ji,o as Yi,ot as Xi,p as Zi,pt as Qi,q as $i,qt as ea,r as ta,rn as na,t as ra,tn as ia,ut as aa,v as q,vt as oa,w as sa,wt as ca,x as la,xt as ua,y as da,yt as fa,z as pa,zt as ma}from"./Viewer-CZiVl0t6.js";import{a as ha,i as ga,s as J}from"./dist-CHluRwHI.js";import{a as _a,n as va,r as ya,t as ba}from"./dist-TNwbKIWT.js";import{i as xa,n as Sa,r as Ca,t as wa}from"./stackblur-es-Djj-lnDR.js";import{I as Ta,M as Ea,c as Da,ht as Oa,pt as ka,t as Aa}from"./dist-CsBP6QjA.js";import{t as ja}from"./array-move-Bc4mVEdq.js";import{t as Ma}from"./dist-Km3QNqlU.js";import{t as Na}from"./groovy-DASguM_i.js";import{n as Pa}from"./dist-CnDXCEJ_.js";import{a as Fa,c as Ia,f as La,i as Ra,l as za,m as Ba,p as Va,r as Ha,s as Ua,u as Wa}from"./apply-DwO6xN9h.js";import{n as Ga,s as Ka}from"./dockLayout-CxOMo-Nl.js";P();function scriptWhatOf(t,r={}){switch(t){case`CONDITION`:case`FEEL_CONDITION`:return x(`app.scriptTab.condition`);case`EXECUTION_LISTENER`:return x(`app.scriptTab.executionListener`,{event:r.event??``});case`TASK_LISTENER`:return x(`app.scriptTab.taskListener`,{event:r.event??``});case`PARAMETER`:case`INPUT_MAPPING`:case`OUTPUT_MAPPING`:return r.parameter?.direction===`output`?x(`app.scriptTab.output`,{name:r.parameter.name}):x(`app.scriptTab.input`,{name:r.parameter?.name??``});case`TASK_BODY`:return x(`app.scriptTab.script`)}}function scriptTitle(t,r){return x(`app.scriptTab.title`,{name:t,what:r})}function scriptTitleOf(t){return scriptTitle(t.shared?x(`app.scriptTab.nameWithId`,{name:t.name,id:t.slot.elementId}):t.name,scriptWhatOf(t.slot.owner,t))}var qa=new Set(`String.string.str.CharSequence.char.Char.Character.Integer.int.Int.int32.int64.Long.long.Short.short.Byte.byte.Double.double.Float.float.float32.float64.decimal.Decimal.BigDecimal.BigInteger.Number.number.Boolean.boolean.bool.Date.LocalDate.LocalDateTime.LocalTime.OffsetDateTime.ZonedDateTime.Instant.Duration.UUID.Guid.DateTime.DateTimeOffset.TimeSpan.date.datetime.Time`.split(`.`)),Ja=new Set([`List`,`ArrayList`,`LinkedList`,`Set`,`HashSet`,`LinkedHashSet`,`TreeSet`,`Collection`,`Iterable`,`Array`,`array`,`Optional`,`IList`,`IEnumerable`,`ICollection`,`IReadOnlyList`,`IReadOnlyCollection`,`Sequence`]),Ya=new Set([`null`,`undefined`,`None`,`nil`,``]);function splitTop(t,r){let a=[],o=0,s=0;for(let u=0;u<t.length;u+=1){let d=t[u];d===`<`||d===`[`||d===`(`?o+=1:d===`>`||d===`]`||d===`)`?--o:d===r&&o===0&&(a.push(t.slice(s,u)),s=u+1)}return a.push(t.slice(s)),a}function unwrap$1(t){let r=t.trim().replace(/^readonly\s+/,``).replace(/^[*&]+/,``).replace(/^["']|["']$/g,``).replace(/\?$/,``).trim(),a=r.split(`|`).map(t=>t.trim()).filter(t=>!Ya.has(t));return a.length===1?a[0]:a.length===0?``:r}r(unwrap$1,`unwrap`);function parse(t){if(t.endsWith(`[]`))return{base:`array`,args:[t.slice(0,-2)]};if(t.startsWith(`[]`))return{base:`array`,args:[t.slice(2)]};let r=/^([A-Za-z_][\w.]*)\s*[<[]([\s\S]*)[>\]]$/.exec(t);return r?{base:r[1],args:splitTop(r[2],`,`)}:{base:t,args:null}}function open$1(t){return{kind:`open`,name:t}}r(open$1,`open`);function declared(t,r,a,o){let s=r.get(t);if(!s||a>3||o.includes(t))return open$1(t);if(s.kind===`enum`)return{kind:`enum`,name:t,constants:s.constants};if(s.open)return open$1(t);let u=s.extends===null?void 0:r.get(s.extends);if(s.extends!==null&&(!u||u.kind!==`class`||u.open||u.extends!==null))return open$1(t);let d=s.fields,f=new Set(d.map(t=>t.name)),p=(u?.fields??[]).filter(t=>!f.has(t.name));return{kind:`object`,name:t,fields:[...d,...p].map(s=>({name:s.name,serialised:s.serialised,type:resolveType(s.type,r,a+1,[...o,t])}))}}function resolveType(t,r,a=1,o=[]){let s=unwrap$1(t??``);if(s===``)return open$1(``);let{base:u,args:d}=parse(s),f=u.slice(u.lastIndexOf(`.`)+1);return d!==null&&d.length===1&&Ja.has(f)?{kind:`collection`,name:f,element:resolveType(d[0],r,a,o)}:d===null&&qa.has(f)?{kind:`scalar`,name:f}:declared(f,r,a,o)}function fieldNamed(t,r){return t.find(t=>t.name===r)??t.find(t=>/^[A-Z]/.test(t.name)&&t.name.charAt(0).toLowerCase()+t.name.slice(1)===r)}var Xa=new Set([`input`,`loop element`]);function visibleAt(t,r,a,o){return o.wholeProcess?r.elementId===a?Xa.has(r.where)||o.includeOwnCode===!0&&r.path!==void 0:!Xa.has(r.where)&&j(t,r.elementId,a):r.elementId===a&&r.path!==void 0}function knownVariable(t,r,a){let o=r.map(t=>({elementId:t.elementId,where:t.where,type:t.type??null,sample:t.sample??null,path:t.path??null,line:t.line??null,offset:t.offset??null})),s=[...new Set(o.map(t=>t.type))],u=s.filter(t=>t!==null);if(u.length>1)return{name:t,certainty:`ambiguous`,type:null,shape:resolveType(null,a),writers:o};if(u.length===1&&s.length===1){let r=resolveType(u[0],a);return{name:t,certainty:r.kind===`open`?`open`:`exact`,type:u[0],shape:r,writers:o}}return{name:t,certainty:`open`,type:null,shape:resolveType(null,a),writers:o}}function variablesAt(t,r,a){let o=new Map(t.types.map(t=>[t.name,t])),s=t.inputs??[],u=t.model.variables.filter(o=>o.writes&&visibleAt(t.order,o,r,a));return{variables:[...new Set([...u.map(t=>t.name),...a.wholeProcess?s:[]])].sort().map(t=>knownVariable(t,u.filter(r=>r.name===t),o)),startVariablesUnknown:s.length===0}}function namesOf$2(t){let r=new Map,visit=t=>{t?.id&&(r.set(t.id,typeof t.name==`string`&&t.name.trim()?t.name.trim():t.id),(t.flowElements??[]).forEach(visit))};return(t?.rootElements??[]).filter(t=>t.$type===`bpmn:Process`).forEach(t=>(t.flowElements??[]).forEach(visit)),r}r(namesOf$2,`namesOf`);function writerOf(t,r,a){return t.path===null?{label:r.get(t.elementId)??t.elementId,elementId:t.elementId,...a?{diagramPath:a}:{},...t.sample===null?{}:{sample:t.sample}}:{label:`${de(t.path)}:${t.line??0}`,elementId:t.elementId,path:t.path,...t.line===null?{}:{line:t.line},...t.offset===null?{}:{offset:t.offset}}}function variableOf(t,r,a,o){return{name:t.name,...t.type===null?{}:{type:t.type},declaredByScript:k(a,t.name),writers:t.writers.map(t=>writerOf(t,r,o))}}function scriptContextOf(t,r,a){let o={variables:[...M(t.definitions).uses,...ie(t.workers)]},s=te(t.definitions).flows.get(r)?.target??r,u=variablesAt({model:o,order:A(t.definitions),types:t.workers?.types??[],inputs:t.inputs},s,{wholeProcess:!0}),d=namesOf$2(t.definitions);return u.variables.map(r=>variableOf(r,d,a,t.diagramPath))}var Za=/\b(?:byte|short|int|integer|long|float|double|number|bigdecimal|biginteger)\b/i,Qa=/\b(?:byte|short|int|integer|long|biginteger)\b/i,$a=/\b(?:bool|boolean)\b/i,eo=/^(?:list|set|collection|sequence|iterable|sortedset|array)$/i,to=/^(?:map|object|jsonnode|jsonobject|record|dictionary)$/i;function valueFor(t){if(!t)return`?`;let r=t.replace(/<.*$/,``).trim();return eo.test(r)||/\[\]$/.test(r)?[]:to.test(r)?{}:$a.test(r)?!1:Qa.test(r)||Za.test(r)?0:`?`}function exampleJson(t){return JSON.stringify(Object.fromEntries(t.map(t=>[t.name,valueFor(t.type)])),null,2)}function exampleInput(t,r,a,o){let s=new Map;(r?.variables??[]).filter(t=>t.elementId===a&&t.type).forEach(t=>s.set(t.name,t.type??null));let{uses:u}=M(t),d=new Set(u.filter(t=>t.writes&&t.elementId===a).map(t=>t.name)),f=new Set;return u.filter(t=>t.writes&&!d.has(t.name)).forEach(t=>{j(o,t.elementId,a)&&f.add(t.name)}),(r?.variables??[]).filter(t=>t.elementId===a&&!t.writes).forEach(t=>f.add(t.name)),[...f].sort().map(t=>({name:t,type:s.get(t)??null}))}var no=`camundaModeler:exampleOutputJson`,ro=[`serviceTask`,`sendTask`,`receiveTask`,`businessRuleTask`,`userTask`,`callActivity`],io={JOB_TYPE:`JOB_TYPE`,TOPIC:`TOPIC`,JAVA_CLASS:`CLASS`,BEAN:`BEAN`};function elementSubjects(t){let r=new Map,add=(t,a)=>{let o=r.get(t);o?o.push(a):r.set(t,[a])},a=new Map(t.messages.map(t=>[t.id,t.name]));return t.workers.forEach(t=>add(t.elementId,{kind:io[t.kind],value:t.value,...t.listener?{listener:t.listener}:{}})),t.calls.forEach(t=>add(t.elementId,{kind:`PROCESS`,value:t.calledProcessId})),t.decisionUses.forEach(t=>add(t.elementId,{kind:`DECISION`,value:t.decisionId})),t.messageUses.filter(t=>t.catches).forEach(t=>{let r=a.get(t.messageId);r&&add(t.elementId,{kind:`MESSAGE`,value:r})}),t.elements.filter(t=>ro.includes(t.type)||r.has(t.id)).map(t=>({elementId:t.id,elementType:t.type,label:t.label,bindings:r.get(t.id)??[]}))}function withRuntimeFacts(t,r){let{reached:a=null,paused:o}=r;return!a&&(!o||o.size===0)?t:t.map(t=>({...t,reached:a&&t.state!==`notApplicable`?a.has(t.elementId):t.reached,paused:o?.has(t.elementId)??t.paused}))}function isBadged(t){return t.state!==`notApplicable`&&ro.includes(t.elementType)}var ao=/^Focus process instance (.+)$/;function localised(t){if(typeof t!=`string`)return String(t??``);let r=ao.exec(t);return r?ct(`Focus process instance {id}`,{id:r[1]}):ct(t)}var oo=`svg, [contenteditable]`;function localiseText(t){try{if(!t||typeof t.data!=`string`||t.parentElement?.closest(oo))return;let r=t.data,a=r.trim();if(!a)return;let o=localised(a);o!==a&&(t.data=r.replace(a,o))}catch{}}var so=[`title`,`aria-label`];function localiseLabels(t){try{if(!t||typeof t.getAttribute!=`function`||typeof t.setAttribute!=`function`||t.closest?.(oo))return;for(let r of so){let a=t.getAttribute(r);if(!a)continue;let o=localised(a);o!==a&&t.setAttribute(r,o)}}catch{}}function localiseTree(t){try{if(!t||typeof t.nodeType!=`number`)return;if(t.nodeType===Node.TEXT_NODE){localiseText(t);return}if(t.nodeType!==Node.ELEMENT_NODE)return;let r=t;if(localiseLabels(r),r.querySelectorAll?.(`[title], [aria-label]`).forEach(localiseLabels),typeof document<`u`&&typeof document.createTreeWalker==`function`){let t=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(;t.nextNode();)localiseText(t.currentNode)}}catch{}}var TokenSimulationTranslator=class{static $inject=[`canvas`];constructor(t){try{if(!t||typeof t.getContainer!=`function`)return;let r=t.getContainer();if(!r||typeof r.nodeType!=`number`||(localiseTree(r),typeof MutationObserver!=`function`))return;new MutationObserver(t=>{try{for(let r of t)r.type===`attributes`?localiseLabels(r.target):r.type===`characterData`?localiseText(r.target):r.addedNodes.forEach(localiseTree)}catch{}}).observe(r,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:so})}catch{}}},co={__init__:[`tokenSimulationTranslator`],tokenSimulationTranslator:[`type`,TokenSimulationTranslator]};function BaseModeler(t){Ei.call(this,t),this.on(`import.parse.complete`,function(t){t.error||this._collectIds(t.definitions,t.elementsById)},this),this.on(`diagram.destroy`,function(){this.get(`moddle`).ids.clear()},this)}K(BaseModeler,Ei),BaseModeler.prototype._createModdle=function(t){var r=Ei.prototype._createModdle.call(this,t);return r.ids=new Ke([32,36,1]),r},BaseModeler.prototype._collectIds=function(t,r){var a=t.$model.ids,o;for(o in a.clear(),r)a.claim(o,r[o])};var lo=300;function KeepSelectionVisible(t,r,a){this._selectionWasVisible=!1;let o=Fe(()=>{this._selectionWasVisible=isSelectionVisible()},lo);t.on(`canvas.viewbox.changed`,o),t.on(`selection.changed`,o),t.on(`diagram.destroy`,()=>{o.cancel()}),t.on(`canvas.resized`,()=>{var t=a.get();if(t.length&&this._selectionWasVisible&&!isSelectionVisible()){var o=r.getRootElement();r.scrollToElement(t.concat(o))}});function isSelectionVisible(){var t=a.get();if(!t.length)return!1;var o=Xr(t),s=r.viewbox(),u=Xi(o),d=Xi(s);return u.left>=d.left&&u.right<=d.right&&u.top>=d.top&&u.bottom<=d.bottom}this._flush=o.flush}KeepSelectionVisible.$inject=[`eventBus`,`canvas`,`selection`];var uo={__init__:[`keepSelectionVisible`],__depends__:[ta],keepSelectionVisible:[`type`,KeepSelectionVisible]};function NavigatedViewer(t){ra.call(this,t)}K(NavigatedViewer,ra),NavigatedViewer.prototype._navigationModules=[uo,$n,Xt,wt],NavigatedViewer.prototype._modules=[].concat(ra.prototype._modules,NavigatedViewer.prototype._navigationModules);var fo={align:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2000 2000">
|
|
1
|
+
import{a as t,i as r,n as a,o,r as s,t as u}from"./rolldown-runtime-B8BYMn-z.js";import{a as d,c as f,d as p,h,i as g,n as _,r as v,s as y,u as b}from"./vendor-NJP34MHU.js";import{i as x,n as S}from"./translator-CS9eR0My.js";import{C,l as w,m as T,x as E}from"./frontend-BLfXy4OQ.js";import{An as D,Bt as O,Gn as k,Kn as ee,Mn as A,Nn as j,Pn as te,Tn as ne,Un as re,Wn as M,bn as ie,ct as ae,jn as oe,kn as se,lt as ce,t as le,ut as ue,yn as de}from"./bridgeInstance-D0bzpNGz.js";import{A as fe,C as pe,D as me,F as he,L as ge,M as _e,N as ve,O as ye,R as N,S as be,T as xe,_ as Se,a as Ce,b as we,c as Te,f as Ee,g as De,h as Oe,i as ke,k as Ae,l as je,m as P,n as Me,o as Ne,p as Pe,r as Fe,s as F,t as I,u as L,v as Ie,w as Le,x as Re,y as ze}from"./dist-CRJyslwo.js";import{t as Be}from"./dist-DgvQWhKm.js";import{C as Ve,S as He,T as Ue,g as We,x as Ge}from"./engine-BPUfS3r2.js";import{t as Ke}from"./dist-BqwyxNP3.js";import{t as qe}from"./platform-BS7bgwr3.js";import{C as Je,D as Ye,E as Xe,O as Ze,T as Qe,b as $e,g as et,h as tt,p as nt,s as rt,t as it,w as at,x as ot}from"./bpmnTheme-Divwrkjy.js";import{u as st}from"./ui-AICOEtWR.js";import{a as ct,i as lt,r as ut}from"./lib-DJ1i09sd.js";import{i as dt,o as ft}from"./preferences-C_EXTz45.js";import{$ as pt,$t as mt,A as ht,An as gt,At as _t,B as vt,Bt as yt,C as bt,Cn as xt,Ct as St,D as Ct,Dn as wt,Dt as Tt,E as Et,En as Dt,Et as Ot,F as kt,Fn as At,Ft as jt,G as Mt,Gt as Nt,H as Pt,Ht as Ft,I as It,In as Lt,It as Rt,J as zt,Jt as Bt,K as Vt,Kt as Ht,L as Ut,M as Wt,Mn as Gt,Mt as Kt,N as qt,Nn as Jt,Nt as Yt,O as R,On as Xt,Ot as Zt,P as Qt,Pn as $t,Pt as en,Q as tn,Qt as nn,R as rn,Rt as an,S as sn,Sn as cn,St as ln,T as un,Tn as dn,Tt as pn,U as mn,Ut as hn,V as gn,Vt as _n,W as z,Wt as vn,X as yn,Xt as bn,Y as xn,Yt as Sn,Z as Cn,Zt as wn,_ as Tn,_n as En,_t as Dn,an as On,at as kn,b as An,bn as jn,bt as Mn,c as Nn,cn as Pn,ct as Fn,d as In,dn as Ln,dt as Rn,en as zn,et as Bn,f as Vn,fn as Hn,ft as Un,g as Wn,gn as Gn,gt as Kn,h as qn,hn as Jn,ht as Yn,i as Xn,in as Zn,it as B,j as Qn,jn as $n,jt as er,k as tr,kn as nr,kt as rr,l as ir,ln as ar,lt as sr,mn as cr,mt as lr,n as ur,nn as dr,nt as V,on as fr,ot as pr,p as mr,pn as hr,pt as gr,q as _r,qt as vr,rn as yr,rt as br,sn as xr,st as Sr,tn as Cr,tt as wr,u as Tr,un as Er,ut as Dr,v as Or,vn as kr,vt as Ar,w as jr,wn as Mr,wt as Nr,x as Pr,xn as Fr,xt as Ir,y as Lr,yn as Rr,yt as zr,z as H,zt as Br}from"./duplicate-C-AiqE1T.js";import{$ as Vr,$t as Hr,A as Ur,At as Wr,B as Gr,Bt as Kr,Ct as qr,D as Jr,E as Yr,Et as Xr,F as Zr,Ft as Qr,Gt as $r,H as ei,Ht as ti,I as ni,It as ri,J as U,Jt as ii,K as W,Kt as ai,L as oi,Lt as si,M as ci,Mt as li,N as ui,Nt as di,O as fi,Ot as pi,P as mi,Pt as hi,Qt as gi,R as _i,Rt as vi,S as yi,St as bi,T as xi,Tt as Si,U as Ci,V as wi,Vt as Ti,W as Ei,Wt as Di,Xt as Oi,Y as G,Yt as ki,_ as Ai,a as ji,bt as Mi,ct as Ni,dt as Pi,et as Fi,f as Ii,ft as Li,g as Ri,h as zi,in as K,j as Bi,jt as Vi,k as Hi,kt as Ui,lt as Wi,m as Gi,mt as Ki,nn as qi,nt as Ji,o as Yi,ot as Xi,p as Zi,pt as Qi,q as $i,qt as ea,r as ta,rn as na,t as ra,tn as ia,ut as aa,v as q,vt as oa,w as sa,wt as ca,x as la,xt as ua,y as da,yt as fa,z as pa,zt as ma}from"./Viewer-CZiVl0t6.js";import{a as ha,i as ga,s as J}from"./dist-CHluRwHI.js";import{a as _a,n as va,r as ya,t as ba}from"./dist-TNwbKIWT.js";import{i as xa,n as Sa,r as Ca,t as wa}from"./stackblur-es-Djj-lnDR.js";import{I as Ta,M as Ea,c as Da,ht as Oa,pt as ka,t as Aa}from"./dist-CsBP6QjA.js";import{t as ja}from"./array-move-Bc4mVEdq.js";import{t as Ma}from"./dist-Km3QNqlU.js";import{t as Na}from"./groovy-DASguM_i.js";import{n as Pa}from"./dist-CnDXCEJ_.js";import{a as Fa,c as Ia,f as La,i as Ra,l as za,m as Ba,p as Va,r as Ha,s as Ua,u as Wa}from"./apply-B0vauBJn.js";import{n as Ga,s as Ka}from"./dockLayout-CxOMo-Nl.js";P();function scriptWhatOf(t,r={}){switch(t){case`CONDITION`:case`FEEL_CONDITION`:return x(`app.scriptTab.condition`);case`EXECUTION_LISTENER`:return x(`app.scriptTab.executionListener`,{event:r.event??``});case`TASK_LISTENER`:return x(`app.scriptTab.taskListener`,{event:r.event??``});case`PARAMETER`:case`INPUT_MAPPING`:case`OUTPUT_MAPPING`:return r.parameter?.direction===`output`?x(`app.scriptTab.output`,{name:r.parameter.name}):x(`app.scriptTab.input`,{name:r.parameter?.name??``});case`TASK_BODY`:return x(`app.scriptTab.script`)}}function scriptTitle(t,r){return x(`app.scriptTab.title`,{name:t,what:r})}function scriptTitleOf(t){return scriptTitle(t.shared?x(`app.scriptTab.nameWithId`,{name:t.name,id:t.slot.elementId}):t.name,scriptWhatOf(t.slot.owner,t))}var qa=new Set(`String.string.str.CharSequence.char.Char.Character.Integer.int.Int.int32.int64.Long.long.Short.short.Byte.byte.Double.double.Float.float.float32.float64.decimal.Decimal.BigDecimal.BigInteger.Number.number.Boolean.boolean.bool.Date.LocalDate.LocalDateTime.LocalTime.OffsetDateTime.ZonedDateTime.Instant.Duration.UUID.Guid.DateTime.DateTimeOffset.TimeSpan.date.datetime.Time`.split(`.`)),Ja=new Set([`List`,`ArrayList`,`LinkedList`,`Set`,`HashSet`,`LinkedHashSet`,`TreeSet`,`Collection`,`Iterable`,`Array`,`array`,`Optional`,`IList`,`IEnumerable`,`ICollection`,`IReadOnlyList`,`IReadOnlyCollection`,`Sequence`]),Ya=new Set([`null`,`undefined`,`None`,`nil`,``]);function splitTop(t,r){let a=[],o=0,s=0;for(let u=0;u<t.length;u+=1){let d=t[u];d===`<`||d===`[`||d===`(`?o+=1:d===`>`||d===`]`||d===`)`?--o:d===r&&o===0&&(a.push(t.slice(s,u)),s=u+1)}return a.push(t.slice(s)),a}function unwrap$1(t){let r=t.trim().replace(/^readonly\s+/,``).replace(/^[*&]+/,``).replace(/^["']|["']$/g,``).replace(/\?$/,``).trim(),a=r.split(`|`).map(t=>t.trim()).filter(t=>!Ya.has(t));return a.length===1?a[0]:a.length===0?``:r}r(unwrap$1,`unwrap`);function parse(t){if(t.endsWith(`[]`))return{base:`array`,args:[t.slice(0,-2)]};if(t.startsWith(`[]`))return{base:`array`,args:[t.slice(2)]};let r=/^([A-Za-z_][\w.]*)\s*[<[]([\s\S]*)[>\]]$/.exec(t);return r?{base:r[1],args:splitTop(r[2],`,`)}:{base:t,args:null}}function open$1(t){return{kind:`open`,name:t}}r(open$1,`open`);function declared(t,r,a,o){let s=r.get(t);if(!s||a>3||o.includes(t))return open$1(t);if(s.kind===`enum`)return{kind:`enum`,name:t,constants:s.constants};if(s.open)return open$1(t);let u=s.extends===null?void 0:r.get(s.extends);if(s.extends!==null&&(!u||u.kind!==`class`||u.open||u.extends!==null))return open$1(t);let d=s.fields,f=new Set(d.map(t=>t.name)),p=(u?.fields??[]).filter(t=>!f.has(t.name));return{kind:`object`,name:t,fields:[...d,...p].map(s=>({name:s.name,serialised:s.serialised,type:resolveType(s.type,r,a+1,[...o,t])}))}}function resolveType(t,r,a=1,o=[]){let s=unwrap$1(t??``);if(s===``)return open$1(``);let{base:u,args:d}=parse(s),f=u.slice(u.lastIndexOf(`.`)+1);return d!==null&&d.length===1&&Ja.has(f)?{kind:`collection`,name:f,element:resolveType(d[0],r,a,o)}:d===null&&qa.has(f)?{kind:`scalar`,name:f}:declared(f,r,a,o)}function fieldNamed(t,r){return t.find(t=>t.name===r)??t.find(t=>/^[A-Z]/.test(t.name)&&t.name.charAt(0).toLowerCase()+t.name.slice(1)===r)}var Xa=new Set([`input`,`loop element`]);function visibleAt(t,r,a,o){return o.wholeProcess?r.elementId===a?Xa.has(r.where)||o.includeOwnCode===!0&&r.path!==void 0:!Xa.has(r.where)&&j(t,r.elementId,a):r.elementId===a&&r.path!==void 0}function knownVariable(t,r,a){let o=r.map(t=>({elementId:t.elementId,where:t.where,type:t.type??null,sample:t.sample??null,path:t.path??null,line:t.line??null,offset:t.offset??null})),s=[...new Set(o.map(t=>t.type))],u=s.filter(t=>t!==null);if(u.length>1)return{name:t,certainty:`ambiguous`,type:null,shape:resolveType(null,a),writers:o};if(u.length===1&&s.length===1){let r=resolveType(u[0],a);return{name:t,certainty:r.kind===`open`?`open`:`exact`,type:u[0],shape:r,writers:o}}return{name:t,certainty:`open`,type:null,shape:resolveType(null,a),writers:o}}function variablesAt(t,r,a){let o=new Map(t.types.map(t=>[t.name,t])),s=t.inputs??[],u=t.model.variables.filter(o=>o.writes&&visibleAt(t.order,o,r,a));return{variables:[...new Set([...u.map(t=>t.name),...a.wholeProcess?s:[]])].sort().map(t=>knownVariable(t,u.filter(r=>r.name===t),o)),startVariablesUnknown:s.length===0}}function namesOf$2(t){let r=new Map,visit=t=>{t?.id&&(r.set(t.id,typeof t.name==`string`&&t.name.trim()?t.name.trim():t.id),(t.flowElements??[]).forEach(visit))};return(t?.rootElements??[]).filter(t=>t.$type===`bpmn:Process`).forEach(t=>(t.flowElements??[]).forEach(visit)),r}r(namesOf$2,`namesOf`);function writerOf(t,r,a){return t.path===null?{label:r.get(t.elementId)??t.elementId,elementId:t.elementId,...a?{diagramPath:a}:{},...t.sample===null?{}:{sample:t.sample}}:{label:`${de(t.path)}:${t.line??0}`,elementId:t.elementId,path:t.path,...t.line===null?{}:{line:t.line},...t.offset===null?{}:{offset:t.offset}}}function variableOf(t,r,a,o){return{name:t.name,...t.type===null?{}:{type:t.type},declaredByScript:k(a,t.name),writers:t.writers.map(t=>writerOf(t,r,o))}}function scriptContextOf(t,r,a){let o={variables:[...M(t.definitions).uses,...ie(t.workers)]},s=te(t.definitions).flows.get(r)?.target??r,u=variablesAt({model:o,order:A(t.definitions),types:t.workers?.types??[],inputs:t.inputs},s,{wholeProcess:!0}),d=namesOf$2(t.definitions);return u.variables.map(r=>variableOf(r,d,a,t.diagramPath))}var Za=/\b(?:byte|short|int|integer|long|float|double|number|bigdecimal|biginteger)\b/i,Qa=/\b(?:byte|short|int|integer|long|biginteger)\b/i,$a=/\b(?:bool|boolean)\b/i,eo=/^(?:list|set|collection|sequence|iterable|sortedset|array)$/i,to=/^(?:map|object|jsonnode|jsonobject|record|dictionary)$/i;function valueFor(t){if(!t)return`?`;let r=t.replace(/<.*$/,``).trim();return eo.test(r)||/\[\]$/.test(r)?[]:to.test(r)?{}:$a.test(r)?!1:Qa.test(r)||Za.test(r)?0:`?`}function exampleJson(t){return JSON.stringify(Object.fromEntries(t.map(t=>[t.name,valueFor(t.type)])),null,2)}function exampleInput(t,r,a,o){let s=new Map;(r?.variables??[]).filter(t=>t.elementId===a&&t.type).forEach(t=>s.set(t.name,t.type??null));let{uses:u}=M(t),d=new Set(u.filter(t=>t.writes&&t.elementId===a).map(t=>t.name)),f=new Set;return u.filter(t=>t.writes&&!d.has(t.name)).forEach(t=>{j(o,t.elementId,a)&&f.add(t.name)}),(r?.variables??[]).filter(t=>t.elementId===a&&!t.writes).forEach(t=>f.add(t.name)),[...f].sort().map(t=>({name:t,type:s.get(t)??null}))}var no=`camundaModeler:exampleOutputJson`,ro=[`serviceTask`,`sendTask`,`receiveTask`,`businessRuleTask`,`userTask`,`callActivity`],io={JOB_TYPE:`JOB_TYPE`,TOPIC:`TOPIC`,JAVA_CLASS:`CLASS`,BEAN:`BEAN`};function elementSubjects(t){let r=new Map,add=(t,a)=>{let o=r.get(t);o?o.push(a):r.set(t,[a])},a=new Map(t.messages.map(t=>[t.id,t.name]));return t.workers.forEach(t=>add(t.elementId,{kind:io[t.kind],value:t.value,...t.listener?{listener:t.listener}:{}})),t.calls.forEach(t=>add(t.elementId,{kind:`PROCESS`,value:t.calledProcessId})),t.decisionUses.forEach(t=>add(t.elementId,{kind:`DECISION`,value:t.decisionId})),t.messageUses.filter(t=>t.catches).forEach(t=>{let r=a.get(t.messageId);r&&add(t.elementId,{kind:`MESSAGE`,value:r})}),t.elements.filter(t=>ro.includes(t.type)||r.has(t.id)).map(t=>({elementId:t.id,elementType:t.type,label:t.label,bindings:r.get(t.id)??[]}))}function withRuntimeFacts(t,r){let{reached:a=null,paused:o}=r;return!a&&(!o||o.size===0)?t:t.map(t=>({...t,reached:a&&t.state!==`notApplicable`?a.has(t.elementId):t.reached,paused:o?.has(t.elementId)??t.paused}))}function isBadged(t){return t.state!==`notApplicable`&&ro.includes(t.elementType)}var ao=/^Focus process instance (.+)$/;function localised(t){if(typeof t!=`string`)return String(t??``);let r=ao.exec(t);return r?ct(`Focus process instance {id}`,{id:r[1]}):ct(t)}var oo=`svg, [contenteditable]`;function localiseText(t){try{if(!t||typeof t.data!=`string`||t.parentElement?.closest(oo))return;let r=t.data,a=r.trim();if(!a)return;let o=localised(a);o!==a&&(t.data=r.replace(a,o))}catch{}}var so=[`title`,`aria-label`];function localiseLabels(t){try{if(!t||typeof t.getAttribute!=`function`||typeof t.setAttribute!=`function`||t.closest?.(oo))return;for(let r of so){let a=t.getAttribute(r);if(!a)continue;let o=localised(a);o!==a&&t.setAttribute(r,o)}}catch{}}function localiseTree(t){try{if(!t||typeof t.nodeType!=`number`)return;if(t.nodeType===Node.TEXT_NODE){localiseText(t);return}if(t.nodeType!==Node.ELEMENT_NODE)return;let r=t;if(localiseLabels(r),r.querySelectorAll?.(`[title], [aria-label]`).forEach(localiseLabels),typeof document<`u`&&typeof document.createTreeWalker==`function`){let t=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(;t.nextNode();)localiseText(t.currentNode)}}catch{}}var TokenSimulationTranslator=class{static $inject=[`canvas`];constructor(t){try{if(!t||typeof t.getContainer!=`function`)return;let r=t.getContainer();if(!r||typeof r.nodeType!=`number`||(localiseTree(r),typeof MutationObserver!=`function`))return;new MutationObserver(t=>{try{for(let r of t)r.type===`attributes`?localiseLabels(r.target):r.type===`characterData`?localiseText(r.target):r.addedNodes.forEach(localiseTree)}catch{}}).observe(r,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:so})}catch{}}},co={__init__:[`tokenSimulationTranslator`],tokenSimulationTranslator:[`type`,TokenSimulationTranslator]};function BaseModeler(t){Ei.call(this,t),this.on(`import.parse.complete`,function(t){t.error||this._collectIds(t.definitions,t.elementsById)},this),this.on(`diagram.destroy`,function(){this.get(`moddle`).ids.clear()},this)}K(BaseModeler,Ei),BaseModeler.prototype._createModdle=function(t){var r=Ei.prototype._createModdle.call(this,t);return r.ids=new Ke([32,36,1]),r},BaseModeler.prototype._collectIds=function(t,r){var a=t.$model.ids,o;for(o in a.clear(),r)a.claim(o,r[o])};var lo=300;function KeepSelectionVisible(t,r,a){this._selectionWasVisible=!1;let o=Fe(()=>{this._selectionWasVisible=isSelectionVisible()},lo);t.on(`canvas.viewbox.changed`,o),t.on(`selection.changed`,o),t.on(`diagram.destroy`,()=>{o.cancel()}),t.on(`canvas.resized`,()=>{var t=a.get();if(t.length&&this._selectionWasVisible&&!isSelectionVisible()){var o=r.getRootElement();r.scrollToElement(t.concat(o))}});function isSelectionVisible(){var t=a.get();if(!t.length)return!1;var o=Xr(t),s=r.viewbox(),u=Xi(o),d=Xi(s);return u.left>=d.left&&u.right<=d.right&&u.top>=d.top&&u.bottom<=d.bottom}this._flush=o.flush}KeepSelectionVisible.$inject=[`eventBus`,`canvas`,`selection`];var uo={__init__:[`keepSelectionVisible`],__depends__:[ta],keepSelectionVisible:[`type`,KeepSelectionVisible]};function NavigatedViewer(t){ra.call(this,t)}K(NavigatedViewer,ra),NavigatedViewer.prototype._navigationModules=[uo,$n,Xt,wt],NavigatedViewer.prototype._modules=[].concat(ra.prototype._modules,NavigatedViewer.prototype._navigationModules);var fo={align:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2000 2000">
|
|
2
2
|
<line x1="200" y1="150" x2="200" y2="1850" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>
|
|
3
3
|
<rect x="500" y="150" width="1300" height="700" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
|
|
4
4
|
<rect x="500" y="1150" width="700" height="700" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
|