|
|
|
@@ -1,10 +1,10 @@
|
|
|
|
|
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),I(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,ee(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||m,p.__i=d,v=I(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&z(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),4&p.__u?(c=j(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),ne(s,s));return r}function j(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=j(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=w(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function F(e){return function(n){if(this.l){var r=thiLine truncated
|
|
|
|
|
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Ae=class extends Error{constructor(e,t){super(e),this.status=t}};function je(e){let t=e instanceof Ae?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Me(e,t){let n=await fetch(e,t);if(!n.ok)throw new Ae(await ke(n),n.status);return n}async function K(e,{method:t=`GET`,body:n,timeoutMs:r=De,parse:i=!0}={}){let a={Accept:`application/json`},o={method:t,headers:a,signal:AbortSignal.timeout(r)};t!==`GET`&&(a[`Content-Type`]=`application/json`,a[`X-Archie-CSRF`]=`1`),n!==void 0&&(o.body=JSON.stringify(n));let s=await Me(e,o);return i?s.json():void 0}var q={summary:()=>K(`/api/summary`),tasks:()=>K(`/api/tasks`),taskMeta:()=>K(`/api/task-meta`),task:e=>K(`/api/tasks/${e}`),taskAttempts:e=>K(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>K(`/api/tasks/${e}/changes`+Oe(t)),taskDebug:(e,t)=>K(`/api/tasks/${e}/debug`+Oe(t)),taskAction:(e,t)=>K(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>K(`/api/setup`),capabilities:()=>K(`/api/capabilities`),workflows:()=>K(`/api/workflows`),workRequest:e=>K(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>K(`/api/skills`),channels:()=>K(`/api/channels`),curators:()=>K(`/api/curators`),channelReload:e=>K(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>K(`/api/config`),version:()=>K(`/api/version`),configUpdate:e=>K(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>K(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>K(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>K(`/api/logs`+Oe(e)),taskLogs:(e,t)=>K(`/api/tasks/${e}/logs`+Oe(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>K(`/api/captures`+Oe({limit:e})),mappings:()=>K(`/api/mappings`),mappingCreate:e=>K(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>K(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>K(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>K(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>K(`/api/bindings`),bindingCreate:e=>K(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>K(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>K(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>K(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>K(`/api/chat/sessions`),chatMessages:e=>K(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>K(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>K(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>K(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Ee(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>K(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>K(`/api/chat/update`),chatUpdateDefer:e=>K(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>K(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>K(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>K(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>K(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>Me(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t})};function Ne(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Pe(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Fe(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Ie=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],Le=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? ThiLine truncated
|
|
|
|
|
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>tt?`${n.slice(0,tt).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}function Q({text:e,kind:t=`idle`}){return J(`span`,{className:`pill pill-${t}`,children:e})}var rt=`archie.setup-complete.dismissed.v1`;function it(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(rt),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function at(e=globalThis.localStorage){e?.setItem?.(rt,`1`)}var ot=new Set([`waiting_human`,`parked`]);function st(e=[]){let t=e.filter(e=>ot.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function ct({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function lt(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function ut(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function dt(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function ft(){let[e,t]=U([]),[n,r]=U(`connecting`),[i,a]=U(`idle`),[o,s]=U(new Map),[c,l]=U(null),[u,d]=U(null),[f,p]=U(null),[m,h]=U(null),[g,_]=U(null),[,v]=U(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([q.summary(),q.setup().catch(()=>null),q.workflows().catch(()=>null),q.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};W(()=>(y(),Ne(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{at(),v(e=>!e)},x=u?.operator?`${ut()}, ${u.operator}`:ut(),C=null;if(g)C=J(`button`,{className:`btn btn-primary`,onClick:y,children:[J(Y,{name:`refresh`,size:15}),` Retry`]});else if(m!==null){let e=st(m),t=e.attention.count,n=e.running.count;C=J(S,{children:[t>0&&J(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[J(Y,{name:`tasks`,size:15}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&J(`a`,{className:`btn`,href:e.running.href,children:[J(Y,{name:`workflows`,size:15}),` `,n,` running`]}),J(`a`,{className:`btn`,href:`#/logs`,children:[J(Y,{name:`logs`,size:15}),` Logs`]}),J(`button`,{className:`btn btn-primary`,onClick:y,children:[J(Y,{name:`refresh`,size:15}),` Refresh`]})]})}let w=null;if(g)w=J(`div`,{className:`card`,children:J(ct,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=J(S,{children:[J(Z,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),J(Z,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),J(Z,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),J(Z,{label:`Tokens used`,value:Ze(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:dt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=it(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=J(`div`,{className:`card setup`,children:[J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Finish setting up`}),J(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),J(`span`,{className:`setup-pct`,children:[t,`%`]})]}),J(`div`,{className:`setup-bar`,children:J(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),J(`ul`,{className:`setup-list`,children:u.steps.map((e,t)=>J(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[J(`span`,{className:`setup-check`,children:e.done?J(Y,{name:`check`,size:12}):``}),J(`div`,{children:[J(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&J(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else T=J(`div`,{className:`card setup setup-done`,children:J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Setup complete`}),J(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),J(`div`,{className:`setup-complete-actions`,children:[J(`span`,{className:`setup-pct`,children:J(Y,{name:`check`,size:16})}),J(`button`,{className:`icon-btn setup-dismiss`,type:`Line truncated
|
|
|
|
|
`),children:[J(`td`,{className:`strong`,children:e.label||e.id}),J(`td`,{className:`mono`,children:e.install_type||`—`}),J(`td`,{className:`mono`,children:e.running_version||`—`}),J(`td`,{className:`mono`,children:e.latest_available||`—`}),J(`td`,{children:J(Q,{text:Zn[e.status]||e.status,kind:Qn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function er({title:e,sub:t,children:n}){return J(`div`,{className:`card cfg-section`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:e}),J(`p`,{className:`card-sub`,children:t})]})}),n]})}function tr(e){return e?.error?e.error:e?.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`}function nr({data:e,onDefer:t,onInstall:n}){let r=e?.available||[];return r.length?J(er,{title:`Updates`,sub:`Whether a newer release is available, and what to do about it.`,children:[J(`p`,{className:`cfg-note`,children:r.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)}),J(`div`,{className:`cfg-actions`,children:[J(`button`,{className:`btn`,type:`button`,onClick:()=>t?.(e.snapshot),children:`Defer`}),e.can_install&&J(`button`,{className:`btn btn-primary`,type:`button`,onClick:()=>n?.(e.snapshot),children:`Install update`})]})]}):J(er,{title:`Updates`,sub:`Whether a newer release is available, and what to do about it.`,children:J(`p`,{className:`cfg-note`,children:tr(e)})})}var rr=e=>e.Number??e.number,ir=e=>e.Label??e.label??`checkpoint`;function ar({data:e,onRequest:t,onDecide:n}){let[r,i]=U(``),[a,o]=U(``);if(e?.error)return J(er,{title:`Dangerous actions`,sub:`Actions that need explicit approval before they run.`,children:J(`p`,{className:`cfg-note`,children:e.error})});let s=e?.pending||[];return J(er,{title:`Dangerous actions`,sub:`Actions that need explicit approval before they run. Requesting one only queues it.`,children:[J(`div`,{className:`cfg-request-row`,children:[J(`select`,{"aria-label":`Checkpoint`,value:r,onChange:e=>i(e.target.value),children:[J(`option`,{value:``,children:`Select checkpoint`}),(e?.checkpoints||[]).map(e=>J(`option`,{value:String(rr(e)),children:[rr(e),` — `,ir(e)]},rr(e)))]}),J(`button`,{className:`btn`,type:`button`,disabled:!r,onClick:()=>t?.(`rollback`,r),children:`Request rollback`})]}),J(`div`,{className:`cfg-request-row`,children:[J(`input`,{placeholder:`Process name or id`,"aria-label":`Process name or id`,value:a,onInput:e=>o(e.target.value)}),J(`button`,{className:`btn`,type:`button`,disabled:!a.trim(),onClick:()=>t?.(`stop`,a),children:`Request stop`})]}),s.length?J(S,{children:s.map(e=>J(`div`,{className:`cfg-pending`,children:[J(`span`,{children:e.description}),J(`div`,{className:`cfg-actions`,children:[J(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`approve`),children:`Approve`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`permanent`),children:`Approve for 24h`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`deny`),children:`Deny`})]})]},e.id))}):J(`p`,{className:`cfg-note`,children:`No pending dangerous actions.`})]})}function $({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function or({title:e,sub:t,children:n}){return J(`div`,{className:`card cfg-section`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:e}),J(`p`,{className:`card-sub`,children:t})]})}),n]})}function sr({origins:e}){return e?.length?J(or,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:J(`div`,{className:`kv-list`,children:e.map((e,t)=>J(qn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):J(or,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:J($,{title:`Source provenance is unavailable.`})})}function cr(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function lr({data:e,error:t}){if(t)return J(or,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:J($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return J(or,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[J(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?J(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??We(e.id),n=e.kind??Ge(e.id);return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,children:e.id}),J(`span`,{className:`kv-value`,children:J(Q,{text:t,kind:n})})]},e.id)})}):J($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),J(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?J(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=cr(e.kind);return J(`Line truncated
|
|
|
|
|
`),i=[],a=null,o=null,s=0,c=()=>{i.length&&(n.push(J(`p`,{children:Jr(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>J(`li`,{children:Jr(e)},t));n.push(a.tag===`ol`?J(`ol`,{children:e},s++):J(`ul`,{children:e},s++)),a=null};for(let e=0;e<r.length;e++){let t=r[e];if(t.startsWith("```")){c(),l(),o?(n.push(J(`pre`,{children:J(`code`,{children:o.join(`
|
|
|
|
|
`)})},s++)),o=null):o=[];continue}if(o){o.push(t);continue}let u=Xr(t),d=e+1<r.length?Xr(r[e+1]):null;if(u&&d&&Zr(d)&&u.length===d.length){c(),l();let t=[];for(e+=2;e<r.length;e++){let n=Xr(r[e]);if(!n||n.length!==u.length){e--;break}t.push(n)}n.push(J(`table`,{children:[J(`thead`,{children:J(`tr`,{children:u.map((e,t)=>J(`th`,{children:Jr(e)},t))})}),J(`tbody`,{children:t.map((e,t)=>J(`tr`,{children:e.map((e,t)=>J(`td`,{children:Jr(e)},t))},t))})]},s++));continue}if(!t.trim()){c(),l();continue}let f=t.match(/^(#{1,3})\s+(.+)$/);if(f){c(),l();let e=`h${f[1].length}`;n.push(J(e,{children:Jr(f[2])},s++));continue}let p=t.match(/^\s*[-*]\s+(.+)$/),m=t.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){c();let e=m?`ol`:`ul`;(!a||a.tag!==e)&&(l(),a={tag:e,items:[]}),a.items.push((p||m)[1]);continue}if(t.startsWith(`>`)){c(),l(),n.push(J(`blockquote`,{children:Jr(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(J(`pre`,{children:J(`code`,{children:o.join(`
|
|
|
|
|
`)})},s++)),J(`div`,{className:t,children:n})}function Xr(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function Zr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Qr=`archie.web.chat.channel`;function $r(){let e=localStorage.getItem(Qr);return e||(e=Ee(),localStorage.setItem(Qr,e)),e}function ei(e){return{text:e,sourceID:Ee()}}function ti(e){return{...e}}function ni(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?ti(e.turn):ei(r),isRetry:n}}function ri({scrollTop:e,viewportHeight:t,optionTop:n,optionHeight:r}){if(r>=t||n<e)return n;let i=n+r;return i>e+t?i-t:e}function ii(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function ai(e,t){if(!t)return`Archie`;let n=(e||[]).find(e=>e.session_id===t);return n?ii(n):`Archie`}function oi(){return location.hash.slice(1)||`/`}function si({open:e=!0}){let[t,n]=U([]),[r,i]=U(``),[a,o]=U([]),[s,c]=U(``),[l,u]=U(`Ready`),[d,f]=U(!1),[p,m]=U({}),[h,g]=U(``),[_,v]=U(``),[y,b]=U(``),[x,C]=U([]),[w,T]=U([]),[E,D]=U(0),[O,k]=U(!1),[A,j]=U(null),M=G(null),N=G(null),P=G(null),F=G(null),I=G(null),L=G(null),ee=G(d);ee.current=d,W(()=>{let e=e=>{let t=L.current;t?.open&&(e.target instanceof Node&&t.contains(e.target)||(t.open=!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`focusin`,e),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`focusin`,e)}},[]),W(()=>{e&&N.current?.focus()},[e]),W(()=>{if(!O)return;let e=I.current,t=e?.children?.[E];!e||!t||(e.scrollTop=ri({scrollTop:e.scrollTop,viewportHeight:e.clientHeight,optionTop:t.offsetTop,optionHeight:t.offsetHeight}))},[E,O]),W(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[a,A]),W(()=>{R().catch(e=>{u(e.message||`Chat unavailable`)});let e=()=>{P.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),P.current?.abort()}},[]);async function R(){let e=await q.chatSessions(),t=e.sessions||[];n(t),m(e),g(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;v(a),b(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);C(o),!r&&t[0]&&await te(t[0].session_id,e,t)}async function te(e,t,n){let r=t||p;i(e),o([]),j(null);let a=r.active_personas?.[e]||r.active_persona||``;g(a);try{await q.chatMessage($r(),`/resume ${e}`);let[t,n]=await Promise.all([q.chatMessages(e),q.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});o(i)}catch(e){u(e.message||`Could not load session messages`)}}async function z(e){if(r)try{u(`Working…`);let t=await q.chatMessage($r(),e);t.session_id&&i(t.session_id),u(t.reply||`Session updated`),await R(),(t.session_id||r)&&await te(t.session_id||r),F.current&&(F.current.open=!1)}catch(e){u(e.message||`Session action failed`)}}function ne(e,t){let n=window.prompt(t);n?.trim()&&z(`${e} ${n.trim()}`)}function re(e){let t=e.target.value;g(t),!(!r||!t)&&q.chatPersona(r,t).then(()=>{m(e=>({...e,active_personas:{...e.active_personas||{},[r]:t}})),u(`Personality: ${t}`)}).catch(e=>{u(e.message||`Failed to set personality`)})}async function ie(e){let t=e.target.value;if(v(t),t)try{let e=await q.chatMessage($r(),`/model --provider ${t}`);u(e.reply||`Provider updated`),await R()}catch(e){u(`Provider update failed: ${e.message||e}`)}}async function B(e){let t=e.target.value;if(b(t),t)try{let e=await q.chatMessage($r(),`/model ${t}`);u(e.reply||`Model updated`),await R()}catch(e){u(`Model update failed: ${e.message||e}`)}}function V(){c(`/new`),ce({textOverride:`/new`})}function ae(e){let t=e.target.value;c(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=x.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){T(t),D(0),k(!0);return}}k(!1),T([])}function oe(e){let t=w[e];if(!t||!N.current)return;let n=N.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\s)\/[^\s]*$/),o=a<0?r.length:a+ +(r[a]===` `),s=`${r.slice(0,o)}${t.command} ${i}`;c(s),k(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function se(e){if(O&&w.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&w.some(e=>e.command===s.trim())){e.preventDefault(),k(!1),ce();return}if(e.key===`ArrowDown`){e.preventDefault(),D(e=>(e+1)%w.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D(e=>(e+w.length-1)%w.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),oe(E);return}if(e.key===`Escape`){e.preventDefault(),k(!1);re
Line truncated
|
|
|
|
|
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),I(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,ee(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||m,p.__i=d,v=I(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ne(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),4&p.__u?(c=j(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),re(s,s));return r}function j(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=j(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=w(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function F(e){return function(n){if(this.l){var r=thLine truncated
|
|
|
|
|
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Me=class extends Error{constructor(e,t){super(e),this.status=t}};function Ne(e){let t=e instanceof Me?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Pe(e,t){let n=await fetch(e,t);if(!n.ok)throw new Me(await je(n),n.status);return n}async function G(e,{method:t=`GET`,body:n,timeoutMs:r=ke,parse:i=!0}={}){let a={Accept:`application/json`},o={method:t,headers:a,signal:AbortSignal.timeout(r)};t!==`GET`&&(a[`Content-Type`]=`application/json`,a[`X-Archie-CSRF`]=`1`),n!==void 0&&(o.body=JSON.stringify(n));let s=await Pe(e,o);return i?s.json():void 0}var K={summary:()=>G(`/api/summary`),tasks:()=>G(`/api/tasks`),taskMeta:()=>G(`/api/task-meta`),task:e=>G(`/api/tasks/${e}`),taskAttempts:e=>G(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>G(`/api/tasks/${e}/changes`+Ae(t)),taskDebug:(e,t)=>G(`/api/tasks/${e}/debug`+Ae(t)),taskAction:(e,t)=>G(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>G(`/api/setup`),capabilities:()=>G(`/api/capabilities`),workflows:()=>G(`/api/workflows`),workRequest:e=>G(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>G(`/api/skills`),channels:()=>G(`/api/channels`),curators:()=>G(`/api/curators`),channelReload:e=>G(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>G(`/api/config`),version:()=>G(`/api/version`),configUpdate:e=>G(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>G(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>G(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>G(`/api/logs`+Ae(e)),taskLogs:(e,t)=>G(`/api/tasks/${e}/logs`+Ae(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>G(`/api/captures`+Ae({limit:e})),mappings:()=>G(`/api/mappings`),mappingCreate:e=>G(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>G(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>G(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>G(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>G(`/api/bindings`),bindingCreate:e=>G(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>G(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>G(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>G(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>G(`/api/chat/sessions`),chatMessages:e=>G(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>G(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>G(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>G(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:De(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>G(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>G(`/api/chat/update`),chatUpdateDefer:e=>G(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>G(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>G(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>G(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>G(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>Pe(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t})};function Fe(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Ie(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(Oe(n.readyState)),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Le(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Re=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],ze=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? TLine truncated
|
|
|
|
|
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>rt?`${n.slice(0,rt).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}function Z({text:e,kind:t=`idle`}){return q(`span`,{className:`pill pill-${t}`,children:e})}var at=`archie.setup-complete.dismissed.v1`;function ot(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(at),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function st(e=globalThis.localStorage){e?.setItem?.(at,`1`)}var ct=new Set([`waiting_human`,`parked`]);function lt(e=[]){let t=e.filter(e=>ct.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function ut({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function dt(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function ft(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function pt(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function mt(){let[e,t]=H([]),[n,r]=H(`connecting`),[i,a]=H(`idle`),[o,s]=H(new Map),[c,l]=H(null),[u,d]=H(null),[f,p]=H(null),[m,h]=H(null),[g,_]=H(null),[,v]=H(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([K.summary(),K.setup().catch(()=>null),K.workflows().catch(()=>null),K.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};U(()=>(y(),Fe(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{st(),v(e=>!e)},x=u?.operator?`${ft()}, ${u.operator}`:ft(),C=null;if(g)C=q(`button`,{className:`btn btn-primary`,onClick:y,children:[q(J,{name:`refresh`,size:15}),` Retry`]});else if(m!==null){let e=lt(m),t=e.attention.count,n=e.running.count;C=q(S,{children:[t>0&&q(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[q(J,{name:`tasks`,size:15}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&q(`a`,{className:`btn`,href:e.running.href,children:[q(J,{name:`workflows`,size:15}),` `,n,` running`]}),q(`a`,{className:`btn`,href:`#/logs`,children:[q(J,{name:`logs`,size:15}),` Logs`]}),q(`button`,{className:`btn btn-primary`,onClick:y,children:[q(J,{name:`refresh`,size:15}),` Refresh`]})]})}let w=null;if(g)w=q(`div`,{className:`card`,children:q(ut,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=q(S,{children:[q(X,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),q(X,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),q(X,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),q(X,{label:`Tokens used`,value:$e(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:pt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=ot(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=q(`div`,{className:`card setup`,children:[q(`div`,{className:`card-head`,children:[q(`div`,{children:[q(`h2`,{className:`card-title`,children:`Finish setting up`}),q(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),q(`span`,{className:`setup-pct`,children:[t,`%`]})]}),q(`div`,{className:`setup-bar`,children:q(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),q(`ul`,{className:`setup-list`,children:u.steps.map((e,t)=>q(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[q(`span`,{className:`setup-check`,children:e.done?q(J,{name:`check`,size:12}):``}),q(`div`,{children:[q(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&q(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else T=q(`div`,{className:`card setup setup-done`,children:q(`div`,{className:`card-head`,children:[q(`div`,{children:[q(`h2`,{className:`card-title`,children:`Setup complete`}),q(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),q(`div`,{className:`setup-complete-actions`,children:[q(`span`,{className:`setup-pct`,children:q(J,{name:`check`,size:16})}),q(`button`,{className:`icon-btn setup-dismiss`,type:`Line truncated
|
|
|
|
|
`),children:[q(`td`,{className:`strong`,children:e.label||e.id}),q(`td`,{className:`mono`,children:e.install_type||`—`}),q(`td`,{className:`mono`,children:e.running_version||`—`}),q(`td`,{className:`mono`,children:e.latest_available||`—`}),q(`td`,{children:q(Z,{text:er[e.status]||e.status,kind:tr[e.status]||`idle`})})]},e.id||e.label))})]})})})}function rr({title:e,sub:t,children:n}){return q(`div`,{className:`card cfg-section`,children:[q(`div`,{className:`card-head`,children:q(`div`,{children:[q(`h2`,{className:`card-title`,children:e}),q(`p`,{className:`card-sub`,children:t})]})}),n]})}function ir(e){return e?.error?e.error:e?.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`}function ar({data:e,onDefer:t,onInstall:n}){let r=e?.available||[];return r.length?q(rr,{title:`Updates`,sub:`Whether a newer release is available, and what to do about it.`,children:[q(`p`,{className:`cfg-note`,children:r.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)}),q(`div`,{className:`cfg-actions`,children:[q(`button`,{className:`btn`,type:`button`,onClick:()=>t?.(e.snapshot),children:`Defer`}),e.can_install&&q(`button`,{className:`btn btn-primary`,type:`button`,onClick:()=>n?.(e.snapshot),children:`Install update`})]})]}):q(rr,{title:`Updates`,sub:`Whether a newer release is available, and what to do about it.`,children:q(`p`,{className:`cfg-note`,children:ir(e)})})}var or=e=>e.Number??e.number,sr=e=>e.Label??e.label??`checkpoint`;function cr({data:e,onRequest:t,onDecide:n}){let[r,i]=H(``),[a,o]=H(``);if(e?.error)return q(rr,{title:`Dangerous actions`,sub:`Actions that need explicit approval before they run.`,children:q(`p`,{className:`cfg-note`,children:e.error})});let s=e?.pending||[];return q(rr,{title:`Dangerous actions`,sub:`Actions that need explicit approval before they run. Requesting one only queues it.`,children:[q(`div`,{className:`cfg-request-row`,children:[q(`select`,{"aria-label":`Checkpoint`,value:r,onChange:e=>i(e.target.value),children:[q(`option`,{value:``,children:`Select checkpoint`}),(e?.checkpoints||[]).map(e=>q(`option`,{value:String(or(e)),children:[or(e),` — `,sr(e)]},or(e)))]}),q(`button`,{className:`btn`,type:`button`,disabled:!r,onClick:()=>t?.(`rollback`,r),children:`Request rollback`})]}),q(`div`,{className:`cfg-request-row`,children:[q(`input`,{placeholder:`Process name or id`,"aria-label":`Process name or id`,value:a,onInput:e=>o(e.target.value)}),q(`button`,{className:`btn`,type:`button`,disabled:!a.trim(),onClick:()=>t?.(`stop`,a),children:`Request stop`})]}),s.length?q(S,{children:s.map(e=>q(`div`,{className:`cfg-pending`,children:[q(`span`,{children:e.description}),q(`div`,{className:`cfg-actions`,children:[q(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`approve`),children:`Approve`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`permanent`),children:`Approve for 24h`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>n?.(e.id,`deny`),children:`Deny`})]})]},e.id))}):q(`p`,{className:`cfg-note`,children:`No pending dangerous actions.`})]})}function Q({title:e,detail:t}){return q(`div`,{className:`empty`,children:[q(`div`,{className:`empty-title`,children:e}),t&&q(`div`,{children:t})]})}function $({title:e,sub:t,children:n}){return q(`div`,{className:`card cfg-section`,children:[q(`div`,{className:`card-head`,children:q(`div`,{children:[q(`h2`,{className:`card-title`,children:e}),q(`p`,{className:`card-sub`,children:t})]})}),n]})}function lr({origins:e}){return e?.length?q($,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:q(`div`,{className:`kv-list`,children:e.map((e,t)=>q(Xn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):q($,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:q(Q,{title:`Source provenance is unavailable.`})})}function ur(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function dr({data:e,error:t}){if(t)return q($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:q(Q,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return q($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[q(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?q(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??Ke(e.id),n=e.kind??qe(e.id);return q(`div`,{className:`kv`,children:[q(`span`,{className:`kv-label`,children:e.id}),q(`span`,{className:`kv-value`,children:q(Z,{text:t,kind:n})})]},e.id)})}):q(Q,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),q(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?q(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=ur(e.kind);return q(`div`,
Line truncated
|
|
|
|
|
`),i=[],a=null,o=null,s=0,c=()=>{i.length&&(n.push(q(`p`,{children:Qr(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>q(`li`,{children:Qr(e)},t));n.push(a.tag===`ol`?q(`ol`,{children:e},s++):q(`ul`,{children:e},s++)),a=null};for(let e=0;e<r.length;e++){let t=r[e];if(t.startsWith("```")){c(),l(),o?(n.push(q(`pre`,{children:q(`code`,{children:o.join(`
|
|
|
|
|
`)})},s++)),o=null):o=[];continue}if(o){o.push(t);continue}let u=ei(t),d=e+1<r.length?ei(r[e+1]):null;if(u&&d&&ti(d)&&u.length===d.length){c(),l();let t=[];for(e+=2;e<r.length;e++){let n=ei(r[e]);if(!n||n.length!==u.length){e--;break}t.push(n)}n.push(q(`table`,{children:[q(`thead`,{children:q(`tr`,{children:u.map((e,t)=>q(`th`,{children:Qr(e)},t))})}),q(`tbody`,{children:t.map((e,t)=>q(`tr`,{children:e.map((e,t)=>q(`td`,{children:Qr(e)},t))},t))})]},s++));continue}if(!t.trim()){c(),l();continue}let f=t.match(/^(#{1,3})\s+(.+)$/);if(f){c(),l();let e=`h${f[1].length}`;n.push(q(e,{children:Qr(f[2])},s++));continue}let p=t.match(/^\s*[-*]\s+(.+)$/),m=t.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){c();let e=m?`ol`:`ul`;(!a||a.tag!==e)&&(l(),a={tag:e,items:[]}),a.items.push((p||m)[1]);continue}if(t.startsWith(`>`)){c(),l(),n.push(q(`blockquote`,{children:Qr(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(q(`pre`,{children:q(`code`,{children:o.join(`
|
|
|
|
|
`)})},s++)),q(`div`,{className:t,children:n})}function ei(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function ti(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var ni=`archie.web.chat.channel`;function ri(){let e=localStorage.getItem(ni);return e||(e=De(),localStorage.setItem(ni,e)),e}function ii(e){return{text:e,sourceID:De()}}function ai(e){return{...e}}function oi(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?ai(e.turn):ii(r),isRetry:n}}function si({scrollTop:e,viewportHeight:t,optionTop:n,optionHeight:r}){if(r>=t||n<e)return n;let i=n+r;return i>e+t?i-t:e}function ci(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function li(e,t){if(!t)return`Archie`;let n=(e||[]).find(e=>e.session_id===t);return n?ci(n):`Archie`}function ui(){return location.hash.slice(1)||`/`}function di({open:e=!0}){let[t,n]=H([]),[r,i]=H(``),[a,o]=H([]),[s,c]=H(``),[l,u]=H(`Ready`),[d,f]=H(!1),[p,m]=H({}),[h,g]=H(``),[_,v]=H(``),[y,b]=H(``),[x,C]=H([]),[w,T]=H([]),[E,D]=H(0),[O,k]=H(!1),[A,j]=H(null),M=W(null),N=W(null),P=W(null),F=W(null),I=W(null),L=W(null),ee=W(d);ee.current=d,U(()=>{let e=e=>{let t=L.current;t?.open&&(e.target instanceof Node&&t.contains(e.target)||(t.open=!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`focusin`,e),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`focusin`,e)}},[]),U(()=>{e&&N.current?.focus()},[e]),U(()=>{if(!O)return;let e=I.current,t=e?.children?.[E];!e||!t||(e.scrollTop=si({scrollTop:e.scrollTop,viewportHeight:e.clientHeight,optionTop:t.offsetTop,optionHeight:t.offsetHeight}))},[E,O]),U(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[a,A]),U(()=>{R().catch(e=>{u(e.message||`Chat unavailable`)});let e=()=>{P.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),P.current?.abort()}},[]);async function R(){let e=await K.chatSessions(),t=e.sessions||[];n(t),m(e),g(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;v(a),b(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);C(o),!r&&t[0]&&await te(t[0].session_id,e,t)}async function te(e,t,n){let r=t||p;i(e),o([]),j(null);let a=r.active_personas?.[e]||r.active_persona||``;g(a);try{await K.chatMessage(ri(),`/resume ${e}`);let[t,n]=await Promise.all([K.chatMessages(e),K.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});o(i)}catch(e){u(e.message||`Could not load session messages`)}}async function ne(e){if(r)try{u(`Working…`);let t=await K.chatMessage(ri(),e);t.session_id&&i(t.session_id),u(t.reply||`Session updated`),await R(),(t.session_id||r)&&await te(t.session_id||r),F.current&&(F.current.open=!1)}catch(e){u(e.message||`Session action failed`)}}function re(e,t){let n=window.prompt(t);n?.trim()&&ne(`${e} ${n.trim()}`)}function ie(e){let t=e.target.value;g(t),!(!r||!t)&&K.chatPersona(r,t).then(()=>{m(e=>({...e,active_personas:{...e.active_personas||{},[r]:t}})),u(`Personality: ${t}`)}).catch(e=>{u(e.message||`Failed to set personality`)})}async function ae(e){let t=e.target.value;if(v(t),t)try{let e=await K.chatMessage(ri(),`/model --provider ${t}`);u(e.reply||`Provider updated`),await R()}catch(e){u(`Provider update failed: ${e.message||e}`)}}async function z(e){let t=e.target.value;if(b(t),t)try{let e=await K.chatMessage(ri(),`/model ${t}`);u(e.reply||`Model updated`),await R()}catch(e){u(`Model update failed: ${e.message||e}`)}}function B(){c(`/new`),le({textOverride:`/new`})}function oe(e){let t=e.target.value;c(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=x.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){T(t),D(0),k(!0);return}}k(!1),T([])}function se(e){let t=w[e];if(!t||!N.current)return;let n=N.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\s)\/[^\s]*$/),o=a<0?r.length:a+ +(r[a]===` `),s=`${r.slice(0,o)}${t.command} ${i}`;c(s),k(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function ce(e){if(O&&w.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&w.some(e=>e.command===s.trim())){e.preventDefault(),k(!1),le();return}if(e.key===`ArrowDown`){e.preventDefault(),D(e=>(e+1)%w.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D(e=>(e+w.length-1)%w.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),se(E);return}if(e.key===`Escape`){e.preventDefault(),k(!1);
Line truncated
|
|
|
|
|
|
|
|
|
|
`);a=o.pop()||``;for(let e of o){let t=e.split(`
|
|
|
|
|
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&i(n.session_id),n.type===`delta`&&(d+=n.text,j(e=>e?{...e,text:d}:null)),n.type===`tool`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`navigate`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`done`&&(p=!0,d||=n.text),n.type===`error`)throw Error(n.text)}if(r)break}if(!p)throw Error(`chat stream ended before completion`);o(e=>[...e,{from:`assistant`,text:d,tool_calls:l}]),j(null),u(`Ready`),await R()}catch(e){if(e.name===`AbortError`&&!m)j({text:`Turn stopped.`,tools:l,isError:!1,turn:r,isRetry:a}),u(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;j({text:t,tools:l,isError:!0,turn:ti(r),isRetry:a}),u(`Error — retry available`)}}finally{clearTimeout(h),P.current=null,f(!1),N.current&&N.current.focus()}}function H(){u(`Stopping…`),r&&q.chatCancel(r).catch(()=>{}),P.current?.abort()}let le=p.models_by_provider||{},ue=_&&le[_]?le[_]:p.models||[];return J(`div`,{className:`chat-panel-content`,children:[J(`div`,{className:`chat-drawer-head`,children:[J(`strong`,{className:`chat-panel-title`,children:ai(t,r)}),J(`div`,{className:`chat-head-actions`,children:J(`button`,{className:`icon-btn chat-new`,type:`button`,title:`New chat`,"aria-label":`New chat`,onClick:V,children:J(Y,{name:`message-circle-plus`})})})]}),J(`div`,{className:`chat-bar`,children:[J(`label`,{className:`chat-session-switch`,children:[J(`span`,{className:`sr-only`,children:`Conversation`}),J(`select`,{value:r,onChange:e=>te(e.target.value),disabled:!t.length,children:t.length?t.map(e=>J(`option`,{value:e.session_id,children:ii(e)},e.session_id)):J(`option`,{value:``,children:`No conversations yet`})})]}),J(`details`,{className:`chat-settings`,ref:L,children:[J(`summary`,{"aria-label":`Chat settings`,title:`Chat settings`,children:J(`span`,{"aria-hidden":`true`,children:`⚙`})}),J(`div`,{className:`chat-settings-body`,children:[J(`span`,{className:`chat-status`,children:l}),J(`label`,{children:[`Personality`,J(`select`,{className:`chat-select`,"aria-label":`Personality`,value:h,onChange:re,children:[J(`option`,{value:``,children:`Default`}),(p.personas||[]).map(e=>J(`option`,{value:e,children:e},e))]})]}),(p.providers||[]).length>0&&J(`label`,{children:[`Provider`,J(`select`,{className:`chat-select`,"aria-label":`Provider`,value:_,onChange:ie,children:[J(`option`,{value:``,children:`Default`}),(p.providers||[]).map(e=>J(`option`,{value:e,children:e},e))]})]}),J(`label`,{children:[`Model`,J(`select`,{className:`chat-select`,"aria-label":`Model`,value:y,onChange:B,children:[J(`option`,{value:``,children:`Default`}),ue.map(e=>J(`option`,{value:e,children:e},e))]})]})]})]})]}),J(`div`,{className:`chat-layout`,children:J(`section`,{className:`chat-workspace`,children:[J(`div`,{className:`chat-workspace-head`,children:J(`details`,{className:`chat-session-tools`,ref:F,hidden:!r,children:[J(`summary`,{children:`Session actions`}),J(`div`,{className:`chat-session-tool-list`,children:[J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/retry`),children:`Retry`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/undo`),children:`Undo`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/title`,`Session title`),children:`Rename`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/branch`,`Branch name (optional)`),children:`Branch`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/compress --preview`),children:`Preview compression`})]})]})}),J(`div`,{className:`chat-transcript`,ref:M,children:!a.length&&!A?J(`div`,{className:`chat-empty-state`,children:[J(`span`,{className:`chat-empty-mark`,children:`A`}),J(`h2`,{children:`What are we working on?`}),J(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),J(`div`,{className:`chat-prompt-grid`,children:[J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Summarise active tasks`),N.current?.focus()},children:`Summarise active tasks`}),J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Show running agents`),N.current?.focus()},children:`Show running agents`}),J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Check system status`),N.current?.focus()},children:`Check system status`})]})]}):J(S,{children:[a.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return J(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:J(`div`,{className:`chat-bubble`,children:i?J(S,{children:[a.length>0&&J(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return J(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[J(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),J(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.Name||e.tool||`tool`,r=e.parameters||e.Parameters||``,i=e.summary||e.Summary||e.text||e.err||e.Err||`Line truncated
|
|
|
|
|
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&i(n.session_id),n.type===`delta`&&(d+=n.text,j(e=>e?{...e,text:d}:null)),n.type===`tool`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`navigate`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`done`&&(p=!0,d||=n.text),n.type===`error`)throw Error(n.text)}if(r)break}if(!p)throw Error(`chat stream ended before completion`);o(e=>[...e,{from:`assistant`,text:d,tool_calls:l}]),j(null),u(`Ready`),await R()}catch(e){if(e.name===`AbortError`&&!m)j({text:`Turn stopped.`,tools:l,isError:!1,turn:r,isRetry:a}),u(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;j({text:t,tools:l,isError:!0,turn:ai(r),isRetry:a}),u(`Error — retry available`)}}finally{clearTimeout(h),P.current=null,f(!1),N.current&&N.current.focus()}}function V(){u(`Stopping…`),r&&K.chatCancel(r).catch(()=>{}),P.current?.abort()}let ue=p.models_by_provider||{},de=_&&ue[_]?ue[_]:p.models||[];return q(`div`,{className:`chat-panel-content`,children:[q(`div`,{className:`chat-drawer-head`,children:[q(`strong`,{className:`chat-panel-title`,children:li(t,r)}),q(`div`,{className:`chat-head-actions`,children:q(`button`,{className:`icon-btn chat-new`,type:`button`,title:`New chat`,"aria-label":`New chat`,onClick:B,children:q(J,{name:`message-circle-plus`})})})]}),q(`div`,{className:`chat-bar`,children:[q(`label`,{className:`chat-session-switch`,children:[q(`span`,{className:`sr-only`,children:`Conversation`}),q(`select`,{value:r,onChange:e=>te(e.target.value),disabled:!t.length,children:t.length?t.map(e=>q(`option`,{value:e.session_id,children:ci(e)},e.session_id)):q(`option`,{value:``,children:`No conversations yet`})})]}),q(`details`,{className:`chat-settings`,ref:L,children:[q(`summary`,{"aria-label":`Chat settings`,title:`Chat settings`,children:q(`span`,{"aria-hidden":`true`,children:`⚙`})}),q(`div`,{className:`chat-settings-body`,children:[q(`span`,{className:`chat-status`,children:l}),q(`label`,{children:[`Personality`,q(`select`,{className:`chat-select`,"aria-label":`Personality`,value:h,onChange:ie,children:[q(`option`,{value:``,children:`Default`}),(p.personas||[]).map(e=>q(`option`,{value:e,children:e},e))]})]}),(p.providers||[]).length>0&&q(`label`,{children:[`Provider`,q(`select`,{className:`chat-select`,"aria-label":`Provider`,value:_,onChange:ae,children:[q(`option`,{value:``,children:`Default`}),(p.providers||[]).map(e=>q(`option`,{value:e,children:e},e))]})]}),q(`label`,{children:[`Model`,q(`select`,{className:`chat-select`,"aria-label":`Model`,value:y,onChange:z,children:[q(`option`,{value:``,children:`Default`}),de.map(e=>q(`option`,{value:e,children:e},e))]})]})]})]})]}),q(`div`,{className:`chat-layout`,children:q(`section`,{className:`chat-workspace`,children:[q(`div`,{className:`chat-workspace-head`,children:q(`details`,{className:`chat-session-tools`,ref:F,hidden:!r,children:[q(`summary`,{children:`Session actions`}),q(`div`,{className:`chat-session-tool-list`,children:[q(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/retry`),children:`Retry`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/undo`),children:`Undo`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>re(`/title`,`Session title`),children:`Rename`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>re(`/branch`,`Branch name (optional)`),children:`Branch`}),q(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/compress --preview`),children:`Preview compression`})]})]})}),q(`div`,{className:`chat-transcript`,ref:M,children:!a.length&&!A?q(`div`,{className:`chat-empty-state`,children:[q(`span`,{className:`chat-empty-mark`,children:`A`}),q(`h2`,{children:`What are we working on?`}),q(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),q(`div`,{className:`chat-prompt-grid`,children:[q(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Summarise active tasks`),N.current?.focus()},children:`Summarise active tasks`}),q(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Show running agents`),N.current?.focus()},children:`Show running agents`}),q(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Check system status`),N.current?.focus()},children:`Check system status`})]})]}):q(S,{children:[a.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return q(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:q(`div`,{className:`chat-bubble`,children:i?q(S,{children:[a.length>0&&q(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return q(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[q(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),q(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.Name||e.tool||`tool`,r=e.parameters||e.Parameters||``,i=e.summary||e.Summary||e.text||e.err||e.Err
Line truncated
|