agent-afk 5.121.0 → 5.122.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/facets/index.d.ts +1 -0
- package/dist/agent/facets/session-end-hook.d.ts +2 -0
- package/dist/cli.mjs +541 -541
- package/dist/index.mjs +98 -98
- package/dist/telegram.mjs +248 -248
- package/dist/web-ui-assets/app.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ var St="__AFK_WEB_TOKEN__",Ie="afk_web_token",Pe="";function Me(){let t=new URLS
|
|
|
2
2
|
`).split(`
|
|
3
3
|
|
|
4
4
|
`),r=n.pop()??"",s=[];for(let i of n){if(i.trim()==="")continue;let o,c;for(let a of i.split(`
|
|
5
|
-
`))a.startsWith("id: ")?o=a.slice(4):a.startsWith("id:")?o=a.slice(3).trimStart():a.startsWith("data: ")?c=a.slice(6):a.startsWith("data:")&&(c=a.slice(5).trimStart());c!==void 0&&s.push({id:o,data:c})}return{events:s,remainder:r}}var At=15e3,Lt=500,j=class{constructor(e,n,r){this.sessionId=e;this.token=n;this.handlers=r}sessionId;token;handlers;controller;lastEventId;attempt=0;stopped=!1;start(){this.stopped=!1,this.connect()}stop(){this.stopped=!0,this.controller?.abort(),this.handlers.onStatus?.("closed")}async connect(){if(this.stopped)return;this.handlers.onStatus?.(this.attempt===0?"connecting":"reconnecting");let e=!1;this.controller=new AbortController;let n={authorization:`Bearer ${this.token}`};this.lastEventId!==void 0&&(n["last-event-id"]=this.lastEventId);try{let s=await fetch(`/api/sessions/${encodeURIComponent(this.sessionId)}/stream`,{headers:n,signal:this.controller.signal});if(!s.ok||s.body===null)throw new Error(`stream failed: ${s.status}`);this.attempt=0,this.handlers.onStatus?.("open");let i=s.body.getReader(),o=new TextDecoder,c="";e:for(;;){let{done:a,value:p}=await i.read();if(a)break;c+=o.decode(p,{stream:!0});let{events:l,remainder:u}=ze(c);c=u;for(let h of l){if(h.id!==void 0&&(this.lastEventId=h.id),h.data===void 0)continue;let x;try{x=JSON.parse(h.data)}catch{continue}if(_e(x)){e=!0,this.stopped=!0;break e}this.handlers.onEvent(x,{id:h.id})}}}catch{}if(this.stopped){e&&this.handlers.onStatus?.("ended");return}this.attempt+=1;let r=Math.min(Lt*2**(this.attempt-1),At);setTimeout(()=>{this.connect()},r)}};var He=/(?:^|\s)(\/[A-Za-z][A-Za-z0-9_:-]*)/g,$t=Number.POSITIVE_INFINITY;function Be(t){let e=new Map;for(let n=0;n<t.length;n++){let r=t[n];if(!r)continue;He.lastIndex=0;let s;for(;(s=He.exec(r))!==null;){let i=s[1]?.toLowerCase();i!==void 0&&!e.has(i)&&e.set(i,n)}}return e}function qe(t,e){let n=t.startsWith("/")?t.toLowerCase():`/${t.toLowerCase()}`;return e.get(n)??$t}function Ne(t,e,n){let r=qe(t,n),s=qe(e,n);return r!==s?r-s:t.localeCompare(e)}var It=20;function Pt(t,e){if(t.length===0)return!0;let n=0;for(let r=0;r<e.length&&n<t.length;r++)e[r]===t[n]&&(n+=1);return n===t.length}function De(t,e,n=[]){let r=e.toLowerCase(),s=t.map(l=>({key:l.name.replace(/^\//,"").toLowerCase(),cand:{value:l.name,...l.summary!==void 0?{summary:l.summary}:{},...l.hint!==void 0?{hint:l.hint}:{}}})),i=s.filter(l=>l.key.startsWith(r)),o=new Set(i.map(l=>l.cand.value)),c=r.length===0?[]:s.filter(l=>!o.has(l.cand.value)&&Pt(r,l.key)),a=Be(n),p=(l,u)=>Ne(l.cand.value,u.cand.value,a);return i.sort(p),c.sort(p),[...i,...c].map(l=>l.cand).slice(0,It)}function U(t){t.dispatchEvent(new Event("input"))}var Oe=new Set(["/clear","/compact","/editor","/exit","/fast","/font-size","/fork","/keys","/model","/reauth","/resume","/rewind","/sh","/theme","/thinking"]);function Fe(t,e,n,r){let s=document.createElement("div");s.id=e,s.setAttribute("role","option"),s.setAttribute("aria-selected",String(n)),s.className=n?"slash-row is-selected":"slash-row";let i=document.createElement("span");if(i.className="slash-name",i.textContent=t.value,s.appendChild(i),Oe.has(t.value)){let o=document.createElement("span");o.className="slash-badge",o.textContent="REPL only",o.title="Drives terminal-only machinery; cannot act in the browser.",s.appendChild(o)}if(t.summary!==void 0&&t.summary!==""){let o=document.createElement("span");o.className="slash-summary",o.textContent=t.summary,s.appendChild(o)}return s.addEventListener("mousedown",o=>{o.button===0&&(o.preventDefault(),r(t))}),s}var je=/^\/(?:[A-Za-z][\w:-]*)?$/,Z=class{constructor(e){this.deps=e;this.menuId=e.menu.id||"slash-autocomplete-listbox",this.focused=document.activeElement===e.input,e.menu.id=this.menuId,e.menu.setAttribute("role","listbox"),e.input.removeAttribute("role"),e.input.setAttribute("aria-autocomplete","list"),e.input.setAttribute("aria-haspopup","listbox"),e.input.setAttribute("aria-controls",this.menuId),this.status=document.createElement("div"),this.status.className="slash-status",this.status.setAttribute("role","status"),this.status.setAttribute("aria-live","polite"),this.status.setAttribute("aria-atomic","true"),e.menu.insertAdjacentElement("afterend",this.status),this.syncAria()}deps;commands=null;loading=null;candidates=[];selected=0;open=!1;openIntent=!1;focused=!1;composing=!1;generation=0;menuId;status;isOpen(){return this.open&&this.candidates.length>0}knows(e){return this.commands?.some(n=>n.name===e)??!1}async preload(){await this.ensureCommands()}current(){return this.isOpen()?this.candidates[this.selected]:void 0}wire(){this.deps.input.addEventListener("focus",()=>{this.focused=!0}),this.deps.input.addEventListener("keydown",e=>this.onKeyDown(e)),this.deps.input.addEventListener("compositionstart",()=>{this.composing=!0}),this.deps.input.addEventListener("compositionend",()=>{this.composing=!1,this.openIntent&&this.refresh()}),this.deps.input.addEventListener("input",()=>{this.openIntent=!0,this.composing||this.refresh()}),this.deps.input.addEventListener("blur",()=>{this.focused=!1,this.composing=!1,this.close(!0)})}onKeyDown(e){if(!(e.isComposing||e.keyCode===229)){if(e.key==="Escape"&&(this.openIntent||this.loading!==null)){this.close(!0),e.preventDefault(),e.stopImmediatePropagation();return}if(this.isOpen()&&!(e.key==="Enter"&&(e.metaKey||e.ctrlKey))){switch(e.key){case"ArrowDown":this.move(1);break;case"ArrowUp":this.move(-1);break;case"Tab":case"Enter":this.accept();break;case"Escape":this.close();break;default:return}e.preventDefault(),e.stopImmediatePropagation()}}}move(e){let n=this.candidates.length;this.selected=(this.selected+e+n)%n,this.render(),this.revealSelected()}revealSelected(){let e=this.deps.menu.children[this.selected];e instanceof HTMLElement&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}accept(){let e=this.current();e&&(this.deps.input.value=`${e.value} `,this.close(!0),this.deps.input.focus(),U(this.deps.input))}close(e=!1){e&&(this.openIntent=!1,this.generation+=1),this.open=!1,this.candidates=[],this.selected=0,this.deps.menu.hidden=!0,this.deps.menu.textContent="",this.status.textContent="",this.syncAria()}syncAria(){let e=this.isOpen();if(this.deps.input.setAttribute("aria-expanded",String(e)),e){this.deps.input.setAttribute("aria-activedescendant",this.optionId(this.selected));let n=this.candidates[this.selected];this.status.textContent=n?`${this.candidates.length} suggestions. ${n.value}, ${this.selected+1} of ${this.candidates.length}.`:""}else this.deps.input.removeAttribute("aria-activedescendant"),this.status.textContent=""}optionId(e){return`${this.menuId}-option-${e}`}async refresh(){!this.focused&&document.activeElement===this.deps.input&&(this.focused=!0);let e=this.deps.input.value;if(!je.test(e)){this.close(!0);return}this.openIntent=!0;let n=++this.generation;if(await this.ensureCommands(),n!==this.generation||!this.openIntent||!this.focused||!je.test(this.deps.input.value)){n===this.generation&&this.close();return}let r=this.deps.input.value.slice(1);this.candidates=De(this.commands??[],r),this.selected=0,this.open=this.candidates.length>0,this.openIntent=this.open,this.render()}async ensureCommands(){this.commands===null&&(this.loading??=this.deps.loadCommands().then(e=>{this.commands=e,this.deps.onCommandsLoaded?.()}).catch(e=>{console.error("[web] failed to load slash-command autocomplete:",e)}).finally(()=>{this.loading=null}),await this.loading)}render(){let e=this.deps.menu;if(e.textContent="",!this.isOpen()){e.hidden=!0,this.syncAria();return}this.candidates.forEach((n,r)=>{e.appendChild(this.row(n,r,r===this.selected))}),e.hidden=!1,this.syncAria()}row(e,n,r){return Fe(e,this.optionId(n),r,s=>{this.selected=this.candidates.indexOf(s),this.accept()})}};var Mt=/^\/[A-Za-z][\w:-]*$/;function _t(t,e){return t===""?[]:t.split(/(\s+)/).filter(n=>n!=="").map(n=>Mt.test(n)?{text:n,kind:e(n)?"known":"slash"}:{text:n,kind:"plain"})}function zt(t,e){t.textContent="";for(let n of e){if(n.kind==="plain"){t.appendChild(document.createTextNode(n.text));continue}let r=document.createElement("span");r.className=n.kind==="known"?"tok-known":"tok-slash",r.textContent=n.text,t.appendChild(r)}t.appendChild(document.createTextNode("\u200B"))}function re(t,e,n){zt(e,_t(t.value,n)),e.scrollTop=t.scrollTop,e.scrollLeft=t.scrollLeft}function Ue(t,e,n){let r=()=>{re(t,e,n)},s=()=>{e.scrollTop=t.scrollTop,e.scrollLeft=t.scrollLeft},i=()=>{t.removeEventListener("input",r),t.removeEventListener("scroll",s),e.textContent=""};return t.addEventListener("input",r),t.addEventListener("scroll",s),r(),i}var Ht="slash-menu",qt="prompt-mirror";function Ze(t){let e=document.getElementById(Ht),n=document.getElementById(qt);if(!e||!n)return;let r;return r=new Z({input:t.input,menu:e,loadCommands:t.loadCommands,onCommandsLoaded:()=>re(t.input,n,s=>r.knows(s))}),r.wire(),Ue(t.input,n,s=>r.knows(s)),t.input.classList.add("slash-highlight-active"),r.preload(),r}var Bt=/\x1B\][^\x07\x1B]*(?:\x07|\x1B\\)|\x1B[P^_X][^\x1B]*\x1B\\|\x1B\[[0-?]*[ -/]*[@-~]|\x9B[0-?]*[ -/]*[@-~]|\x1B[@-_]/g;function Ke(t){return t.replace(Bt,"")}function K(t){return Ke(t)}function le(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var I=le();function Ye(t){I=t}var L={exec:()=>null};function f(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(w.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var Nt=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),w={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},Dt=/^(?:[ \t]*(?:\n|$))+/,Ot=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ft=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,F=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,jt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ce=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,et=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,tt=f(et).replace(/bull/g,ce).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ut=f(et).replace(/bull/g,ce).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),pe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Zt=/^[^\n]+/,de=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Kt=f(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",de).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qt=f(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ce).getRegex(),V="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ue=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Gt=f("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ue).replace("tag",V).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),nt=f(pe).replace("hr",F).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",V).getRegex(),Wt=f(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",nt).getRegex(),he={blockquote:Wt,code:Ot,def:Kt,fences:Ft,heading:jt,hr:F,html:Gt,lheading:tt,list:Qt,newline:Dt,paragraph:nt,table:L,text:Zt},Qe=f("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",F).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",V).getRegex(),Xt={...he,lheading:Ut,table:Qe,paragraph:f(pe).replace("hr",F).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Qe).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",V).getRegex()},Vt={...he,html:f(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ue).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:L,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:f(pe).replace("hr",F).replace("heading",` *#{1,6} *[^
|
|
5
|
+
`))a.startsWith("id: ")?o=a.slice(4):a.startsWith("id:")?o=a.slice(3).trimStart():a.startsWith("data: ")?c=a.slice(6):a.startsWith("data:")&&(c=a.slice(5).trimStart());c!==void 0&&s.push({id:o,data:c})}return{events:s,remainder:r}}var At=15e3,Lt=500,j=class{constructor(e,n,r){this.sessionId=e;this.token=n;this.handlers=r}sessionId;token;handlers;controller;lastEventId;attempt=0;stopped=!1;start(){this.stopped=!1,this.connect()}stop(){this.stopped=!0,this.controller?.abort(),this.handlers.onStatus?.("closed")}async connect(){if(this.stopped)return;this.handlers.onStatus?.(this.attempt===0?"connecting":"reconnecting");let e=!1;this.controller=new AbortController;let n={authorization:`Bearer ${this.token}`};this.lastEventId!==void 0&&(n["last-event-id"]=this.lastEventId);try{let s=await fetch(`/api/sessions/${encodeURIComponent(this.sessionId)}/stream`,{headers:n,signal:this.controller.signal});if(!s.ok||s.body===null)throw new Error(`stream failed: ${s.status}`);this.attempt=0,this.handlers.onStatus?.("open");let i=s.body.getReader(),o=new TextDecoder,c="";e:for(;;){let{done:a,value:p}=await i.read();if(a)break;c+=o.decode(p,{stream:!0});let{events:l,remainder:u}=ze(c);c=u;for(let h of l){if(h.id!==void 0&&(this.lastEventId=h.id),h.data===void 0)continue;let x;try{x=JSON.parse(h.data)}catch{continue}if(_e(x)){e=!0,this.stopped=!0;break e}this.handlers.onEvent(x,{id:h.id})}}}catch{}if(this.stopped){e&&this.handlers.onStatus?.("ended");return}this.attempt+=1;let r=Math.min(Lt*2**(this.attempt-1),At);setTimeout(()=>{this.connect()},r)}};var He=/(?:^|\s)(\/[A-Za-z][A-Za-z0-9_:-]*)/g,$t=Number.POSITIVE_INFINITY;function Be(t){let e=new Map;for(let n=0;n<t.length;n++){let r=t[n];if(!r)continue;He.lastIndex=0;let s;for(;(s=He.exec(r))!==null;){let i=s[1]?.toLowerCase();i!==void 0&&!e.has(i)&&e.set(i,n)}}return e}function qe(t,e){let n=t.startsWith("/")?t.toLowerCase():`/${t.toLowerCase()}`;return e.get(n)??$t}function Ne(t,e,n){let r=qe(t,n),s=qe(e,n);return r!==s?r-s:t.localeCompare(e)}var It=20;function Pt(t,e){if(t.length===0)return!0;let n=0;for(let r=0;r<e.length&&n<t.length;r++)e[r]===t[n]&&(n+=1);return n===t.length}function De(t,e,n=[]){let r=e.toLowerCase(),s=t.map(l=>({key:l.name.replace(/^\//,"").toLowerCase(),cand:{value:l.name,...l.summary!==void 0?{summary:l.summary}:{},...l.hint!==void 0?{hint:l.hint}:{}}})),i=s.filter(l=>l.key.startsWith(r)),o=new Set(i.map(l=>l.cand.value)),c=r.length===0?[]:s.filter(l=>!o.has(l.cand.value)&&Pt(r,l.key)),a=Be(n),p=(l,u)=>Ne(l.cand.value,u.cand.value,a);return i.sort(p),c.sort(p),[...i,...c].map(l=>l.cand).slice(0,It)}function U(t){t.dispatchEvent(new Event("input"))}var Oe=new Set(["/clear","/compact","/editor","/exit","/fast","/font-size","/fork","/keys","/model","/reauth","/resume","/rewind","/sh","/theme","/thinking"]);function Fe(t,e,n,r){let s=document.createElement("div");s.id=e,s.setAttribute("role","option"),s.setAttribute("aria-selected",String(n)),s.className=n?"slash-row is-selected":"slash-row";let i=document.createElement("span");if(i.className="slash-name",i.textContent=t.value,s.appendChild(i),Oe.has(t.value)){let o=document.createElement("span");o.className="slash-badge",o.textContent="REPL only",o.title="Drives terminal-only machinery; cannot act in the browser.",s.appendChild(o)}if(t.summary!==void 0&&t.summary!==""){let o=document.createElement("span");o.className="slash-summary",o.textContent=t.summary,s.appendChild(o)}return s.addEventListener("mousedown",o=>{o.button===0&&(o.preventDefault(),r(t))}),s}var je=/^\/(?:[A-Za-z][\w:-]*)?$/,Z=class{constructor(e){this.deps=e;this.menuId=e.menu.id||"slash-autocomplete-listbox",this.focused=document.activeElement===e.input,e.menu.id=this.menuId,e.menu.setAttribute("role","listbox"),e.input.removeAttribute("role"),e.input.setAttribute("aria-autocomplete","list"),e.input.setAttribute("aria-haspopup","listbox"),e.input.setAttribute("aria-controls",this.menuId),this.status=document.createElement("div"),this.status.className="slash-status",this.status.setAttribute("role","status"),this.status.setAttribute("aria-live","polite"),this.status.setAttribute("aria-atomic","true"),e.menu.insertAdjacentElement("afterend",this.status),this.syncAria()}deps;commands=null;loading=null;candidates=[];selected=0;open=!1;openIntent=!1;focused=!1;composing=!1;generation=0;menuId;status;isOpen(){return this.open&&this.candidates.length>0}knows(e){return this.commands?.some(n=>n.name===e)??!1}async preload(){await this.ensureCommands()}current(){return this.isOpen()?this.candidates[this.selected]:void 0}wire(){this.deps.input.addEventListener("focus",()=>{this.focused=!0}),this.deps.input.addEventListener("keydown",e=>this.onKeyDown(e)),this.deps.input.addEventListener("compositionstart",()=>{this.composing=!0}),this.deps.input.addEventListener("compositionend",()=>{this.composing=!1,this.openIntent&&this.refresh()}),this.deps.input.addEventListener("input",()=>{this.openIntent=!0,this.composing||this.refresh()}),this.deps.input.addEventListener("blur",()=>{this.focused=!1,this.composing=!1,this.close(!0)})}onKeyDown(e){if(!(e.isComposing||e.keyCode===229)){if(e.key==="Escape"&&(this.openIntent||this.loading!==null)){this.close(!0),e.preventDefault(),e.stopImmediatePropagation();return}if(this.isOpen()&&!(e.key==="Enter"&&(e.metaKey||e.ctrlKey))){switch(e.key){case"ArrowDown":this.move(1);break;case"ArrowUp":this.move(-1);break;case"Tab":case"Enter":this.accept();break;case"Escape":this.close();break;default:return}e.preventDefault(),e.stopImmediatePropagation()}}}move(e){let n=this.candidates.length;this.selected=(this.selected+e+n)%n,this.render(),this.revealSelected()}revealSelected(){let e=this.deps.menu.children[this.selected];e instanceof HTMLElement&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}accept(){let e=this.current();e&&(this.deps.input.value=`${e.value} `,this.close(!0),this.deps.input.focus(),U(this.deps.input))}close(e=!1){e&&(this.openIntent=!1,this.generation+=1),this.open=!1,this.candidates=[],this.selected=0,this.deps.menu.hidden=!0,this.deps.menu.textContent="",this.status.textContent="",this.syncAria()}syncAria(){let e=this.isOpen();if(this.deps.input.setAttribute("aria-expanded",String(e)),e){this.deps.input.setAttribute("aria-activedescendant",this.optionId(this.selected));let n=this.candidates[this.selected];this.status.textContent=n?`${this.candidates.length} suggestions. ${n.value}, ${this.selected+1} of ${this.candidates.length}.`:""}else this.deps.input.removeAttribute("aria-activedescendant"),this.status.textContent=""}optionId(e){return`${this.menuId}-option-${e}`}async refresh(){!this.focused&&document.activeElement===this.deps.input&&(this.focused=!0);let e=this.deps.input.value;if(!je.test(e)){this.close(!0);return}this.openIntent=!0;let n=++this.generation;if(await this.ensureCommands(),n!==this.generation||!this.openIntent||!this.focused||!je.test(this.deps.input.value)){n===this.generation&&this.close();return}let r=this.deps.input.value.slice(1);this.candidates=De(this.commands??[],r),this.selected=0,this.open=this.candidates.length>0,this.openIntent=this.open,this.render()}async ensureCommands(){this.commands===null&&(this.loading??=this.deps.loadCommands().then(e=>{this.commands=e,this.deps.onCommandsLoaded?.()}).catch(e=>{console.error("[web] failed to load slash-command autocomplete:",e)}).finally(()=>{this.loading=null}),await this.loading)}render(){let e=this.deps.menu;if(e.textContent="",!this.isOpen()){e.hidden=!0,this.syncAria();return}this.candidates.forEach((n,r)=>{e.appendChild(this.row(n,r,r===this.selected))}),e.hidden=!1,this.syncAria()}row(e,n,r){return Fe(e,this.optionId(n),r,s=>{this.selected=this.candidates.indexOf(s),this.accept()})}};var Mt=/^\/[A-Za-z][\w:-]*$/;function _t(t,e){return t===""?[]:t.split(/(\s+)/).filter(n=>n!=="").map(n=>Mt.test(n)?{text:n,kind:e(n)?"known":"slash"}:{text:n,kind:"plain"})}function zt(t,e){t.textContent="";for(let n of e){if(n.kind==="plain"){t.appendChild(document.createTextNode(n.text));continue}let r=document.createElement("span");r.className=n.kind==="known"?"tok-known":"tok-slash",r.textContent=n.text,t.appendChild(r)}t.appendChild(document.createTextNode("\u200B"))}function re(t,e,n){zt(e,_t(t.value,n)),e.scrollTop=t.scrollTop,e.scrollLeft=t.scrollLeft}function Ue(t,e,n){let r=()=>{re(t,e,n)},s=()=>{e.scrollTop=t.scrollTop,e.scrollLeft=t.scrollLeft},i=()=>{t.removeEventListener("input",r),t.removeEventListener("scroll",s),e.textContent=""};return t.addEventListener("input",r),t.addEventListener("scroll",s),r(),i}var Ht="slash-menu",qt="prompt-mirror";function Ze(t){let e=document.getElementById(Ht),n=document.getElementById(qt);if(!e||!n)return;let r;return r=new Z({input:t.input,menu:e,loadCommands:t.loadCommands,onCommandsLoaded:()=>re(t.input,n,s=>r.knows(s))}),r.wire(),Ue(t.input,n,s=>r.knows(s)),t.input.classList.add("slash-highlight-active"),r.preload(),r}var Bt=/\x1B\][^\x07\x1B\x9C]*(?:\x07|\x1B\\|\x9C)|\x1B[P^_X][^\x1B\x9C]*(?:\x1B\\|\x9C)|\x1B\[[0-?]*[ -/]*[@-~]|\x9B[0-?]*[ -/]*[@-~]|\x1B[6-_]/g;function Ke(t){return t.replace(Bt,"")}function K(t){return Ke(t)}function le(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var I=le();function Ye(t){I=t}var L={exec:()=>null};function f(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(w.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var Nt=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),w={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},Dt=/^(?:[ \t]*(?:\n|$))+/,Ot=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ft=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,F=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,jt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ce=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,et=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,tt=f(et).replace(/bull/g,ce).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ut=f(et).replace(/bull/g,ce).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),pe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Zt=/^[^\n]+/,de=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Kt=f(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",de).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qt=f(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ce).getRegex(),V="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ue=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Gt=f("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ue).replace("tag",V).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),nt=f(pe).replace("hr",F).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",V).getRegex(),Wt=f(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",nt).getRegex(),he={blockquote:Wt,code:Ot,def:Kt,fences:Ft,heading:jt,hr:F,html:Gt,lheading:tt,list:Qt,newline:Dt,paragraph:nt,table:L,text:Zt},Qe=f("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",F).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",V).getRegex(),Xt={...he,lheading:Ut,table:Qe,paragraph:f(pe).replace("hr",F).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Qe).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",V).getRegex()},Vt={...he,html:f(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ue).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:L,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:f(pe).replace("hr",F).replace("heading",` *#{1,6} *[^
|
|
6
6
|
]`).replace("lheading",tt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Jt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Yt=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,st=/^( {2,}|\\)\n(?!\s*$)/,en=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,z=/[\p{P}\p{S}]/u,J=/[\s\p{P}\p{S}]/u,fe=/[^\s\p{P}\p{S}]/u,tn=f(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,J).getRegex(),rt=/(?!~)[\p{P}\p{S}]/u,nn=/(?!~)[\s\p{P}\p{S}]/u,sn=/(?:[^\s\p{P}\p{S}]|~)/u,rn=f(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Nt?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),it=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,on=f(it,"u").replace(/punct/g,z).getRegex(),an=f(it,"u").replace(/punct/g,rt).getRegex(),ot="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ln=f(ot,"gu").replace(/notPunctSpace/g,fe).replace(/punctSpace/g,J).replace(/punct/g,z).getRegex(),cn=f(ot,"gu").replace(/notPunctSpace/g,sn).replace(/punctSpace/g,nn).replace(/punct/g,rt).getRegex(),pn=f("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,fe).replace(/punctSpace/g,J).replace(/punct/g,z).getRegex(),dn=f(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,z).getRegex(),un="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",hn=f(un,"gu").replace(/notPunctSpace/g,fe).replace(/punctSpace/g,J).replace(/punct/g,z).getRegex(),fn=f(/\\(punct)/,"gu").replace(/punct/g,z).getRegex(),gn=f(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),mn=f(ue).replace("(?:-->|$)","-->").getRegex(),kn=f("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",mn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),G=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,xn=f(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",G).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),at=f(/^!?\[(label)\]\[(ref)\]/).replace("label",G).replace("ref",de).getRegex(),lt=f(/^!?\[(ref)\](?:\[\])?/).replace("ref",de).getRegex(),bn=f("reflink|nolink(?!\\()","g").replace("reflink",at).replace("nolink",lt).getRegex(),Ge=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ge={_backpedal:L,anyPunctuation:fn,autolink:gn,blockSkip:rn,br:st,code:Yt,del:L,delLDelim:L,delRDelim:L,emStrongLDelim:on,emStrongRDelimAst:ln,emStrongRDelimUnd:pn,escape:Jt,link:xn,nolink:lt,punctuation:tn,reflink:at,reflinkSearch:bn,tag:kn,text:en,url:L},wn={...ge,link:f(/^!?\[(label)\]\((.*?)\)/).replace("label",G).getRegex(),reflink:f(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",G).getRegex()},ie={...ge,emStrongRDelimAst:cn,emStrongLDelim:an,delLDelim:dn,delRDelim:hn,url:f(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ge).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:f(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ge).getRegex()},yn={...ie,br:f(st).replace("{2,}","*").getRegex(),text:f(ie.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Q={normal:he,gfm:Xt,pedantic:Vt},N={normal:ge,gfm:ie,breaks:yn,pedantic:wn},vn={"&":"&","<":"<",">":">",'"':""","'":"'"},We=t=>vn[t];function S(t,e){if(e){if(w.escapeTest.test(t))return t.replace(w.escapeReplace,We)}else if(w.escapeTestNoEncode.test(t))return t.replace(w.escapeReplaceNoEncode,We);return t}function Xe(t){try{t=encodeURI(t).replace(w.percentDecode,"%")}catch{return null}return t}function Ve(t,e){let n=t.replace(w.findPipe,(i,o,c)=>{let a=!1,p=o;for(;--p>=0&&c[p]==="\\";)a=!a;return a?"|":" |"}),r=n.split(w.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(w.slashPipe,"|");return r}function D(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r;){let i=t.charAt(r-s-1);if(i===e&&!n)s++;else if(i!==e&&n)s++;else break}return t.slice(0,r-s)}function Tn(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Sn(t,e=0){let n=e,r="";for(let s of t)if(s===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=s,n++;return r}function Je(t,e,n,r,s){let i=e.href,o=e.title||null,c=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:c,tokens:r.inlineTokens(c)};return r.state.inLink=!1,a}function Cn(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
|
|
7
7
|
`).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[c]=o;return c.length>=s.length?i.slice(s.length):i}).join(`
|
|
8
8
|
`)}var W=class{options;rules;lexer;constructor(t){this.options=t||I}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:D(n,`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-afk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.122.0",
|
|
4
4
|
"description": "Open-source coding-agent harness you can actually change — own the loop (prompts, gates, routing, skills, terminal states), use any model, run long tasks while you're away.",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|