|
|
|
@@ -1,9 +1,9 @@
|
|
|
|
|
(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&&te(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)),B(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 Oe=class extends Error{constructor(e,t){super(e),this.status=t}};function ke(e){let t=e instanceof Oe?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 Ae(e,t){let n=await fetch(e,t);if(!n.ok)throw new Oe(await De(n),n.status);return n}async function J(e,{method:t=`GET`,body:n,timeoutMs:r=Te,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 Ae(e,o);return i?s.json():void 0}var Y={summary:()=>J(`/api/summary`),tasks:()=>J(`/api/tasks`),taskMeta:()=>J(`/api/task-meta`),task:e=>J(`/api/tasks/${e}`),taskAttempts:e=>J(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>J(`/api/tasks/${e}/changes`+Ee(t)),taskDebug:(e,t)=>J(`/api/tasks/${e}/debug`+Ee(t)),taskAction:(e,t)=>J(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>J(`/api/setup`),capabilities:()=>J(`/api/capabilities`),workflows:()=>J(`/api/workflows`),workRequest:e=>J(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>J(`/api/skills`),channels:()=>J(`/api/channels`),curators:()=>J(`/api/curators`),channelReload:e=>J(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>J(`/api/config`),version:()=>J(`/api/version`),configUpdate:e=>J(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>J(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>J(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>J(`/api/logs`+Ee(e)),taskLogs:(e,t)=>J(`/api/tasks/${e}/logs`+Ee(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>J(`/api/captures`+Ee({limit:e})),mappings:()=>J(`/api/mappings`),mappingCreate:e=>J(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>J(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>J(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>J(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>J(`/api/bindings`),bindingCreate:e=>J(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>J(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>J(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>J(`/api/bindings/${e}/approve`,{method:`POST`}),memory:()=>J(`/api/memory`),chatSessions:()=>J(`/api/chat/sessions`),chatMessages:e=>J(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>J(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>J(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>J(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:we(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>J(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>J(`/api/chat/update`),chatUpdateDefer:e=>J(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>J(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>J(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>J(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>J(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>Ae(`/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 je(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 Me(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 Ne(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Pe=0;Array.isArray;function X(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Pe,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}var Fe={dashboard:`<rect x="3" y="3" width="7" height="9" rx="1.5"/><rect x="14" y="3" width="7" height="5" rx="1.5"/><rect x="14" y="12" width="7" height="9" rx="1.5"/><rect x="3" y="16" width="7" height="5" rx="1.5"/>`,chat:`<path d="M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v7a2.5 2.5 0 0 1-2.5 2.5H11l-4.5 4v-4.1A2.5 2.5 0 0 1 4 12.5z"/><path d="M8 8h8M8 11h5"/>`,tasks:`Line truncated
|
|
|
|
|
`),children:[X(`td`,{className:`strong`,children:e.label||e.id}),X(`td`,{className:`mono`,children:e.install_type||`—`}),X(`td`,{className:`mono`,children:e.running_version||`—`}),X(`td`,{className:`mono`,children:e.latest_available||`—`}),X(`td`,{children:X(Q,{text:Jn[e.status]||e.status,kind:Yn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Zn({title:e,sub:t,children:n}){return X(`div`,{className:`card cfg-section`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:e}),X(`p`,{className:`card-sub`,children:t})]})}),n]})}function Qn({origins:e}){return e?.length?X(Zn,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:X(`div`,{className:`kv-list`,children:e.map((e,t)=>X(Wn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):X(Zn,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:X($,{title:`Source provenance is unavailable.`})})}function $n(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function er({data:e,error:t}){if(t)return X(Zn,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:X($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return X(Zn,{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:[X(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?X(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??We(e.id),n=e.kind??Ge(e.id);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(Q,{text:t,kind:n})})]},e.id)})}):X($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),X(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?X(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=$n(e.kind);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):X($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function tr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(!1),[o,s]=W(null),[c,l]=W(!!e[t]);return r?X(`td`,{children:[X(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await Y.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{children:c?`yes`:`no`})}function nr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(String(e[t]??0)),[o,s]=W(null),[c,l]=W(!1);return r?X(`td`,{children:[X(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await Y.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{className:`mono`,children:i})}function rr({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return X(Zn,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:X($,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return X(Zn,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Repository`}),X(`th`,{children:`Base branch`}),X(`th`,{children:`Ecosystem`}),X(`th`,{children:`Quality gate`}),X(`th`,{children:`Protected paths`}),X(`th`,{children:`Concurrent`}),X(`th`,{children:`Max retries`}),X(`th`,{children:`Self-review`})]})}),X(`tbody`,{children:e.map((e,i)=>X(`tr`,{children:[X(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),X(`td`,{className:`mono`,children:e.base}),X(`td`,{children:e.ecosystem||`go`}),X(`td`,{className:`mono`,children:r(e.gate)}),X(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),X(tr,{r:e,field:`alloLine truncated
|
|
|
|
|
`),i=[],a=null,o=null,s=0,c=()=>{i.length&&(n.push(X(`p`,{children:Wr(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>X(`li`,{children:Wr(e)},t));n.push(a.tag===`ol`?X(`ol`,{children:e},s++):X(`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(X(`pre`,{children:X(`code`,{children:o.join(`
|
|
|
|
|
`)})},s++)),o=null):o=[];continue}if(o){o.push(t);continue}let u=Kr(t),d=e+1<r.length?Kr(r[e+1]):null;if(u&&d&&qr(d)&&u.length===d.length){c(),l();let t=[];for(e+=2;e<r.length;e++){let n=Kr(r[e]);if(!n||n.length!==u.length){e--;break}t.push(n)}n.push(X(`table`,{children:[X(`thead`,{children:X(`tr`,{children:u.map((e,t)=>X(`th`,{children:Wr(e)},t))})}),X(`tbody`,{children:t.map((e,t)=>X(`tr`,{children:e.map((e,t)=>X(`td`,{children:Wr(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(X(e,{children:Wr(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(X(`blockquote`,{children:Wr(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(X(`pre`,{children:X(`code`,{children:o.join(`
|
|
|
|
|
`)})},s++)),X(`div`,{className:t,children:n})}function Kr(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 qr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Jr=`archie.web.chat.channel`;function Yr(){let e=localStorage.getItem(Jr);return e||(e=we(),localStorage.setItem(Jr,e)),e}function Xr(e){return{text:e,sourceID:we()}}function Zr(e){return{...e}}function Qr(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?Zr(e.turn):Xr(r),isRetry:n}}function $r(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function ei(e){return e?.status===501?null:`Could not check for updates.`}function ti(){return location.hash.slice(1)||`/`}function ni(){let[e,t]=W([]),[n,r]=W(``),[i,a]=W([]),[o,s]=W(``),[c,l]=W(`Ready`),[u,d]=W(!1),[f,p]=W({}),[m,h]=W(``),[g,_]=W(``),[v,y]=W(``),[b,x]=W([]),[C,w]=W([]),[T,E]=W(0),[D,O]=W(!1),[k,A]=W(null),[j,M]=W(null),[N,P]=W(null),[F,I]=W(``),[L,ee]=W(``),[R,z]=W(null),te=K(null),B=K(null),V=K(null),ne=K(null),re=K(null),H=K(u);H.current=u,G(()=>{te.current&&(te.current.scrollTop=te.current.scrollHeight)},[i,R]),G(()=>{le().catch(e=>{l(e.message||`Chat unavailable`)}),ie();let e=()=>{V.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),V.current?.abort()}},[]);async function ie(){try{let e=await Y.chatUpdate();M(e?.snapshot||null),A(e)}catch(e){let t=ei(e);A(t?{error:t}:null)}}async function ae(){if(j)try{await Y.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function oe(){if(j)try{l(`Installing…`);let e=await Y.chatUpdateInstall(j);M(null),A({snapshot:{},available:[]}),l(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){l(e.message||`Update install failed`)}}async function se(){try{let e=await Y.chatDangerous();P(e)}catch(e){P({error:e.message||`Dangerous actions unavailable`})}}async function U(e,t){if(t)try{await Y.chatDangerousRequest(e,t),l(`Approval requested`),await se()}catch(e){l(e.message||`Could not request action`)}}async function ce(e,t){try{await Y.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await se()}catch(e){l(e.message||`Approval failed`)}}async function le(){let e=await Y.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),e.dangerous_available&&await se(),!n&&r[0]&&await ue(r[0].session_id,e,r)}async function ue(e,t,n){let i=t||f;r(e),a([]),z(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await Y.chatMessage(Yr(),`/resume ${e}`);let[t,n]=await Promise.all([Y.chatMessages(e),Y.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});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function de(e){if(n)try{l(`Working…`);let t=await Y.chatMessage(Yr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await le(),(t.session_id||n)&&await ue(t.session_id||n),ne.current&&(ne.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function fe(e,t){let n=window.prompt(t);n?.trim()&&de(`${e} ${n.trim()}`)}function pe(e){let t=e.target.value;h(t),!(!n||!t)&&Y.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function me(e){let t=e.target.value;if(_(t),t)try{let e=await Y.chatMessage(Yr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await le()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function he(e){let t=e.target.value;if(y(t),t)try{let e=await Y.chatMessage(Yr(),`/model ${t}`);l(e.reply||`Model updated`),await le()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ge(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),q({textOverride:`/restart`}))}function _e(){s(`/new`),q({textOverride:`/new`})}function ve(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function ye(e){let t=C[e];if(!t||!B.current)return;let n=B.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]===` `),c=`${r.slice(0,o)}${t.command} ${i}`;s(c),O(!1);let l=o+t
Line truncated
|
|
|
|
|
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Oe=class extends Error{constructor(e,t){super(e),this.status=t}};function ke(e){let t=e instanceof Oe?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 Ae(e,t){let n=await fetch(e,t);if(!n.ok)throw new Oe(await De(n),n.status);return n}async function J(e,{method:t=`GET`,body:n,timeoutMs:r=Te,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 Ae(e,o);return i?s.json():void 0}var Y={summary:()=>J(`/api/summary`),tasks:()=>J(`/api/tasks`),taskMeta:()=>J(`/api/task-meta`),task:e=>J(`/api/tasks/${e}`),taskAttempts:e=>J(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>J(`/api/tasks/${e}/changes`+Ee(t)),taskDebug:(e,t)=>J(`/api/tasks/${e}/debug`+Ee(t)),taskAction:(e,t)=>J(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>J(`/api/setup`),capabilities:()=>J(`/api/capabilities`),workflows:()=>J(`/api/workflows`),workRequest:e=>J(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>J(`/api/skills`),channels:()=>J(`/api/channels`),curators:()=>J(`/api/curators`),channelReload:e=>J(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>J(`/api/config`),version:()=>J(`/api/version`),configUpdate:e=>J(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>J(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>J(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>J(`/api/logs`+Ee(e)),taskLogs:(e,t)=>J(`/api/tasks/${e}/logs`+Ee(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>J(`/api/captures`+Ee({limit:e})),mappings:()=>J(`/api/mappings`),mappingCreate:e=>J(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>J(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>J(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>J(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>J(`/api/bindings`),bindingCreate:e=>J(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>J(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>J(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>J(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>J(`/api/chat/sessions`),chatMessages:e=>J(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>J(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>J(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>J(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:we(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>J(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>J(`/api/chat/update`),chatUpdateDefer:e=>J(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>J(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>J(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>J(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>J(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>Ae(`/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 je(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 Me(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 Ne(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Pe=[{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`}],Fe=[{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
|
|
|
|
|
`),children:[X(`td`,{className:`strong`,children:e.label||e.id}),X(`td`,{className:`mono`,children:e.install_type||`—`}),X(`td`,{className:`mono`,children:e.running_version||`—`}),X(`td`,{className:`mono`,children:e.latest_available||`—`}),X(`td`,{children:X(Q,{text:Yn[e.status]||e.status,kind:Xn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Qn({title:e,sub:t,children:n}){return X(`div`,{className:`card cfg-section`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:e}),X(`p`,{className:`card-sub`,children:t})]})}),n]})}function $n({origins:e}){return e?.length?X(Qn,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:X(`div`,{className:`kv-list`,children:e.map((e,t)=>X(Gn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):X(Qn,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:X($,{title:`Source provenance is unavailable.`})})}function er(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function tr({data:e,error:t}){if(t)return X(Qn,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:X($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return X(Qn,{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:[X(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?X(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??He(e.id),n=e.kind??Ue(e.id);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(Q,{text:t,kind:n})})]},e.id)})}):X($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),X(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?X(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=er(e.kind);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):X($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function nr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(!1),[o,s]=W(null),[c,l]=W(!!e[t]);return r?X(`td`,{children:[X(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await Y.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{children:c?`yes`:`no`})}function rr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(String(e[t]??0)),[o,s]=W(null),[c,l]=W(!1);return r?X(`td`,{children:[X(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await Y.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{className:`mono`,children:i})}function ir({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return X(Qn,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:X($,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return X(Qn,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Repository`}),X(`th`,{children:`Base branch`}),X(`th`,{children:`Ecosystem`}),X(`th`,{children:`Quality gate`}),X(`th`,{children:`Protected paths`}),X(`th`,{children:`Concurrent`}),X(`th`,{children:`Max retries`}),X(`th`,{children:`Self-review`})]})}),X(`tbody`,{children:e.map((e,i)=>X(`tr`,{children:[X(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),X(`td`,{className:`mono`,children:e.base}),X(`td`,{children:e.ecosystem||`go`}),X(`td`,{className:`mono`,children:r(e.gate)}),X(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),X(nr,{r:e,field:`alloLine truncated
|
|
|
|
|
`),i=[],a=null,o=null,s=0,c=()=>{i.length&&(n.push(X(`p`,{children:Br(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>X(`li`,{children:Br(e)},t));n.push(a.tag===`ol`?X(`ol`,{children:e},s++):X(`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(X(`pre`,{children:X(`code`,{children:o.join(`
|
|
|
|
|
`)})},s++)),o=null):o=[];continue}if(o){o.push(t);continue}let u=Hr(t),d=e+1<r.length?Hr(r[e+1]):null;if(u&&d&&Ur(d)&&u.length===d.length){c(),l();let t=[];for(e+=2;e<r.length;e++){let n=Hr(r[e]);if(!n||n.length!==u.length){e--;break}t.push(n)}n.push(X(`table`,{children:[X(`thead`,{children:X(`tr`,{children:u.map((e,t)=>X(`th`,{children:Br(e)},t))})}),X(`tbody`,{children:t.map((e,t)=>X(`tr`,{children:e.map((e,t)=>X(`td`,{children:Br(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(X(e,{children:Br(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(X(`blockquote`,{children:Br(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(X(`pre`,{children:X(`code`,{children:o.join(`
|
|
|
|
|
`)})},s++)),X(`div`,{className:t,children:n})}function Hr(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 Ur(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Wr=`archie.web.chat.channel`;function Gr(){let e=localStorage.getItem(Wr);return e||(e=we(),localStorage.setItem(Wr,e)),e}function Kr(e){return{text:e,sourceID:we()}}function qr(e){return{...e}}function Jr(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?qr(e.turn):Kr(r),isRetry:n}}function Yr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function Xr(e){return e?.status===501?null:`Could not check for updates.`}function Zr(){return location.hash.slice(1)||`/`}function Qr(){let[e,t]=W([]),[n,r]=W(``),[i,a]=W([]),[o,s]=W(``),[c,l]=W(`Ready`),[u,d]=W(!1),[f,p]=W({}),[m,h]=W(``),[g,_]=W(``),[v,y]=W(``),[b,x]=W([]),[C,w]=W([]),[T,E]=W(0),[D,O]=W(!1),[k,A]=W(null),[j,M]=W(null),[N,P]=W(null),[F,I]=W(``),[L,ee]=W(``),[R,z]=W(null),te=K(null),B=K(null),V=K(null),ne=K(null),re=K(null),H=K(u);H.current=u,G(()=>{te.current&&(te.current.scrollTop=te.current.scrollHeight)},[i,R]),G(()=>{le().catch(e=>{l(e.message||`Chat unavailable`)}),ie();let e=()=>{V.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),V.current?.abort()}},[]);async function ie(){try{let e=await Y.chatUpdate();M(e?.snapshot||null),A(e)}catch(e){let t=Xr(e);A(t?{error:t}:null)}}async function ae(){if(j)try{await Y.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function oe(){if(j)try{l(`Installing…`);let e=await Y.chatUpdateInstall(j);M(null),A({snapshot:{},available:[]}),l(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){l(e.message||`Update install failed`)}}async function se(){try{let e=await Y.chatDangerous();P(e)}catch(e){P({error:e.message||`Dangerous actions unavailable`})}}async function U(e,t){if(t)try{await Y.chatDangerousRequest(e,t),l(`Approval requested`),await se()}catch(e){l(e.message||`Could not request action`)}}async function ce(e,t){try{await Y.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await se()}catch(e){l(e.message||`Approval failed`)}}async function le(){let e=await Y.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),e.dangerous_available&&await se(),!n&&r[0]&&await ue(r[0].session_id,e,r)}async function ue(e,t,n){let i=t||f;r(e),a([]),z(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await Y.chatMessage(Gr(),`/resume ${e}`);let[t,n]=await Promise.all([Y.chatMessages(e),Y.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});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function de(e){if(n)try{l(`Working…`);let t=await Y.chatMessage(Gr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await le(),(t.session_id||n)&&await ue(t.session_id||n),ne.current&&(ne.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function fe(e,t){let n=window.prompt(t);n?.trim()&&de(`${e} ${n.trim()}`)}function pe(e){let t=e.target.value;h(t),!(!n||!t)&&Y.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function me(e){let t=e.target.value;if(_(t),t)try{let e=await Y.chatMessage(Gr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await le()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function he(e){let t=e.target.value;if(y(t),t)try{let e=await Y.chatMessage(Gr(),`/model ${t}`);l(e.reply||`Model updated`),await le()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ge(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),q({textOverride:`/restart`}))}function _e(){s(`/new`),q({textOverride:`/new`})}function ve(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function ye(e){let t=C[e];if(!t||!B.current)return;let n=B.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]===` `),c=`${r.slice(0,o)}${t.command} ${i}`;s(c),O(!1);let l=o+t
Line truncated
|
|
|
|
|
|
|
|
|
|
`);o=a.pop()||``;for(let e of a){let t=e.split(`
|
|
|
|
|
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(f+=n.text,z(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],z(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],z(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(i)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),z(null),l(`Ready`),await le()}catch(e){if(e.name===`AbortError`&&!m)z({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;z({text:t,tools:u,isError:!0,turn:Zr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),V.current=null,d(!1),B.current&&B.current.focus()}}function xe(){l(`Stopping…`),n&&Y.chatCancel(n).catch(()=>{}),V.current?.abort()}let Se=f.models_by_provider||{},Ce=g&&Se[g]?Se[g]:f.models||[];return X(`div`,{className:`chat-page-content`,children:[X(`header`,{className:`chat-topbar`,children:[X(`div`,{children:[X(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),X(`h1`,{className:`page-title`,children:`Chat`})]}),X(`div`,{className:`chat-topbar-actions`,children:[X(`span`,{className:`chat-status`,children:c}),f.restart_available&&X(`button`,{className:`btn`,type:`button`,onClick:ge,children:`Reload Telegram`}),X(`button`,{className:`btn`,type:`button`,onClick:ie,children:`Check updates`}),X(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:pe,children:[X(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>X(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&X(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:me,children:[X(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>X(`option`,{value:e,children:e},e))]}),X(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:he,children:[X(`option`,{value:``,children:`Model`}),Ce.map(e=>X(`option`,{value:e,children:e},e))]})]})]}),k&&X(`div`,{className:`chat-update-panel`,children:k.error?X(`span`,{children:k.error}):k.available?.length?X(S,{children:[X(`div`,{children:[X(`strong`,{children:`Update available`}),X(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:ae,children:`Defer`}),k.can_install&&X(`button`,{className:`btn btn-primary`,type:`button`,onClick:oe,children:`Install update`})]})]}):X(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&N&&X(`div`,{className:`chat-dangerous-panel`,children:[X(`div`,{className:`chat-dangerous-head`,children:[X(`strong`,{children:`Dangerous actions`}),X(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),X(`div`,{className:`chat-dangerous-controls`,children:[X(`div`,{children:[X(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:F,onChange:e=>I(e.target.value),children:[X(`option`,{value:``,children:`Select checkpoint`}),(N.checkpoints||[]).map(e=>X(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),X(`button`,{className:`btn`,type:`button`,onClick:()=>U(`rollback`,F),children:`Request rollback`})]}),X(`div`,{children:[X(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:L,onInput:e=>ee(e.target.value)}),X(`button`,{className:`btn`,type:`button`,onClick:()=>U(`stop`,L),children:`Request stop`})]})]}),X(`div`,{className:`chat-dangerous-pending-list`,children:(N.pending||[]).length?N.pending.map(e=>X(`div`,{className:`chat-dangerous-pending`,children:[X(`span`,{children:e.description}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`approve`),children:`Approve`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`permanent`),children:`Approve for 24h`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`deny`),children:`Deny`})]})]},e.id)):X(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),X(`div`,{className:`chat-layout`,children:[X(`aside`,{className:`chat-sidebar`,children:[X(`div`,{className:`chat-sidebar-head`,children:[X(`strong`,{children:`Conversations`}),X(`button`,{className:`btn btn-primary`,type:`button`,onClick:_e,children:`+ New chat`})]}),X(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>X(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>ue(e.session_id),children:[X(`strong`,{children:$r(e)}),X(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):X(`div`,{className:`chat-empty`,children:`Your conversations will aLine truncated
|
|
|
|
|
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(f+=n.text,z(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],z(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],z(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(i)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),z(null),l(`Ready`),await le()}catch(e){if(e.name===`AbortError`&&!m)z({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;z({text:t,tools:u,isError:!0,turn:qr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),V.current=null,d(!1),B.current&&B.current.focus()}}function xe(){l(`Stopping…`),n&&Y.chatCancel(n).catch(()=>{}),V.current?.abort()}let Se=f.models_by_provider||{},Ce=g&&Se[g]?Se[g]:f.models||[];return X(`div`,{className:`chat-page-content`,children:[X(`header`,{className:`chat-topbar`,children:[X(`div`,{children:[X(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),X(`h1`,{className:`page-title`,children:`Chat`})]}),X(`div`,{className:`chat-topbar-actions`,children:[X(`span`,{className:`chat-status`,children:c}),f.restart_available&&X(`button`,{className:`btn`,type:`button`,onClick:ge,children:`Reload Telegram`}),X(`button`,{className:`btn`,type:`button`,onClick:ie,children:`Check updates`}),X(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:pe,children:[X(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>X(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&X(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:me,children:[X(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>X(`option`,{value:e,children:e},e))]}),X(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:he,children:[X(`option`,{value:``,children:`Model`}),Ce.map(e=>X(`option`,{value:e,children:e},e))]})]})]}),k&&X(`div`,{className:`chat-update-panel`,children:k.error?X(`span`,{children:k.error}):k.available?.length?X(S,{children:[X(`div`,{children:[X(`strong`,{children:`Update available`}),X(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:ae,children:`Defer`}),k.can_install&&X(`button`,{className:`btn btn-primary`,type:`button`,onClick:oe,children:`Install update`})]})]}):X(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&N&&X(`div`,{className:`chat-dangerous-panel`,children:[X(`div`,{className:`chat-dangerous-head`,children:[X(`strong`,{children:`Dangerous actions`}),X(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),X(`div`,{className:`chat-dangerous-controls`,children:[X(`div`,{children:[X(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:F,onChange:e=>I(e.target.value),children:[X(`option`,{value:``,children:`Select checkpoint`}),(N.checkpoints||[]).map(e=>X(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),X(`button`,{className:`btn`,type:`button`,onClick:()=>U(`rollback`,F),children:`Request rollback`})]}),X(`div`,{children:[X(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:L,onInput:e=>ee(e.target.value)}),X(`button`,{className:`btn`,type:`button`,onClick:()=>U(`stop`,L),children:`Request stop`})]})]}),X(`div`,{className:`chat-dangerous-pending-list`,children:(N.pending||[]).length?N.pending.map(e=>X(`div`,{className:`chat-dangerous-pending`,children:[X(`span`,{children:e.description}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`approve`),children:`Approve`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`permanent`),children:`Approve for 24h`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`deny`),children:`Deny`})]})]},e.id)):X(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),X(`div`,{className:`chat-layout`,children:[X(`aside`,{className:`chat-sidebar`,children:[X(`div`,{className:`chat-sidebar-head`,children:[X(`strong`,{children:`Conversations`}),X(`button`,{className:`btn btn-primary`,type:`button`,onClick:_e,children:`+ New chat`})]}),X(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>X(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>ue(e.session_id),children:[X(`strong`,{children:Yr(e)}),X(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):X(`div`,{className:`chat-empty`,children:`Your conversations will aLine truncated
|