cogpit 3.3.5 → 3.3.6
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/cli-runtime.js +5330 -4848
- package/dist/instance-worker.js +5550 -5196
- package/dist/web/assets/{CogpitBlock-erlqla7o.js → CogpitBlock-DTcsvTF0.js} +1 -1
- package/dist/web/assets/{CommandPaletteHost-CuOrr39_.js → CommandPaletteHost-DnjXwwFv.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-C2DsAcvc.js → ConfigBrowser-C6-RV3dj.js} +1 -1
- package/dist/web/assets/{CrewPanel-DICdtFaE.js → CrewPanel-CdPeA3WX.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-CP5_qp0D.js → HighlightedEditor-ptPSiZXt.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-DB1DgAfw.js → KeyboardShortcutsDialog-CNsqP3xD.js} +1 -1
- package/dist/web/assets/{MissionHome-D8vtj_X6.js → MissionHome-CJ8aY60N.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-B5ADNE1K.js → MobileFileChanges-xDTu0VVe.js} +1 -1
- package/dist/web/assets/{PluginsDialog-B_69f-f3.js → PluginsDialog-U4WQVeyc.js} +1 -1
- package/dist/web/assets/{PreviewPanel-Dg9ZZMgz.js → PreviewPanel-CXZkRGUI.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-DkSythhf.js → ProjectFilesPanel-DxTA4CcL.js} +1 -1
- package/dist/web/assets/{ProjectSwitcherModal-ztUOYaYv.js → ProjectSwitcherModal-DVRB-R0l.js} +1 -1
- package/dist/web/assets/{TerminalOutput-LYCC1x6i.js → TerminalOutput-D_7Mor6c.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-C3Mbqa4u.js → ThemeSelectorModal-Bhkx5ikh.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-BOmbzwo_.js → WorkflowsPanel-Dexz6c1y.js} +1 -1
- package/dist/web/assets/{WorktreePanel-CdYUr34j.js → WorktreePanel-DS4svy6H.js} +1 -1
- package/dist/web/assets/{edition-ui-acJKBfUS.js → edition-ui-D6tmWJW3.js} +1 -1
- package/dist/web/assets/{index-CNaiQBmD.js → index-BKROBJD1.js} +1 -1
- package/dist/web/assets/{index-RkopwWeC.js → index-BZiOTcnb.js} +1 -1
- package/dist/web/assets/index-C6tWmbrY.css +1 -0
- package/dist/web/assets/index-COB3e1_W.js +496 -0
- package/dist/web/assets/{index-DxwM8M7d.js → index-DUyWfgZU.js} +1 -1
- package/dist/web/assets/session-parser.worker-DqoBsPjk.js +30 -0
- package/dist/web/assets/{switch-BqBbmo4j.js → switch-Bm0VDZET.js} +1 -1
- package/dist/web/assets/{vendor-ui-Cj1G8Clp.js → vendor-ui-DKYSMrjf.js} +199 -189
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/index-D1VvcJwM.css +0 -1
- package/dist/web/assets/index-DeMgVaXr.js +0 -493
- package/dist/web/assets/session-parser.worker-BZQCzzKl.js +0 -30
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as le,j as t,r as fe}from"./vendor-react-gGw_S5I_.js";import{aQ as Ne,J as ke,aR as ge,aS as pe,aT as je,aU as ve,B as Z,aV as ye,aW as Te,L as be,M as Ce,O as _e,Q as Me,j as Be,k as we,Z as $e,i as Ae,l as de,q as Se,h as Ie,D as Re}from"./index-
|
|
1
|
+
import{c as le,j as t,r as fe}from"./vendor-react-gGw_S5I_.js";import{aQ as Ne,J as ke,aR as ge,aS as pe,aT as je,aU as ve,B as Z,aV as ye,aW as Te,L as be,M as Ce,O as _e,Q as Me,j as Be,k as we,Z as $e,i as Ae,l as de,q as Se,h as Ie,D as Re}from"./index-COB3e1_W.js";import{R as me,_ as Ee,$ as De,C as ze}from"./vendor-ui-DKYSMrjf.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function Le(a){const e=le.c(29),{branches:s,activeBranchIdx:c,branchPointTurnIndex:f}=a,g=s.length;if(g===0)return null;const j=Math.min(f+1,5);let h;e[0]!==s?(h=Math.max(...s.map(He),1),e[0]=s,e[1]=h):h=e[1];const o=Math.min(h,6),n=20+j*25,r=Math.min(32,Math.max(20,(300-n)/(o+1))),d=18+(g-1)*27+15,m=`0 0 340 ${d}`,p=`${g} branches from turn ${f+1}`;let l;e[2]!==n?(l=t.jsx("line",{x1:20,y1:18,x2:n,y2:18,stroke:"var(--muted-foreground)",strokeWidth:2}),e[2]=n,e[3]=l):l=e[3];let u;e[4]!==j?(u=Array.from({length:j}).map(We),e[4]=j,e[5]=u):u=e[5];let k,b;e[6]!==n?(k=t.jsx("circle",{cx:n,cy:18,r:5,fill:"var(--background)",stroke:"var(--foreground)",strokeWidth:2}),b=t.jsx("circle",{cx:n,cy:18,r:2,fill:"var(--foreground)"}),e[6]=n,e[7]=k,e[8]=b):(k=e[7],b=e[8]);let T;if(e[9]!==c||e[10]!==n||e[11]!==s||e[12]!==o||e[13]!==r){let w;e[15]!==c||e[16]!==n||e[17]!==o||e[18]!==r?(w=(i,C)=>{const v=C===c,_=v?"var(--foreground)":"var(--border)",A=v?"var(--foreground)":"var(--border)",N=18+C*27,$=Math.min(i.graphTurnCount,o);return t.jsxs("g",{style:{opacity:v?1:.3},children:[C===0?t.jsx("line",{x1:n,y1:N,x2:n+$*r,y2:N,stroke:_,strokeWidth:2}):t.jsxs(t.Fragment,{children:[t.jsx("path",{d:`M ${n} 18 C ${n+10} ${N-5}, ${n+20} ${N}, ${n+r} ${N}`,fill:"none",stroke:_,strokeWidth:2}),$>1&&t.jsx("line",{x1:n+r,y1:N,x2:n+$*r,y2:N,stroke:_,strokeWidth:2})]}),Array.from({length:$}).map((R,S)=>t.jsxs("g",{children:[t.jsx("circle",{cx:n+(S+1)*r,cy:N,r:3.5,fill:"var(--background)",stroke:_,strokeWidth:1.5}),t.jsx("circle",{cx:n+(S+1)*r,cy:N,r:1.5,fill:A})]},S)),i.graphTurnCount>o&&t.jsxs("text",{x:n+($+.4)*r,y:N+3,fill:v?"var(--foreground)":"var(--border)",fontSize:"8",fontFamily:"monospace",children:["+",i.graphTurnCount-o]})]},i.id)},e[15]=c,e[16]=n,e[17]=o,e[18]=r,e[19]=w):w=e[19],T=s.map(w),e[9]=c,e[10]=n,e[11]=s,e[12]=o,e[13]=r,e[14]=T}else T=e[14];let B;return e[20]!==d||e[21]!==m||e[22]!==p||e[23]!==l||e[24]!==u||e[25]!==k||e[26]!==b||e[27]!==T?(B=t.jsx("div",{className:"rounded-lg border bg-muted/20 px-3 py-2",children:t.jsxs("svg",{width:"100%",height:d,viewBox:m,role:"img","aria-label":p,children:[l,u,k,b,T]})}),e[20]=d,e[21]=m,e[22]=p,e[23]=l,e[24]=u,e[25]=k,e[26]=b,e[27]=T,e[28]=B):B=e[28],B}function We(a,e){return t.jsxs("g",{children:[t.jsx("circle",{cx:20+e*25,cy:18,r:3.5,fill:"var(--background)",stroke:"var(--muted-foreground)",strokeWidth:1.5}),t.jsx("circle",{cx:20+e*25,cy:18,r:1.5,fill:"var(--muted-foreground)"})]},`s-${e}`)}function He(a){return a.graphTurnCount}function Pe(a){const e=a.input.file_path??a.input.path??"";if(e)return e.split("/").pop()||e;const s=a.input.command;if(s)return s.length>40?s.slice(0,37)+"...":s;const c=a.input.pattern;if(c)return c.length>30?c.slice(0,27)+"...":c;const f=a.input.query;return f?f.length>30?f.slice(0,27)+"...":f:""}function Fe(a){const e=le.c(26),{turn:s,archiveIndex:c,branchId:f,onRedoToHere:g}=a;let j;e[0]!==s.userMessage?(j=typeof s.userMessage=="string"?s.userMessage:Array.isArray(s.userMessage)?s.userMessage.flatMap(qe).join(`
|
|
2
2
|
`):null,e[0]=s.userMessage,e[1]=j):j=e[1];const h=j,y=c+1;let o;e[2]!==y?(o=t.jsx(ge,{className:"border-b py-2",children:t.jsxs(pe,{children:["Turn ",y]})}),e[2]=y,e[3]=o):o=e[3];let n;e[4]!==h?(n=h&&t.jsxs("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-start gap-3",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"You"}),t.jsx("div",{className:"text-sm text-foreground",children:h})]}),e[4]=h,e[5]=n):n=e[5];let r;e[6]!==s.thinking[0]||e[7]!==s.thinking.length?(r=s.thinking.length>0&&t.jsxs("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-start gap-3",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Thinking"}),t.jsxs("div",{className:"text-xs text-muted-foreground italic",children:[s.thinking[0].thinking.slice(0,300),s.thinking[0].thinking.length>300?"...":""]})]}),e[6]=s.thinking[0],e[7]=s.thinking.length,e[8]=r):r=e[8];let d;e[9]!==s.assistantText?(d=s.assistantText.length>0&&t.jsxs("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-start gap-3",children:[t.jsx("span",{className:"text-xs font-medium text-success",children:"Assistant"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:s.assistantText.join(`
|
|
3
3
|
`)})]}),e[9]=s.assistantText,e[10]=d):d=e[10];let m;e[11]!==s.toolCalls?(m=s.toolCalls.length>0&&t.jsxs("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-start gap-3",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Tools"}),t.jsx("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:s.toolCalls.map(Oe)})]}),e[11]=s.toolCalls,e[12]=m):m=e[12];let p;e[13]!==n||e[14]!==r||e[15]!==d||e[16]!==m?(p=t.jsxs(je,{className:"flex flex-col gap-3 py-3",children:[n,r,d,m]}),e[13]=n,e[14]=r,e[15]=d,e[16]=m,e[17]=p):p=e[17];let l;e[18]!==c||e[19]!==f||e[20]!==g?(l=g&&t.jsx(ve,{className:"justify-end py-2",children:t.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>g(f,c),children:[t.jsx(me,{"data-icon":"inline-start",className:"scale-x-[-1]"}),"Redo to here"]})}),e[18]=c,e[19]=f,e[20]=g,e[21]=l):l=e[21];let u;return e[22]!==o||e[23]!==p||e[24]!==l?(u=t.jsxs(ye,{size:"sm",className:"motion-list-item gap-0 py-0",children:[o,p,l]}),e[22]=o,e[23]=p,e[24]=l,e[25]=u):u=e[25],u}function Oe(a){const e=Ne(a),s=Pe(a)||e.summary;return t.jsxs("span",{className:ke("font-mono text-xs text-muted-foreground",a.isError&&"text-destructive"),children:[e.label,s?` ${s}`:""]},a.id)}function qe(a){return a.type==="text"?[a.text]:[]}function Ge(a){const e=le.c(27),{turn:s,archiveIndex:c,branchId:f,onRedoToHere:g}=a,j=c+1;let h;e[0]!==j?(h=t.jsx(ge,{className:"border-b py-2",children:t.jsxs(pe,{children:["Turn ",j]})}),e[0]=j,e[1]=h):h=e[1];let y;e[2]!==s.userMessage?(y=s.userMessage&&t.jsxs("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-start gap-3",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"You"}),t.jsx("div",{className:"text-sm text-foreground",children:s.userMessage})]}),e[2]=s.userMessage,e[3]=y):y=e[3];let o;e[4]!==s.thinkingBlocks[0]||e[5]!==s.thinkingBlocks.length?(o=s.thinkingBlocks.length>0&&t.jsxs("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-start gap-3",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Thinking"}),t.jsxs("div",{className:"text-xs text-muted-foreground italic",children:[s.thinkingBlocks[0].slice(0,300),"..."]})]}),e[4]=s.thinkingBlocks[0],e[5]=s.thinkingBlocks.length,e[6]=o):o=e[6];let n;e[7]!==s.assistantText?(n=s.assistantText.length>0&&t.jsxs("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-start gap-3",children:[t.jsx("span",{className:"text-xs font-medium text-success",children:"Assistant"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:s.assistantText.join(`
|
|
4
4
|
`)})]}),e[7]=s.assistantText,e[8]=n):n=e[8];let r;e[9]!==s.toolCalls?(r=s.toolCalls.length>0&&t.jsxs("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-start gap-3",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Tools"}),t.jsx("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:s.toolCalls.map(Qe)})]}),e[9]=s.toolCalls,e[10]=r):r=e[10];let d;e[11]!==y||e[12]!==o||e[13]!==n||e[14]!==r?(d=t.jsxs(je,{className:"flex flex-col gap-3 py-3",children:[y,o,n,r]}),e[11]=y,e[12]=o,e[13]=n,e[14]=r,e[15]=d):d=e[15];let m;e[16]!==c||e[17]!==f||e[18]!==g?(m=()=>g(f,c),e[16]=c,e[17]=f,e[18]=g,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(me,{"data-icon":"inline-start",className:"scale-x-[-1]"}),e[20]=p):p=e[20];let l;e[21]!==m?(l=t.jsx(ve,{className:"justify-end py-2",children:t.jsxs(Z,{variant:"ghost",size:"sm",onClick:m,children:[p,"Redo to here"]})}),e[21]=m,e[22]=l):l=e[22];let u;return e[23]!==l||e[24]!==h||e[25]!==d?(u=t.jsxs(ye,{size:"sm",className:"motion-list-item gap-0 py-0",children:[h,d,l]}),e[23]=l,e[24]=h,e[25]=d,e[26]=u):u=e[26],u}function Qe(a,e){return t.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[a.type," ",a.filePath.split("/").pop()]},e)}function Ze(a){var xe,he,ue;const e=le.c(88),{open:s,branches:c,branchPointTurnIndex:f,currentTurns:g,onClose:j,onCloseComplete:h,onRedoToTurn:y,onRedoEntireBranch:o}=a,n=s===void 0?!0:s;let r;if(e[0]!==c||e[1]!==g){r=[];let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=new Date().toISOString(),e[3]=x):x=e[3];let M;e[4]!==g?(M={kind:"current",id:"__current__",label:"Current branch",createdAt:x,fullTurns:g,archivedTurns:null,graphTurnCount:g.length,branch:null},e[4]=g,e[5]=M):M=e[5],r.push(M);for(const I of c){let X=null;if(I.jsonlLines.length>0)try{X=Te(I.jsonlLines.join(`
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(function(){"use strict";const Ct=["acp","codex","copilot","claude"];function Wt(t,e){if(t==="default")return e;const n=new TextEncoder().encode(e),s=btoa(Array.from(n,o=>String.fromCharCode(o)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`i-${t}__${s}`}function qt(t){const e=/^i-([A-Za-z0-9-]+)__([A-Za-z0-9_-]+)$/.exec(t);if(!e)return{instanceId:"default",nativeId:t};try{const n=Uint8Array.from(atob(e[2].replace(/-/g,"+").replace(/_/g,"/")),s=>s.charCodeAt(0));return{instanceId:e[1],nativeId:new TextDecoder("utf-8",{fatal:!0}).decode(n)}}catch{throw new Error("Invalid instance session ID")}}function en(t,e){return e==="default"?t:{...t,instanceId:e,sessionId:Wt(e,qt(t.sessionId).nativeId),...t.branchedFrom?{branchedFrom:{...t.branchedFrom,sessionId:Wt(e,qt(t.branchedFrom.sessionId).nativeId)}}:{}}}const It="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",nn=new RegExp(`^${It}$`,"i");function zt(t,e){const n=new TextEncoder().encode(e);let s="";for(const i of n)s+=String.fromCharCode(i);const o=btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${t}${o}`}function Jt(t,e){if(!e.startsWith(t))return null;try{const n=e.slice(t.length).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),o=Uint8Array.from(s,i=>i.charCodeAt(0));return new TextDecoder().decode(o)}catch{return null}}function xt(t){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(t),recognizes:e=>{const n=Jt(t,e);return n!==null&&n!==""&&zt(t,n)===e},encode:e=>zt(t,e),decode:e=>Jt(t,e)}}function Y(t){const e=new RegExp(`(${It})\\.jsonl(?:\\.zst)?$`,"i").exec(t);return e?e[1]:null}function ct(t){return t?{rootSessionId:t.toLowerCase(),isRootTranscript:!0}:null}function At(t){const e=t.split("/");return e.every(s=>s!==""&&s!=="."&&s!==".."&&!s.includes("\\"))?e:null}const St={urlId:t=>t.replace(/\.jsonl$/,""),fileNameFromUrlId:t=>t.endsWith(".jsonl")?t:`${t}.jsonl`};function Vt(t){return`'${t.replace(/'/g,"'\\''")}'`}function tt(t,e){return e?[t,e]:[]}function ut(t,e){var n;return((n=e.exec(t))==null?void 0:n[1])??null}const dt="[0-9a-f-]{36}",Ht="codex__",Gt="copilot__",sn=new Set(["default","plan","acceptEdits","dontAsk","auto"]),on=new Set(["subagents","workflows"]);function rn(t){const e=At(t);if(!e)return null;const[n,s]=e;if(e.length===1){const o=n.replace(/\.jsonl$/,"");return o!==n&&Qt(o)?ct(o):null}return e.length>2&&on.has(s)&&Qt(n)?{rootSessionId:n.toLowerCase(),isRootTranscript:!1}:null}const an={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:t=>typeof t=="string"&&!t.startsWith(Ht)&&!t.startsWith(Gt),recognizes:t=>/^(?:(?:-|[A-Za-z]--)[A-Za-z0-9-]*|[A-Za-z]-)$/.test(t),encode:t=>(t.replace(/[\\/]+$/,"")||t).replace(/[^a-zA-Z0-9]/g,"-"),decode:t=>{const e=/^([A-Za-z])--(.*)$/.exec(t);return e?`${e[1]}:\\${e[2].replace(/-/g,"\\")}`:"/"+t.replace(/^-/,"").replace(/-/g,"/")}},projectWorktreeDir:".claude/worktrees",sessionFile:{name:t=>`${t}.jsonl`,sessionId:Y,...St,transcriptRoot:rn},metadataFromHead:!0,resume:{command:t=>`claude --resume ${t}`,args:t=>["--resume",t]},launchArgs:{permissions:t=>t!=null&&t.mode?t.mode==="bypassPermissions"?["--dangerously-skip-permissions"]:[...sn.has(t.mode)?["--permission-mode",t.mode]:[],...(t.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(t.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:t=>tt("--model",t),effort:t=>tt("--effort",t),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@anthropic-ai/claude-code",homebrew:{name:"claude-code",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:{args:["update"],matches:t=>t.endsWith("/.local/bin/claude")||t.endsWith("/.local/bin/claude.exe")||t.includes("/.local/share/claude/")},bundledBySdk:!0,homeDirName:".claude",homeEnvVar:null,sdkHomeEnvVar:"CLAUDE_CONFIG_DIR",installMarker:"projects",homeIsDiscoverable:!1,process:{by:"command",sessionIdFromCommand:t=>ut(t,new RegExp(`--resume(?:=|\\s+)(${dt})`))??ut(t,new RegExp(`--session-id(?:=|\\s+)(${dt})`))}},config:{rootDirName:".claude",instructions:[{in:"scope",path:"CLAUDE.md",scopes:["global","project"]},{in:"root",path:"CLAUDE.md",label:".claude/CLAUDE.md",scopes:["project"]},{in:"scope",path:"AGENTS.md",scopes:["project"],fallback:!0}],settings:[{in:"root",path:"settings.json",scopes:["global"]},{in:"root",path:"settings.local.json",scopes:["project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"commands",themesDir:"themes",pluginsDir:"plugins",pluginManifestDir:".claude-plugin"},contextWindow:{defaultLimit:1e6,limits:[{match:"claude-haiku-4-5",limit:2e5},{match:"claude-haiku-4-1",limit:2e5},{match:"claude-sonnet-4-5",limit:2e5},{match:"claude-opus-4-5",limit:2e5},{match:"claude-opus-4-1",limit:2e5}],compactBuffer:33e3,extendedContext:{marker:"[1m]",limit:1e6}},capabilities:{worktrees:!0,mcp:!0,slashCommands:!0,workflows:!0,agentTeams:!0,subagentTranscripts:!0,nestedSubagents:!1,sharing:!0,goals:"transcript",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!0,reasoningEffort:!0,configurableContextWindow:!1,fastTier:!0,lowPriorityInTerminal:!0,imageInput:!0,midTurnSteering:!0,activeNotifications:!0,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,accountSwitching:!0,modelFallbackNotices:!0,autoPermissionMode:"per-model",toolPermissionRules:!0,settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},Kt={appServerValue:"priority",cliConfigValue:"fast"},ln={kind:"codex",displayName:"Codex",binName:"codex",dirName:xt(Ht),projectWorktreeDir:null,sessionFile:{name:(t,e=new Date)=>{const n=String(e.getFullYear()),s=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0"),d=String(e.getSeconds()).padStart(2,"0");return`${n}/${s}/${o}/rollout-${n}-${s}-${o}T${i}-${l}-${d}-${t}.jsonl`},sessionId:Y,...St,transcriptRoot:t=>At(t)?ct(Y(t)):null},metadataFromHead:!1,resume:{command:(t,e)=>e?`codex -C ${Vt(e)} resume ${t}`:`codex resume ${t}`,args:t=>["resume",t]},launchArgs:{permissions:t=>{const e=(t==null?void 0:t.mode)||"default";return e==="bypassPermissions"?["--dangerously-bypass-approvals-and-sandbox"]:e==="auto"?["--approve-for-me"]:["--sandbox",e==="plan"?"read-only":"workspace-write","-c",'approval_policy="never"']},model:t=>tt("-m",t),effort:t=>t?["-c",`model_reasoning_effort=${JSON.stringify(t)}`]:[],fastTier:t=>t?["-c",`service_tier=${JSON.stringify(Kt.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:Kt,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,bundledBySdk:!1,homeDirName:".codex",homeEnvVar:"CODEX_HOME",sessionIdEnvVar:"CODEX_THREAD_ID",installMarker:"",homeIsDiscoverable:!0,process:{by:"command",sessionIdFromCommand:t=>ut(t,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${dt})`))}},config:{rootDirName:".codex",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.toml",scopes:["global","project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"prompts",themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:272e3,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!0,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,nestedSubagents:!0,sharing:!1,goals:"thread-api",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,configurableContextWindow:!0,fastTier:!0,lowPriorityInTerminal:!1,imageInput:!0,midTurnSteering:!0,activeNotifications:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",toolPermissionRules:!0,settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}};function wt(t){const e=new RegExp(`^(${It})/events\\.jsonl$`,"i").exec(t);return e?e[1]:null}const et={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:xt(Gt),projectWorktreeDir:null,sessionFile:{name:t=>`${t}/events.jsonl`,sessionId:wt,urlId:t=>wt(t)??t.replace(/\.jsonl$/,""),fileNameFromUrlId:t=>t.endsWith(".jsonl")?t:`${t}/events.jsonl`,transcriptRoot:t=>ct(wt(t))},metadataFromHead:!0,resume:{command:(t,e)=>e?`copilot -C ${Vt(e)} --resume ${t}`:`copilot --resume ${t}`,args:t=>[`--resume=${t}`]},launchArgs:{permissions:t=>(t==null?void 0:t.mode)==="bypassPermissions"||(t==null?void 0:t.mode)==="auto"?["--allow-all"]:[],model:t=>tt("--model",t),effort:t=>tt("--reasoning-effort",t),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@github/copilot",homebrew:{name:"copilot-cli",cask:!0},wingetId:"GitHub.Copilot",versionArgs:["--version"],selfUpdate:{args:["update"],matches:t=>t.endsWith("/.local/bin/copilot")||t==="/usr/local/bin/copilot"},bundledBySdk:!1,homeDirName:".copilot",homeEnvVar:"COPILOT_HOME",installMarker:"session-state",homeIsDiscoverable:!0,process:{by:"executable",sessionIdFromCommand:t=>ut(t,new RegExp(`--resume(?:=|\\s+)(${dt})`))}},config:{rootDirName:".copilot",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.json",scopes:["global"]}],skillsDir:"skills",agentsDir:null,commandsDir:null,themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:2e5,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!1,nestedSubagents:!1,sharing:!1,goals:!1,undo:!0,redo:!1,nativeRewind:!0,fileCheckpoints:!1,reasoningEffort:!1,configurableContextWindow:!1,fastTier:!1,lowPriorityInTerminal:!1,imageInput:!1,midTurnSteering:!0,activeNotifications:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",toolPermissionRules:!0,settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},cn={...et,kind:"acp",displayName:"ACP agent",binName:"acp",dirName:xt("acp__"),sessionFile:{name:t=>`${t}.jsonl`,sessionId:Y,...St,transcriptRoot:t=>{const e=At(t);return(e==null?void 0:e.length)===1?ct(Y(t)):null}},resume:{command:()=>"Resume this session in Cogpit",args:()=>[]},launchArgs:{permissions:()=>[],model:()=>[],effort:()=>[],fastTier:()=>[]},cli:{...et.cli,packageName:"",homebrew:null,wingetId:null,selfUpdate:null,requiresConfiguration:!0,homeDirName:".cogpit-acp",homeEnvVar:"COGPIT_ACP_HOME",homeIsDiscoverable:!0,installMarker:"projects"},config:{...et.config,rootDirName:".cogpit-acp",instructions:[],settings:[],skillsDir:null},capabilities:{...et.capabilities,undo:!1,redo:!1,nativeRewind:!1,nativeFork:!1,midTurnSteering:!1,activeNotifications:!1,externalProcesses:!1,autoPermissionMode:"never",toolPermissionRules:!1,namedSessions:!1}},un=Object.freeze({claude:an,codex:ln,copilot:et,acp:cn});function ft(t){return un[t]}function Qt(t){return nn.test(t)}const Zt={0:"\0",b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" ",v:"\v"};function Xt(t,e){const n=t[e];if(n!=='"'&&n!=="'"&&n!=="`")return null;let s="",o=e+1;for(;o<t.length;){const i=t[o];if(i===n)return{endIndex:o+1,value:s};if(i!=="\\"){s+=i,o++;continue}if(o++,o>=t.length)return null;const l=t[o];if(l in Zt){s+=Zt[l],o++;continue}if(l===`
|
|
3
|
+
`){o++;continue}if(l==="\r"){o+=t[o+1]===`
|
|
4
|
+
`?2:1;continue}if(l==="x"&&/^[0-9a-fA-F]{2}$/.test(t.slice(o+1,o+3))){s+=String.fromCharCode(Number.parseInt(t.slice(o+1,o+3),16)),o+=3;continue}if(l==="u"){const d=t.slice(o+1).match(/^\{([0-9a-fA-F]+)\}/);if(d){const u=Number.parseInt(d[1],16);if(Number.isFinite(u)&&u<=1114111){s+=String.fromCodePoint(u),o+=d[0].length+1;continue}}const f=t.slice(o+1,o+5);if(/^[0-9a-fA-F]{4}$/.test(f)){s+=String.fromCharCode(Number.parseInt(f,16)),o+=5;continue}}s+=l,o++}return null}function Mt(t,e=0){if(!t.some(d=>d.endedAt===void 0))return null;const n=[...t].sort((d,f)=>d.launchedAt-f.launchedAt);let s=0,o=-1/0;n.forEach((d,f)=>{o<d.launchedAt&&(s=f),o=Math.max(o,d.endedAt??1/0)});const i=n.slice(s).map(({agent:d,endedAt:f})=>({...d,done:f!==void 0})),l=i.filter(d=>!d.done);return{status:"awaiting_agents",pendingQueue:e,pendingAgents:l.length,pendingAgentDescriptions:l.map(d=>d.description).filter(d=>d.length>0),backgroundAgents:i}}function Et(t){return t.type==="user"}function Nt(t){return t.type==="assistant"}function Yt(t){return t.type==="progress"}function vt(t){return t.type==="system"}function te(t){return t.type==="summary"}function dn(t){return t.type==="queue-operation"}function ee(t){return t.type==="attachment"}function fn(t){return t.type==="user"&&t.isCompactSummary===!0}function ne(t){return t.type==="system"&&t.subtype==="compact_boundary"}function se(t,e){let n=0;for(const s of t)e[s.name]=(e[s.name]??0)+1,s.isError&&n++;return n}function oe(t,e){t.totalInputTokens+=e.input_tokens,t.totalOutputTokens+=e.output_tokens,t.totalCacheCreationTokens+=e.cache_creation_input_tokens??0,t.totalCacheReadTokens+=e.cache_read_input_tokens??0}function pt(t){return{totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:t}}function mt(t){const e=pt(t.length);for(const n of t){n.tokenUsage&&oe(e,n.tokenUsage),n.durationMs&&(e.totalDurationMs+=n.durationMs),e.errorCount+=se(n.toolCalls,e.toolCallCounts);for(const s of n.subAgentActivity)e.errorCount+=se(s.toolCalls,e.toolCallCounts),s.tokenUsage&&oe(e,s.tokenUsage)}return e}function K(t,e){var s,o;if(!t)return{...e};const n=(((s=t.output_tokens_details)==null?void 0:s.thinking_tokens)??0)+(((o=e.output_tokens_details)==null?void 0:o.thinking_tokens)??0);return{input_tokens:t.input_tokens+e.input_tokens,output_tokens:t.output_tokens+e.output_tokens,cache_creation_input_tokens:(t.cache_creation_input_tokens??0)+(e.cache_creation_input_tokens??0),cache_read_input_tokens:(t.cache_read_input_tokens??0)+(e.cache_read_input_tokens??0),speed:e.speed??t.speed,...t.output_tokens_details||e.output_tokens_details?{output_tokens_details:{thinking_tokens:n}}:{}}}const pn=/<(agent-message|teammate-message)([^>]*)>([\s\S]*?)<\/\1>/g,mn=[/\bteammate_id=(?:"([^"]*)"|'([^']*)')/,/\bfrom=(?:"([^"]*)"|'([^']*)')/];function gn(t){for(const e of mn){const n=t.match(e),s=(n==null?void 0:n[1])??(n==null?void 0:n[2]);if(s)return s}return null}function Rt(t){let e=null,n=!1;const s=t.replace(pn,(o,i,l,d)=>(n=!0,e===null&&(e=gn(l)),d.trim()));return{sender:e,matched:n,body:n?s.trim():t}}function gt(t){return t&&typeof t=="object"?t:{}}function hn(t,e){const n=gt(e);if(t==="Edit"||t==="Write")return n.staged===!0?{awaitingReview:!0}:{};if(t!=="Bash")return{};const s=gt(n.bashEditDiff);if(!Array.isArray(s.files))return{};const o=[];for(const l of s.files){const d=gt(l);if(typeof d.filePath!="string"||!d.filePath||!Array.isArray(d.hunks))continue;const f=[];for(const u of d.hunks){const _=gt(u),{oldStart:S,oldLines:h,newStart:g,newLines:E,lines:R}=_;[S,h,g,E].every(P=>typeof P=="number"&&Number.isInteger(P)&&P>=0)&&(!Array.isArray(R)||!R.every(P=>typeof P=="string"&&/^[ +\\-]/.test(P))||f.push({oldStart:S,oldLines:h,newStart:g,newLines:E,lines:R}))}f.length&&o.push({filePath:d.filePath,hunks:f})}const i=typeof s.moreFiles=="number"&&Number.isInteger(s.moreFiles)&&s.moreFiles>0?s.moreFiles:0;return{fileDiffs:o,...i?{additionalFileDiffs:i}:{}}}function ht(t){return typeof t=="string"?t:t.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
5
|
+
`)}function ie(t){return t?typeof t=="string"?t:t.map(e=>e.type==="text"?e.text:"").filter(Boolean).join(`
|
|
6
|
+
`):""}function re(t){if(!(t!=null&&t.trim()))return!1;const e=t.trimStart();return e.startsWith("<")?!e.includes("<task-notification>")&&!e.startsWith("<system-reminder>")&&!e.startsWith("<local-command-"):!0}const yn=/<task-notification>[\s\S]*?<\/task-notification>/g,_n=/<[^>]*>/g;function kn(t){var n;if(((n=t.origin)==null?void 0:n.kind)==="task-notification")return!0;const e=ht(t.message.content);return e.includes("<task-notification>")?e.replace(yn,"").replace(_n,"").trim()==="":!1}function ae(t){return t==="Task"||t==="Agent"}function le(t){const e=t.effort;return{name:typeof t.name=="string"?t.name:null,subagentType:typeof t.subagent_type=="string"?t.subagent_type:null,effort:typeof e=="string"||typeof e=="number"?String(e):null}}function bn(t){if(!ee(t))return null;const e=t.attachment;if(!e||e.type!=="queued_command"||e.commandMode!=="prompt")return null;const n=e.prompt;if(n==null)return null;const s=typeof n=="string"?n:ht(n);if(!re(s))return null;const o=e.origin;if((o==null?void 0:o.kind)==="peer"){const l=o.name??o.from??null;if(l)return{raw:s,sender:l,body:o.body??Rt(s).body}}if((o==null?void 0:o.kind)==="human")return{raw:s,sender:null,body:s};const i=Rt(s);return{raw:s,sender:i.sender,body:i.body}}const Tn=[["attributionAgent","agent"],["attributionSkill","skill"],["attributionPlugin","plugin"],["attributionMcpServer","mcpServer"],["attributionMcpTool","mcpTool"]];function Cn(t,e){let n=t;for(const[s,o]of Tn){const i=e[s];typeof i!="string"||!i||(n={...n,[o]:i})}return n}const In=/^This session is being continued from a previous conversation[\s\S]*?\n\nSummary:\s*\n/,xn=/\n+(?:If you need specific details from before compaction|(?:Please c|C)ontinue the conversation from where it left off)[\s\S]*$/;function An(t){return ht(t).trim().replace(In,"").replace(xn,"").trim()}function Sn(t){if(t)return{trigger:t.trigger,preTokens:t.preTokens,postTokens:t.postTokens}}function yt(t,e){return{id:t.uuid??crypto.randomUUID(),userMessage:e,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:t.timestamp??"",durationMs:null,tokenUsage:null,model:null}}function wn(t){const e=[];let n=0;for(;n<t.length;){const s=t[n];if(s.kind==="tool_calls"){const o=s.toolCalls.findIndex(i=>i.name==="EnterPlanMode");if(o!==-1){const i=s.toolCalls[o],l=String(i.input.plan??""),d=s.timestamp,f=s.toolCalls.slice(0,o);f.length>0&&e.push({kind:"tool_calls",toolCalls:f,timestamp:s.timestamp});const u=[],_=s.toolCalls.slice(o+1),S=_.findIndex(h=>h.name==="ExitPlanMode");if(S!==-1){u.push(..._.slice(0,S));const h=_[S],g=h.input.path?String(h.input.path):void 0;let E="pending";h.result!==null&&(E=h.isError?"rejected":"approved"),e.push({kind:"plan_mode",plan:l,planFilePath:g,status:E,toolCalls:u,timestamp:d});const R=_.slice(S+1);R.length>0&&e.push({kind:"tool_calls",toolCalls:R,timestamp:s.timestamp}),n++;continue}else{u.push(..._);let h,g,E="pending",R=n+1;const P=[];for(;R<t.length;){const k=t[R];if(k.kind==="tool_calls"){const v=k.toolCalls.findIndex(F=>F.name==="ExitPlanMode");if(v!==-1){u.push(...k.toolCalls.slice(0,v)),h=k.toolCalls[v],g=h.input.path?String(h.input.path):void 0,h.result!==null&&(E=h.isError?"rejected":"approved");const F=k.toolCalls.slice(v+1);e.push({kind:"plan_mode",plan:l,planFilePath:g,status:E,toolCalls:u,timestamp:d}),e.push(...P),F.length>0&&e.push({kind:"tool_calls",toolCalls:F,timestamp:k.timestamp}),n=R+1;break}else u.push(...k.toolCalls),R++}else if(k.kind==="hook_event"||k.kind==="text"||k.kind==="queued_prompt"||k.kind==="agent_message")P.push(k),R++;else break}h||(e.push({kind:"plan_mode",plan:l,planFilePath:void 0,status:"pending",toolCalls:u,timestamp:d}),e.push(...P),n=R);continue}}}e.push(s),n++}return e}function Mn(t){return t.contentBlocks.some(e=>e.kind==="agent_message")?{...t,contentBlocks:t.contentBlocks.map(e=>{if(e.kind!=="agent_message")return e;const{reply:n,...s}=e;return s})}:t}function ce(t){var s;const e=t.map(Mn),n=new Map;for(const o of e)for(const i of o.contentBlocks){if(i.kind==="agent_message"){const l=n.get(i.sender);l?l.push(i):n.set(i.sender,[i]);continue}if(i.kind==="tool_calls")for(const l of i.toolCalls){if(l.name!=="SendMessage")continue;const d=l.input.to;if(typeof d!="string"||!d)continue;const f=(s=n.get(d))==null?void 0:s.shift();if(!f)continue;const u=l.input.summary;f.reply={summary:typeof u=="string"?u:"",timestamp:l.timestamp||i.timestamp||""}}}return e}function En(t){const e=[];let n=!1;for(let s=0;s<t.length;s++){const o=t[s];if(te(o)||ne(o)){n=!1;continue}if(Et(o)&&!o.isMeta){const i=o.message.content;if(n&&Array.isArray(i)&&i.some(d=>d.type==="tool_result"))continue;e.push(s),n=!0;continue}Nt(o)&&!n&&(e.push(s),n=!0)}return e}function ue(t){var L,x;const e=[],n=[];let s=null,o=0,i=null,l=null;function d(r){l&&(r.compactionSummary=l.summary,r.compactionMeta=l.meta,l=null)}let f=null;const u=new Map,_=new Set,S=new Map,h=new Map,g=new Set,E=new Map,R=[],P=new Map;function k(r,c){let b=P.get(r);b||(b=new Map,P.set(r,b)),b.set(c,(b.get(c)??0)+1)}function v(r,c){const b=P.get(r),p=b==null?void 0:b.get(c);return!b||!p?!1:(p===1?b.delete(c):b.set(c,p-1),!0)}function F(){for(const r of R)r.turn.contentBlocks.push(r.sender?{kind:"agent_message",sender:r.sender,body:r.body,timestamp:r.timestamp}:{kind:"queued_prompt",content:r.content,timestamp:r.timestamp});R.length=0}function W(r){if(!i)return;const c=S.get(r);if(!c||c.length===0)return;i.subAgentActivity.push(...c),S.delete(r);const b=g.has(r)?"background_agent":"sub_agent",p=h.get(r);if(p)p.messages.push(...c);else{const T={kind:b,messages:[...c]};i.contentBlocks.push(T),h.set(r,T)}}function O(){if(i){for(const r of i.toolCalls)W(r.id);for(const[r]of S)W(r);for(const r of i.contentBlocks)if(r.kind==="hook_event")for(const c of r.events){if(!(c.eventName==="PostToolUse"||c.eventName.startsWith("PostToolUse:"))||!c.toolUseId)continue;const p=i.toolCalls.find(T=>T.id===c.toolUseId);p&&(c.updatedToolOutput&&(p.outputReplacedByHook=!0),c.durationMs!==void 0&&(p.hookDurationMs=(p.hookDurationMs??0)+c.durationMs))}i.contentBlocks=wn(i.contentBlocks),e.push(i),s!==null&&n.push(s),s=null,i=null,h.clear()}}for(o=0;o<t.length;o++){const r=t[o];if(te(r)){O(),l={summary:r.summary};continue}if(ne(r)){O(),l={meta:Sn(r.compactMetadata)};continue}if(fn(r)){O(),s=o,i=yt(r,null),i.compactionSummary=An(r.message.content),i.compactionMeta=l==null?void 0:l.meta,l=null;continue}if(vt(r)&&r.subtype==="away_summary"&&r.content){f={content:r.content,timestamp:r.timestamp};continue}if(vt(r)&&r.subtype==="local_command"&&r.content){i==null||i.contentBlocks.push({kind:"local_command",content:r.content,timestamp:r.timestamp,...r.contextUsage?{contextUsage:r.contextUsage}:{},...r.usageReport?{usageReport:r.usageReport}:{}});continue}if(dn(r)){if(i&&r.operation==="enqueue"&&re(r.content)){const c=Rt(r.content);R.push({turn:i,content:r.content,timestamp:r.timestamp,sender:c.sender,body:c.body}),k(i,r.content)}continue}if(ee(r)){const c=bn(r);i&&c!==null&&!v(i,c.raw)&&R.push({turn:i,content:c.raw,timestamp:((L=r.attachment)==null?void 0:L.timestamp)??r.timestamp,sender:c.sender,body:c.body});continue}if(R.length>0){const c=Et(r)&&!r.isMeta?r.message.content:null;if(typeof c=="string"){const b=R.findIndex(p=>p.content===c);if(b>=0){const[p]=R.splice(b,1);v(p.turn,p.content)}}F()}if(Et(r)&&!r.isMeta){const c=r.message.content;if(typeof c!="string"&&Array.isArray(c)&&c.some(p=>p.type==="tool_result")&&i){for(const T of c)if(T.type==="tool_result"){const a=u.get(T.tool_use_id);if(a){a.turn.toolCalls[a.index].result=ie(T.content),a.turn.toolCalls[a.index].isError=T.is_error===!0;const C=a.turn.toolCalls[a.index];Object.assign(C,hn(C.name,r.toolUseResult)),u.delete(T.tool_use_id)}}const p=r.toolUseResult;if(p!=null&&p.agentId){const T=((x=c.find(y=>y.type==="tool_result"))==null?void 0:x.tool_use_id)??"",a=E.get(T),C=g.has(T),w=[];if(Array.isArray(p.content))for(const y of p.content)y.type==="text"&&w.push(y.text);const m={agentId:p.agentId,parentToolUseId:T||void 0,agentName:(a==null?void 0:a.name)??null,subagentType:(a==null?void 0:a.subagentType)??null,...a!=null&&a.effort?{effort:a.effort}:{},type:"assistant",content:p.content,toolCalls:[],thinking:[],text:w,timestamp:r.timestamp??"",tokenUsage:p.usage?{input_tokens:p.usage.input_tokens??0,output_tokens:p.usage.output_tokens??0,cache_creation_input_tokens:p.usage.cache_creation_input_tokens??0,cache_read_input_tokens:p.usage.cache_read_input_tokens??0}:null,model:null,isBackground:C,prompt:p.prompt,status:p.status,durationMs:p.totalDurationMs,toolUseCount:p.totalToolUseCount};if(!h.get(T)){i.subAgentActivity.push(m);const N={kind:C?"background_agent":"sub_agent",messages:[m]};i.contentBlocks.push(N),h.set(T,N)}}continue}if(kn(r)){const b={kind:"task_notification",content:ht(c),timestamp:r.timestamp};if(i){i.contentBlocks.push(b);continue}s=o,i=yt(r,null),i.contentBlocks.push(b),d(i);continue}O(),s=o,i=yt(r,r.message.content),d(i),f&&(i.contentBlocks.push({kind:"recap",content:f.content,timestamp:f.timestamp}),f=null);continue}if(Nt(r)){let c=function(){C.length>0&&(w.contentBlocks.push({kind:"tool_calls",toolCalls:[...C],timestamp:T}),C.length=0)},b=function(){if(a.length>0){const m=w.contentBlocks[w.contentBlocks.length-1];m&&m.kind==="thinking"?m.blocks.push(...a):w.contentBlocks.push({kind:"thinking",blocks:[...a],timestamp:T}),a.length=0}};i||(s=o,i=yt(r,null),d(i)),i.model=r.message.model,r.effort&&(i.effort=r.effort),i.attribution=Cn(i.attribution,r);const p=r.message.id;_.has(p)||(_.add(p),i.tokenUsage=K(i.tokenUsage,r.message.usage));const T=r.timestamp??"",a=[],C=[],w=i;for(const m of r.message.content)if(m.type==="thinking"){c();const I=m;if(!I.thinking)continue;i.thinking.push(I),a.push(I)}else if(m.type==="text"){c(),b();const I=/<thinking>([\s\S]*?)<\/thinking>/g;let y=m.text,N;for(;(N=I.exec(m.text))!==null;){const M=N[1].trim();if(M){const B={type:"thinking",thinking:M,signature:""};i.thinking.push(B),i.contentBlocks.push({kind:"thinking",blocks:[B],timestamp:T})}y=y.replace(N[0],"")}if(y=y.trim(),y){i.assistantText.push(y);const M=i.contentBlocks[i.contentBlocks.length-1];M&&M.kind==="text"?M.text.push(y):i.contentBlocks.push({kind:"text",text:[y],timestamp:T})}}else if(m.type==="tool_use"){b();const I={id:m.id,name:m.name,input:m.input,result:null,isError:!1,timestamp:r.timestamp??""},y=i.toolCalls.length;if(i.toolCalls.push(I),C.push(I),u.set(m.id,{turn:i,index:y}),ae(m.name)){const N=m.input;N.run_in_background===!0&&g.add(m.id),E.set(m.id,le(N))}}b(),c();continue}if(Yt(r)&&r.data.type==="agent_progress"){const c=r.data,b=r.parentToolUseID??"",p=c.toolUseId??b;let T=null;if(c.message.type==="assistant"){const I=c.message.message,y=I.id,N=I.usage;N&&y&&!_.has(y)&&(_.add(y),T={input_tokens:N.input_tokens??0,output_tokens:N.output_tokens??0,cache_creation_input_tokens:N.cache_creation_input_tokens??0,cache_read_input_tokens:N.cache_read_input_tokens??0})}const a=c.message.type==="assistant"?c.message.message.model??null:null,C=E.get(p),w={agentId:c.agentId,parentToolUseId:p||void 0,...c.parentAgentId?{parentAgentId:c.parentAgentId}:{},...C!=null&&C.effort?{effort:C.effort}:{},agentName:(C==null?void 0:C.name)??null,subagentType:(C==null?void 0:C.subagentType)??c.subagentType??null,type:c.message.type,content:c.message.message.content,toolCalls:[],thinking:[],text:[],timestamp:c.message.timestamp??r.timestamp??"",tokenUsage:T,model:a,isBackground:g.has(b)};if(c.message.type==="assistant"){const I=c.message.message.content;if(Array.isArray(I))for(const y of I)y.type==="thinking"?w.thinking.push(y.thinking):y.type==="text"?w.text.push(y.text):y.type==="tool_use"&&(ae(y.name)&&E.set(y.id,le(y.input)),w.toolCalls.push({id:y.id,name:y.name,input:y.input,result:null,isError:!1,timestamp:c.message.timestamp??r.timestamp??""}))}else if(c.message.type==="user"){const I=c.message.message.content;if(Array.isArray(I)){for(const y of I)if(y.type==="tool_result"){const N=S.get(b);if(N)for(const M of N){const B=M.toolCalls.find(D=>D.id===y.tool_use_id);B&&(B.result=ie(y.content),B.isError=y.is_error===!0)}}}}let m=S.get(b);m||(m=[],S.set(b,m)),m.push(w),i&&W(b);continue}if(Yt(r)&&r.data.type==="hook_progress"){const c=r.data,b=String(c.hook_event_name??c.hookEvent??"unknown"),p=c.hookSpecificOutput,T={eventName:b,source:c.source!==void 0?String(c.source):void 0,toolName:c.tool_name!==void 0?String(c.tool_name):void 0,toolUseId:c.tool_use_id!==void 0?String(c.tool_use_id):void 0,command:c.command!==void 0?String(c.command):void 0,output:c.output!==void 0?String(c.output):void 0,stderr:c.stderr!==void 0?String(c.stderr):void 0,exitCode:c.exit_code!==void 0?Number(c.exit_code):void 0,decision:c.decision!==void 0?String(c.decision):void 0,durationMs:c.duration_ms!==void 0?Number(c.duration_ms):void 0,updatedToolOutput:(p==null?void 0:p.updatedToolOutput)!==void 0?String(p.updatedToolOutput):void 0,sessionTitle:(p==null?void 0:p.sessionTitle)!==void 0?String(p.sessionTitle):void 0,worktreePath:(p==null?void 0:p.worktreePath)!==void 0?String(p.worktreePath):void 0,timestamp:r.timestamp??""};if(i){const a=i.contentBlocks[i.contentBlocks.length-1];a&&a.kind==="hook_event"?a.events.push(T):i.contentBlocks.push({kind:"hook_event",events:[T],timestamp:r.timestamp})}continue}if(vt(r)&&r.subtype==="turn_duration"&&i){r.durationMs!==void 0&&r.durationMs!==null&&(i.durationMs=(i.durationMs??0)+r.durationMs);continue}}return F(),O(),{turns:ce(e),turnStartIndices:n}}function de(t){return ue(t).turns}function fe(){return!0}const pe='"type":"api-request',Nn=256;function me(t){if(t.startsWith(`{${pe}`))return!0;const e=t.slice(0,Nn),n=e.indexOf(pe);return n>0&&e.lastIndexOf("{",n)===0}function ge(t){const e=[];for(const n of t){const s=n.trim();if(!(!s||me(s)))try{e.push(JSON.parse(s))}catch{}}return e}function he(t){return ge(t.split(`
|
|
7
|
+
`))}function ye(t){const e={sessionId:"",version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",branchedFrom:void 0};for(const n of t)if(n.sessionId&&!e.sessionId&&(e.sessionId=n.sessionId),n.version&&!e.version&&(e.version=n.version),n.gitBranch&&!e.gitBranch&&(e.gitBranch=n.gitBranch),n.cwd&&!e.cwd&&(e.cwd=n.cwd),n.slug&&!e.slug&&(e.slug=n.slug),n.name&&!e.name&&(e.name=n.name),n.branchedFrom&&!e.branchedFrom&&(e.branchedFrom=n.branchedFrom),Nt(n)&&n.message.model&&!e.model&&(e.model=n.message.model),e.sessionId&&e.version&&e.gitBranch&&e.cwd&&e.model)break;return e}function vn(t){return ye(ge(t))}function _e(t,e){const n=he(t),s=ye(n),o=de(n),i=e!=null&&e.skipStats?pt(o.length):mt(o);return{...s,turns:o,stats:i,rawMessages:e!=null&&e.skipStats?[]:n,agentKind:"claude"}}function ke(t,e){const n=he(e);if(n.length===0)return t;const s=t.rawMessages,o=[...s,...n],i=En(s),l=Math.max(0,t.turns.length-i.length);let d=Math.max(0,i.length-1);const f=new Set;for(const E of n)if(E.type==="progress"){const R=E.parentToolUseID;R&&f.add(R)}if(f.size>0)for(let E=d-1;E>=0;E--){const R=t.turns[l+E];if(R!=null&&R.toolCalls.some(P=>f.has(P.id))){d=E;break}}const u=i[d]??s.length,_=t.turns.slice(0,l+d),S=de(o.slice(u)),h=ce([..._,...S]),g=mt(h);return{sessionId:t.sessionId,version:t.version,gitBranch:t.gitBranch,cwd:t.cwd,slug:t.slug,name:t.name,model:t.model||h.length>0&&h[h.length-1].model||"",turns:h,stats:g,rawMessages:o,branchedFrom:t.branchedFrom,agentKind:t.agentKind}}const be="<task-notification>",Rn=/<task-id>([^<]+)<\/task-id>/g,Pn=/<tool-use-id>([^<]+)<\/tool-use-id>/g;function z(t){return typeof t=="object"&&t!==null}function Bn(t){const e=z(t.message)?t.message:null,n=e==null?void 0:e.content;return typeof n=="string"?[n]:Array.isArray(n)?n.filter(s=>z(s)&&typeof s.text=="string").map(s=>s.text):[]}function Un(t){const e=[],n=new Map,s=new Set,o=new Set;function i(d,f){n.has(d)||n.set(d,f)}function l(d,f,u){if(d.includes(be)){for(const _ of d.matchAll(Rn))i(_[1],f),u==null||u.add(_[1]);for(const _ of d.matchAll(Pn))i(_[1],f),u==null||u.add(_[1])}}for(const[d,f]of t.entries()){if(f.type==="user"){const u=z(f.toolUseResult)?f.toolUseResult:null;if((u==null?void 0:u.status)==="async_launched"){const _=z(f.message)?f.message:null,h=(Array.isArray(_==null?void 0:_.content)?_.content:[]).filter(k=>z(k)&&k.type==="tool_result").map(k=>k.tool_use_id),g=[u.agentId,u.taskId,...h].filter(k=>typeof k=="string"&&k.length>0),E=[u.description,u.workflowName,u.summary].find(k=>typeof k=="string"&&k.length>0)??"",R=h.find(k=>typeof k=="string"&&k.length>0),P=typeof f.timestamp=="string"?f.timestamp:void 0;g.length>0&&e.push({ids:g,launch:{agent:{description:E,startedAt:P,toolUseId:R},launchedAt:d}})}for(const _ of Bn(f))l(_,d,o);continue}if(f.type==="assistant"){const u=z(f.message)?f.message:null,_=Array.isArray(u==null?void 0:u.content)?u.content:[];for(const S of _){if(!z(S)||S.type!=="tool_use"||S.name!=="TaskStop")continue;const h=z(S.input)?S.input:null,g=(h==null?void 0:h.task_id)??(h==null?void 0:h.shell_id);typeof g=="string"&&i(g,d)}continue}if(f.type==="attachment"){const u=z(f.attachment)?f.attachment:null;typeof(u==null?void 0:u.prompt)=="string"&&l(u.prompt,d,o);continue}if(f.type==="queue-operation"&&typeof f.content=="string"){const u=f.operation;l(f.content,d,u==="enqueue"?s:o)}}return{launches:e.map(({ids:d,launch:f})=>{const u=d.flatMap(_=>n.get(_)??[]);return u.length>0?{...f,endedAt:Math.min(...u)}:f}),undeliveredNotifications:[...s].filter(d=>!o.has(d)).length}}function Dn(t){var l,d;let e=0,n=null,s=!1;function o(f,u){const _={status:f,pendingQueue:Math.max(0,e)};return u&&(_.toolName=u),_}function i(){return n??(n=Un(t))}for(let f=t.length-1;f>=0;f--){const u=t[f];if(u.type!=="queue-operation"){if(u.type==="progress"){const _=u.data;if((_==null?void 0:_.type)==="hook_progress"&&(_.decision??((l=_.hookSpecificOutput)==null?void 0:l.permissionDecision))==="defer")return o("deferred");break}break}}for(let f=t.length-1;f>=0;f--){const u=t[f];if(u.type==="queue-operation"){if(typeof u.content=="string"&&u.content.includes(be))continue;const _=u.operation;_==="enqueue"?e++:(_==="dequeue"||_==="remove")&&e--;continue}if(u.type==="attachment"){const _=z(u.attachment)?u.attachment:null;(_==null?void 0:_.commandMode)==="task-notification"&&(s=!0);continue}if(u.type==="assistant"){const _=u.message,S=_==null?void 0:_.stop_reason;if(S==="end_turn"){const h=i();if(s||h.undeliveredNotifications>0)return o("processing");const g=Mt(h.launches,Math.max(0,e));if(g)return g;let E=!1;for(let R=f-1;R>=0;R--){const P=t[R];if(P.type==="user"&&!P.isMeta){E=!0;break}}return o(E?"completed":"idle")}if(S==="tool_use"){const h=_==null?void 0:_.content,g=(d=h==null?void 0:h.findLast)==null?void 0:d.call(h,E=>E.type==="tool_use");return o("tool_use",g==null?void 0:g.name)}return o("thinking")}if(u.type==="user"){if(u.isMeta)continue;return o("processing")}if(u.type==="system"&&u.subtype==="terminal_reason"){const _=u.reason;if(_)return{status:"completed",terminalReason:_,pendingQueue:Math.max(0,e)};continue}u.type!=="summary"&&u.type==="system"&&u.subtype}return{status:"idle"}}function Fn(t,e,n){const s=typeof t.sessionId=="string"?t.sessionId:"";return{record:{...t,sessionId:e,branchedFrom:{sessionId:s,turnIndex:n}},originalId:s}}function $n(t){return ue(t).turnStartIndices}function Pt(t,e,n){if(!e)return;t.assistantText.push(e);const s=t.contentBlocks[t.contentBlocks.length-1];if((s==null?void 0:s.kind)==="text"){s.text.push(e);return}t.contentBlocks.push({kind:"text",text:[e],timestamp:n})}function Te(t){return t.includes("*** Begin Patch")&&t.includes("*** End Patch")}function On(t){if(!t.includes("apply_patch")||!t.includes("*** Begin Patch"))return[];const e=new Map;for(let l=0;l<t.length;l++){const d=Xt(t,l);if(d){if(Te(d.value)){const f=t.slice(0,l).match(/(?:^|[;\n])\s*(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*$/);f&&e.set(f[1],d.value)}l=d.endIndex-1}}const n=[],s=new Set,o=/\btools\s*\.\s*apply_patch\s*\(/g;let i;for(;(i=o.exec(t))!==null;){let l=i.index+i[0].length;for(;/\s/.test(t[l]??"");)l++;const d=Xt(t,l),f=d?null:t.slice(l).match(/^([A-Za-z_$][\w$]*)/),u=(d==null?void 0:d.value)??(f?e.get(f[1]):void 0);!u||!Te(u)||s.has(u)||(s.add(u),n.push(u))}return n}function Ce(t,e){if(!e||t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t))return t;const n=e.replace(/[\\/]+$/,""),s=t.replace(/^\.[\\/]/,"");return/^[A-Za-z]:[\\/]/.test(e)?`${n}\\${s.replace(/\//g,"\\")}`:`${n}/${s}`}function Ie(t,e,n,s=""){var f,u;const o=[],i=/^\*\*\*\s+(Update File|Add File|Delete File):\s*(.+)$/gm,l=[];let d;for(;(d=i.exec(t))!==null;)l.push({action:d[1],filePath:d[2].trim(),headerIdx:d.index,startIdx:d.index+d[0].length});for(let _=0;_<l.length;_++){const S=l[_],h=_+1<l.length?l[_+1].headerIdx:t.length,g=t.slice(S.startIdx,h),E=(u=(f=g.match(/^\*\*\*\s+Move to:\s*(.+)$/m))==null?void 0:f[1])==null?void 0:u.trim(),R=Ce(S.filePath,s),P=Ce(E||S.filePath,s),k=g.split(/^@@.*$/m).filter(O=>O.trim()),v=[],F=[];for(const O of k)for(const L of O.split(`
|
|
8
|
+
`))L.startsWith("-")?v.push(L.slice(1)):L.startsWith("+")?F.push(L.slice(1)):L.startsWith(" ")&&(v.push(L.slice(1)),F.push(L.slice(1)));const W=l.length>1?`${e}:file-${_}`:e;S.action==="Add File"?o.push({id:W,name:"Write",input:{file_path:P,content:F.join(`
|
|
9
|
+
`)},result:null,isError:!1,timestamp:n}):S.action==="Delete File"?o.push({id:W,name:"Edit",input:{file_path:P,old_string:v.join(`
|
|
10
|
+
`),new_string:""},result:null,isError:!1,timestamp:n}):o.push({id:W,name:"Edit",input:{file_path:P,...E?{old_path:R}:{},old_string:v.join(`
|
|
11
|
+
`),new_string:F.join(`
|
|
12
|
+
`)},result:null,isError:!1,timestamp:n})}return o}function jn(t,e,n,s,o=""){return t==="apply_patch"?Ie(e,n,s,o):On(e).flatMap((i,l)=>Ie(i,`${n}:patch-${l}`,s,o))}function Ln(t,e,n){var d;if(!e||!/(?:apply[_ ]patch|invalid patch|invalid context|failed to (?:apply|find)|could not apply)/i.test(t))return new Set;const s=new Map;for(const f of n){const u=(d=f.id.match(/:patch-(\d+)(?::file-\d+)?$/))==null?void 0:d[1];if(u===void 0)continue;const _=Number(u),S=s.get(_)??[];S.push(f),s.set(_,S)}if(s.size===0)return new Set(n.map(f=>f.id));const o=t.toLowerCase().replaceAll("\\","/"),i=new Set;for(const[f,u]of s)u.some(_=>{const S=String(_.input.file_path??"").toLowerCase().replaceAll("\\","/");if(!S)return!1;const g=S.split("/").filter(Boolean).slice(-2).join("/");return o.includes(S)||g.includes("/")&&o.includes(g)})&&i.add(f);for(const f of o.matchAll(/\bpatch\s*(?:#|-)?\s*(\d+)\b/g)){const u=Number(f[1]);s.has(u)&&i.add(u)}i.size===0&&i.add(Math.max(...s.keys()));const l=Math.min(...i);for(const f of s.keys())f>=l&&i.add(f);return new Set([...i].flatMap(f=>{var u;return((u=s.get(f))==null?void 0:u.map(_=>_.id))??[]}))}function J(t){return typeof t=="object"&&t!==null}const Wn=new Map([["spawn_agent","spawn_agent"],["spawnAgent","spawn_agent"],["wait_agent","wait_agent"],["waitAgent","wait_agent"],["send_message","send_message"],["sendMessage","send_message"],["followup_task","followup_task"],["followupTask","followup_task"],["list_agents","list_agents"],["listAgents","list_agents"],["interrupt_agent","interrupt_agent"],["interruptAgent","interrupt_agent"]]),qn=new Set(["exec","exec_command","write_stdin","apply_patch","update_plan","view_image","request_user_input","request_user_input_async","tool_search","list_mcp_resources","list_mcp_resource_templates","read_mcp_resource","request_plugin_install","create_goal","get_goal","update_goal","wait"]);function Q(t){if(t.startsWith("mcp__"))return t;const e=t.split(/(?:__|[.:/])+/).filter(Boolean).at(-1)??t;return Wn.get(e)??(qn.has(e)?e:t)}function zn(t){const e=t==null?void 0:t.match(/Process exited with code (\d+)/);return e?e[1]!=="0":!1}function Jn(t){return t==="request_user_input"||t==="request_user_input_async"}function Vn(t){const n=(Array.isArray(t.questions)?t.questions:[t]).filter(s=>J(s)).map(s=>{const o=typeof s.question=="string"?s.question:typeof s.title=="string"?s.title:"",i=Array.isArray(s.options)?s.options:[];return{question:o,...typeof s.header=="string"&&s.header?{header:s.header}:{},options:i.map(l=>typeof l=="string"?{label:l}:!J(l)||typeof l.label!="string"?null:{label:l.label,...typeof l.description=="string"&&l.description?{description:l.description}:{}}).filter(l=>l!==null)}}).filter(s=>s.question);return n.length>0?{...t,questions:n}:t}function Hn(t){return{todos:(Array.isArray(t.plan)?t.plan:[]).filter(s=>J(s)).map(s=>({content:typeof s.step=="string"?s.step:"",status:typeof s.status=="string"?s.status:"pending",activeForm:typeof s.step=="string"?s.step:""}))}}function Gn(t){if(t.type!=="image"&&t.type!=="input_image"&&t.type!=="image_url")return null;const e=J(t.source)?t.source:t,n=e.media_type??e.mimeType;if(typeof n=="string"&&n.startsWith("image/")&&typeof e.data=="string"&&e.data)return{type:"image",source:{type:"base64",media_type:n,data:e.data}};const s=J(t.image_url)?t.image_url.url:t.image_url,o=typeof s=="string"?/^data:(image\/[^;,]+);base64,(.+)$/is.exec(s):null;return o?{type:"image",source:{type:"base64",media_type:o[1].toLowerCase(),data:o[2]}}:null}function xe(t){if(typeof t=="string")return{parts:[t],text:t,images:[]};if(!Array.isArray(t)){const s=t==null?"":JSON.stringify(t);return{parts:[s],text:s,images:[]}}const e=[],n=[];for(const s of t){if(!J(s))continue;typeof s.text=="string"&&e.push(s.text);const o=Gn(s);o&&n.push(o)}return{parts:e,text:e.join(""),images:n}}const Kn=/^Script (?:completed|failed|running)\b/;function Ae(t,e){J(t)&&(t.status==="rejected"?e.push(1):t.status==="fulfilled"?Ae(t.value,e):typeof t.exit_code=="number"&&e.push(t.exit_code))}function Qn(t){const e=t[0]??"";if(!Kn.test(e))return;if(e.startsWith("Script failed"))return!0;const n=[];for(const s of t.slice(1)){let o;try{o=JSON.parse(s)}catch{continue}for(const i of Array.isArray(o)?o:[o])Ae(i,n)}return n.length>0?n.some(s=>s!==0):void 0}function Bt(t){const e=xe(t);let n=J(t)&&!Array.isArray(t)?t:null;try{const u=n??JSON.parse(e.text);J(u)&&!Array.isArray(u)&&(n=u)}catch{}const s=n&&("output"in n||"content"in n)?xe(n.output??n.content):e,o=s===e?e.images:[...e.images,...s.images],i=J(n==null?void 0:n.metadata)?n.metadata:null,l=(i==null?void 0:i.exit_code)??(n==null?void 0:n.exit_code),d=typeof(n==null?void 0:n.isError)=="boolean"?n.isError:typeof(n==null?void 0:n.is_error)=="boolean"?n.is_error:void 0,f=d===!0||(typeof l=="number"?l!==0:d??Qn(e.parts)??zn(s.text));return{text:s.text,isError:f,...o.length>0?{images:o}:{}}}const Zn=["# AGENTS.md instructions for ","<recommended_plugins>","<environment_context>","<permissions instructions>","<collaboration_mode>","<skills_instructions>"];function Xn(t){var e,n;return((n=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:n.call(e))??`${t}-${Math.random().toString(36).slice(2,10)}`}function nt(t){try{return JSON.parse(t)}catch{return null}}function U(t){return typeof t=="object"&&t!==null}function Yn(t){const e=U(t.source)?t.source:null,n=e&&U(e.subagent)?e.subagent:null,s=n&&U(n.thread_spawn)?n.thread_spawn:null;for(const o of[t.forked_from_id,t.parent_thread_id,s==null?void 0:s.parent_thread_id])if(typeof o=="string"&&o)return o;return null}function Ut(t){var o;const e=t.find(i=>(i==null?void 0:i.type)==="session_meta"),n=(o=e==null?void 0:e.payload)==null?void 0:o.subagent_history_start_ordinal;if(typeof n!="number")return null;const s=i=>typeof i=="number"&&i>=n;return!s(e==null?void 0:e.rolloutLastOrdinal)&&!t.some(i=>s(i==null?void 0:i.ordinal))?null:i=>typeof i.ordinal=="number"&&i.ordinal>0&&i.ordinal<n}async function ts(t,e){var o;if(!t.includes('"subagent_history_start_ordinal"'))return t;const n=nt(t);if((n==null?void 0:n.type)!=="session_meta")return t;const s=await e();for(let i=s.length-1;i>=0;i--){const l=(o=nt(s[i]))==null?void 0:o.ordinal;if(typeof l=="number")return JSON.stringify({...n,rolloutLastOrdinal:l})}return t}function es(t){const e=t.payload;return t.type!=="event_msg"||!U(e)?null:e.type==="sub_agent_activity"?e:e.type==="item_completed"&&U(e.item)&&e.item.type==="SubAgentActivity"?e.item:null}function Se(t){const e=es(t);return!e||typeof e.agent_thread_id!="string"||typeof e.agent_path!="string"?null:{agentId:e.agent_thread_id,agentPath:e.agent_path,kind:typeof e.kind=="string"?e.kind:"started",eventId:it(e.event_id,e.id)??"",model:it(e.model)||null,effort:it(e.reasoning_effort)||null}}function ns(t){return t.type!=="task_complete"||!U(t.error)?"":typeof t.error.message=="string"?t.error.message.trim():""}function Z(t){return!t||typeof t.type!="string"?!1:t.type==="session_meta"||t.type==="turn_context"||t.type==="event_msg"||t.type==="response_item"||t.type==="inter_agent_communication_metadata"||t.type==="compacted"||t.type==="world_state"}function _t(t,e){const n=t==null?void 0:t.content;return Array.isArray(n)?n.filter(s=>U(s)&&s.type===e&&typeof s.text=="string").map(s=>s.text).join(`
|
|
13
|
+
`).trim():""}const ss=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.+)$/is,os=/^data:(audio\/(?:wav|x-wav|mpeg|mp4|webm|ogg));base64,(.+)$/is;function we(t){if(typeof t!="string")return null;const e=ss.exec(t);return!(e!=null&&e[1])||!e[2]?null:{type:"image",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function Me(t){if(typeof t!="string")return null;const e=os.exec(t);return!(e!=null&&e[1])||!e[2]?null:{type:"audio",source:{type:"base64",media_type:e[1].toLowerCase(),data:e[2]}}}function is(t){return Array.isArray(t.images)?t.images.map(we).filter(e=>e!==null):[]}function rs(t){return Array.isArray(t.audio)?t.audio.map(Me).filter(e=>e!==null):[]}function Ee(t){return Array.isArray(t.content)?t.content.filter(e=>U(e)&&e.type==="input_image").map(e=>we(e.image_url)).filter(e=>e!==null):[]}function Ne(t){return Array.isArray(t.content)?t.content.filter(e=>U(e)&&e.type==="input_audio").map(e=>Me(e.audio_url)).filter(e=>e!==null):[]}function ve(t,e,n=[],s=[],o=[]){const i=[...s.map(d=>`
|
|
14
|
+
`),...o.map(d=>`
|
|
15
|
+
[audio attachment](<${d}>)`)].join(""),l=t+i;return e.length===0&&n.length===0?l:[...e,...n,...l?[{type:"text",text:l}]:[]]}function as(t){var l,d;const e=_t(t,"input_text");if(!e)return{messageType:null,text:""};const n=e.match(/\r?\nPayload:\s*(?:\r?\n|$)/);if(!e.startsWith("Message Type:")||!n||n.index===void 0)return{messageType:null,text:e.trim()};const o=((d=(l=e.slice(0,n.index).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:l[1])==null?void 0:d.trim().toUpperCase())??null,i=e.slice(n.index+n[0].length).trim();return{messageType:o,text:i}}function st(t){return t.split(/[\\/]/).filter(Boolean).at(-1)??null}function ls(t){if(typeof t!="string")return"";const e=t.trim();return/^gAAAAA[A-Za-z0-9_-]+$/.test(e)?"":e}function Dt(t){const e=t.trim();return!e||Zn.some(n=>e.startsWith(n))?"":e}function cs(t){if(!U(t))return null;const e=typeof t.input_tokens=="number"?t.input_tokens:0,n=typeof t.output_tokens=="number"?t.output_tokens:0,s=typeof t.cache_write_input_tokens=="number"?t.cache_write_input_tokens:typeof t.cache_creation_input_tokens=="number"?t.cache_creation_input_tokens:0,o=typeof t.cached_input_tokens=="number"?Math.max(0,t.cached_input_tokens):null,i=o??(typeof t.cache_read_input_tokens=="number"?t.cache_read_input_tokens:0),l=o===null?e:Math.max(0,e-o);return l===0&&n===0&&s===0&&i===0?null:{input_tokens:l,output_tokens:n,cache_creation_input_tokens:s,cache_read_input_tokens:i}}function us(t,e,n){if(!e)return;const s={type:"thinking",thinking:e,signature:""};t.thinking.push(s);const o=t.contentBlocks[t.contentBlocks.length-1];if(o&&o.kind==="thinking"){o.blocks.push(s);return}t.contentBlocks.push({kind:"thinking",blocks:[s],timestamp:n})}function X(t,e,n){t.toolCalls.push(e);const s=t.contentBlocks[t.contentBlocks.length-1];if(s&&s.kind==="tool_calls"&&s.timestamp===n){s.toolCalls.push(e);return}t.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:n})}function ds(t,e,n){if(!e||!(e.userMessage!==null||e.assistantText.length>0||e.toolCalls.length>0||e.thinking.length>0||e.subAgentActivity.length>0))return null;if(e.timestamp&&n){const o=new Date(e.timestamp).getTime(),i=new Date(n).getTime();Number.isFinite(o)&&Number.isFinite(i)&&i>=o&&(e.durationMs=i-o)}return t.push(e),null}function Re(t){if(typeof t!="string"||!t.trim())return{};try{const e=JSON.parse(t);return U(e)?e:{value:e}}catch{return{raw:t}}}function ot(t){if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t??"")}}function it(...t){return t.find(e=>typeof e=="string")}function fs(t){return t.startsWith("exec-")}function ps(t){var o;if(!U(t))return{text:ot(t),isError:!1};if("Err"in t)return{text:ot(t.Err),isError:!0};const e=U(t.Ok)?t.Ok:null;if(!e)return{text:ot(t),isError:!1};const n=Bt({...e,content:e.content}),s=n.text||((o=n.images)!=null&&o.length?"":e.structuredContent!==void 0?ot(e.structuredContent):ot(e));return{...n,text:s,isError:n.isError}}function ms(t,e,n){return{id:t?`${t}@${e}`:Xn("codex-turn"),userMessage:null,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:n}}function Ft(t){const e=U(t.payload)?t.payload:null;return t.type==="event_msg"&&(e==null?void 0:e.type)==="user_message"&&typeof e.message=="string"?Dt(e.message):t.type==="response_item"&&(e==null?void 0:e.type)==="message"&&e.role==="user"?Dt(_t(e,"input_text")):""}function gs(){let t=!1;return e=>{const n=U(e.payload)?e.payload:null;if(e.type==="event_msg"&&(n==null?void 0:n.type)==="user_message"){const o=t;return t=!1,o?"":Ft(e)}if(e.type!=="response_item")return"";const s=Ft(e);return s?t=!0:((n==null?void 0:n.type)!=="message"||n.role!=="user")&&(t=!1),s}}function hs(t,e){if(t.type==="session_meta"||t.type==="event_msg"&&(e==null?void 0:e.type)==="task_started")return!1;if(t.type==="response_item"&&(e==null?void 0:e.type)==="message"){if(e.role==="developer"||e.role==="system")return!1;if(e.role==="user")return Ft(t)!==""||Ee(e).length>0||Ne(e).length>0}return!0}function Pe(t){let e="",n="",s="",o="",i="",l,d="",f="",u="",_="",S=0,h=!1,g=null,E="/root";const R=gs(),P=Ut(t);for(const k of t){if(!U(k.payload)||P!=null&&P(k))continue;if(k.type==="session_meta"){if(e||(e=typeof k.payload.id=="string"?k.payload.id:""),n||(n=typeof k.payload.cli_version=="string"?k.payload.cli_version:""),o||(o=typeof k.payload.cwd=="string"?k.payload.cwd:""),!l&&U(k.payload.branchedFrom)){const O=typeof k.payload.branchedFrom.sessionId=="string"?k.payload.branchedFrom.sessionId:"";O&&(l={sessionId:O,turnIndex:typeof k.payload.branchedFrom.turnIndex=="number"?k.payload.branchedFrom.turnIndex:null})}const F=U(k.payload.source)?k.payload.source:null;if(F&&U(F.subagent)){h=!0;const O=U(F.subagent.thread_spawn)?F.subagent.thread_spawn:null;O&&typeof O.agent_path=="string"&&(E=O.agent_path)}g=Yn(k.payload)??g;const W=U(k.payload.git)?k.payload.git:null;s||(s=W&&typeof W.branch=="string"?W.branch:"")}k.type==="turn_context"&&(i||(i=typeof k.payload.model=="string"?k.payload.model:""),o||(o=typeof k.payload.cwd=="string"?k.payload.cwd:""));const v=R(k);v&&(d||(d=v),f=v,S++,u||(u=k.timestamp??""),_=k.timestamp??_)}return _===""&&(_=u),{sessionId:e,version:n,gitBranch:s,cwd:o,model:i,slug:"",name:"",branchedFrom:l,firstUserMessage:d,lastUserMessage:f,timestamp:u,lastTimestamp:_,turnCount:S,isSubagent:h,parentSessionId:g,agentPath:E}}function ys(t){for(const e of t.split(`
|
|
16
|
+
`)){const n=e.trim();if(n)return Z(nt(n))}return!1}function _s(t){return Z(t[0]??null)}function ks(t){const e=t.map(nt).filter(Z);return Pe(e)}function Be(t,e){const n=Pe(t.filter(Z)),s=[],o=new Map,i=new Map,l=new Map,d=new Map,f=new Map,u=new Map,_=new Map,S=new Map;function h(p,T,a,C={}){const w=f.get(p);let m=S.get(p);if(!m){const y={agentId:p,parentToolUseId:(w==null?void 0:w.parentToolCallId)||void 0,agentName:(w==null?void 0:w.nickname)??(w!=null&&w.agentPath?st(w.agentPath):null),subagentType:(w==null?void 0:w.agentType)??null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:(w==null?void 0:w.timestamp)??a,tokenUsage:null,model:(w==null?void 0:w.model)??null,...w!=null&&w.effort?{effort:w.effort}:{},isBackground:!1,prompt:(w==null?void 0:w.message)||void 0,status:C.status??"running"};T.subAgentActivity.push(y);const N=T.contentBlocks[T.contentBlocks.length-1];(N==null?void 0:N.kind)==="sub_agent"?N.messages.push(y):T.contentBlocks.push({kind:"sub_agent",messages:[y],timestamp:a}),m={message:y,turn:T},S.set(p,m)}const I=m.message;if(w&&(I.parentToolUseId=w.parentToolCallId||I.parentToolUseId,I.agentName=w.nickname??(w.agentPath?st(w.agentPath):I.agentName),I.subagentType=w.agentType,I.model=w.model,w.effort&&(I.effort=w.effort),I.prompt=w.message||I.prompt),C.text&&!I.text.includes(C.text)&&(I.text.push(C.text),I.content=I.text.join(`
|
|
17
|
+
|
|
18
|
+
`)),C.status){const y=new Set(["completed","failed","interrupted"]);if(C.status==="running"&&I.status&&y.has(I.status)||(I.status=C.status),y.has(C.status)&&I.timestamp&&a){const N=new Date(I.timestamp).getTime(),M=new Date(a).getTime();Number.isFinite(N)&&Number.isFinite(M)&&M>=N&&(I.durationMs=M-N)}}return I}let g=null,E=null,R=n.model||null,P="",k=null,v=!1;const F=[];let W=0,O=null,L=null;function x(p){const T=s.length,a=ds(s,p,P);return s.length>T&&L!==null&&F.push(L),L=null,a}function r(p,T,a){const C=ms(p,T,a);return L=O??W,O=null,v||(C.isFragment=!0),k&&(C.compactionSummary=k,k=null),C}function c(p,T,a,C,w){const m=i.get(T);if(m){m.input={...m.input,...a},m.result=C,m.isError=C==="failed";return}const I={id:T,name:"WebSearch",input:a,result:C,isError:C==="failed",timestamp:w};i.set(T,I),X(p,I,w)}const b=Ut(t);for(let p=0;p<t.length;p++){const T=t[p];if(!Z(T)||b!=null&&b(T))continue;W=p;const a=U(T.payload)?T.payload:void 0,C=T.timestamp??"";if(T.type==="compacted"){g=x(g),k="Conversation compacted",P=C;continue}if(T.type==="world_state")continue;if(T.type==="turn_context"){g=x(g),O=p,E=typeof(a==null?void 0:a.turn_id)=="string"?a.turn_id:null,R=typeof(a==null?void 0:a.model)=="string"?a.model:R,P=C,v=!0;continue}if(T.type==="event_msg"&&(a==null?void 0:a.type)==="user_message"&&typeof a.message=="string"){g&&(g.assistantText.length>0||g.toolCalls.length>0||g.thinking.length>0)&&(g=x(g)),v=!0,g??(g=r(E,C,R));const m=(Array.isArray(a.local_images)?a.local_images:[]).filter(y=>typeof y=="string"&&y.length>0),I=(Array.isArray(a.local_audio)?a.local_audio:[]).filter(y=>typeof y=="string"&&y.length>0);g.userMessage=ve(a.message,is(a),rs(a),m,I),g.isFragment=!1,g.timestamp=g.timestamp||C,P=C;continue}if(!g&&!hs(T,a))continue;if(g??(g=r(E,C,R)),!g.model&&R&&(g.model=R),g.timestamp||(g.timestamp=C),C&&(P=C),T.type==="event_msg"&&(a==null?void 0:a.type)==="token_count"){const m=U(a.info)?a.info:null,I=m?cs(m.last_token_usage):null;I&&(g.tokenUsage=K(g.tokenUsage,I));continue}if(T.type==="event_msg"&&(a==null?void 0:a.type)==="web_search_end"&&typeof a.call_id=="string"){const m={};typeof a.query=="string"&&a.query&&(m.query=a.query),U(a.action)&&(m.action=a.action),c(g,a.call_id,m,"completed",C);continue}if(T.type==="event_msg"&&(a==null?void 0:a.type)==="mcp_tool_call_end"&&typeof a.call_id=="string"&&U(a.invocation)){const m=a.invocation,I=typeof m.server=="string"?m.server:"mcp",y=typeof m.tool=="string"?m.tool:"tool",N=U(m.arguments)?m.arguments:{},M=ps(a.result),B=o.get(a.call_id);B?(B.result=M.text,B.isError=M.isError,M.images&&(B.resultImages=M.images),o.delete(a.call_id)):fs(a.call_id)||X(g,{id:a.call_id,name:`mcp__${I}__${y}`,input:N,result:M.text,isError:M.isError,...M.images?{resultImages:M.images}:{},timestamp:C},C);continue}if(T.type==="event_msg"&&a){const m=ns(a);if(m){Pt(g,m,C);continue}}const w=Se(T);if(w){const{agentId:m,agentPath:I,eventId:y,kind:N}=w,M=y?d.get(y):void 0,B=u.get(I),D=f.get(m)??(B?f.get(B):void 0);if(N!=="started"&&!D&&!M)continue;if(B&&B!==m&&!S.has(m)){const V=S.get(B);V&&(V.message.agentId=m,S.delete(B),S.set(m,V)),f.delete(B)}const j={agentId:m,nickname:(D==null?void 0:D.nickname)??st(I)??(M==null?void 0:M.taskName)??null,agentPath:I,message:(D==null?void 0:D.message)??(M==null?void 0:M.message)??"",model:w.model??(D==null?void 0:D.model)??(M==null?void 0:M.model)??null,effort:w.effort??(D==null?void 0:D.effort)??null,agentType:(D==null?void 0:D.agentType)??(M==null?void 0:M.agentType)??null,timestamp:(D==null?void 0:D.timestamp)??(C||(M==null?void 0:M.timestamp)||""),parentToolCallId:(D==null?void 0:D.parentToolCallId)??y};f.set(m,j),u.set(I,m),y&&(N==="started"||M)&&_.set(y,m),h(m,g,C,{status:N==="interrupted"||N==="completed"?N:"running"});continue}if(!(T.type!=="response_item"||!a)){if(a.type==="reasoning"){const m=Array.isArray(a.summary)?a.summary.filter(I=>typeof I=="string").join(`
|
|
19
|
+
`):"";us(g,m.trim(),C);continue}if(a.type==="message"&&a.role==="assistant"){Pt(g,_t(a,"output_text"),C);continue}if(a.type==="message"&&a.role==="user"&&g.userMessage===null){const m=Dt(_t(a,"input_text")),I=Ee(a),y=Ne(a);(m||I.length>0||y.length>0)&&(g.userMessage=ve(m,I,y),g.isFragment=!1,v=!0);continue}if(a.type==="web_search_call"&&typeof a.id=="string"){const m={};U(a.action)&&(m.action=a.action);const I=typeof a.status=="string"?a.status:"completed";c(g,a.id,m,I,C);continue}if(a.type==="tool_search_call"){const m=it(a.call_id,a.id)??"";if(m){const I={id:m,name:"ToolSearch",input:U(a.arguments)?a.arguments:{},result:null,isError:!1,timestamp:C};o.set(m,I),X(g,I,C)}continue}if(a.type==="tool_search_output"&&typeof a.call_id=="string"){const m=o.get(a.call_id);if(m){const I=Array.isArray(a.tools)?a.tools:[],y=I.filter(U).map(B=>it(B.name)??"").filter(Boolean),N=y.length>0?y.length:I.length,M=`Found ${N} tool${N===1?"":"s"}`;m.result=y.length>0?`${M}: ${y.join(", ")}`:M,m.isError=a.status==="failed",o.delete(a.call_id)}continue}if(a.type==="agent_message"&&typeof a.author=="string"){const m=a.author,I=typeof a.recipient=="string"?a.recipient:null,y=as(a);if(y.messageType==="NEW_TASK")continue;const N=u.get(m),M=m.startsWith(`${n.agentPath}/`)&&(I===null||I===n.agentPath);if(!N&&!M)continue;const B=N??m;N||(f.set(B,{agentId:B,nickname:st(m),agentPath:m,message:"",model:null,agentType:null,timestamp:C,parentToolCallId:""}),u.set(m,B));let D;y.messageType==="FINAL_ANSWER"?D="completed":y.messageType==="ERROR"||y.messageType==="FAILED"?D="failed":y.messageType==="INTERRUPTED"?D="interrupted":y.messageType==="MESSAGE"&&(D="running"),h(B,g,C,{status:D,text:y.text||void 0});continue}if(a.type==="function_call"&&typeof a.call_id=="string"){const m=typeof a.name=="string"?a.name:"tool",I=Q(m),y=Re(a.arguments);let N=I,M=y;I==="exec_command"?N="Bash":I==="update_plan"?(N="TodoWrite",M=Hn(y)):Jn(I)&&(N="AskUserQuestion",M=Vn(y)),I==="spawn_agent"&&d.set(a.call_id,{callId:a.call_id,message:ls(y.message),taskName:typeof y.task_name=="string"?y.task_name:null,model:typeof y.model=="string"?y.model:null,agentType:typeof y.agent_type=="string"?y.agent_type:null,timestamp:C});const B={id:a.call_id,name:N,input:M,result:null,isError:!1,timestamp:C,...I==="request_user_input_async"?{asyncQuestion:!0}:{}};o.set(B.id,B),X(g,B,C);continue}if(a.type==="function_call_output"&&typeof a.call_id=="string"){const m=o.get(a.call_id);if(!m)continue;const I=Bt(a.output),y=I.text;if(m.result=y,m.isError=I.isError,I.images&&(m.resultImages=I.images),o.delete(a.call_id),m.name==="spawn_agent"&&y)try{const N=JSON.parse(y),M=typeof N.agent_id=="string"?N.agent_id:_.get(m.id)??"",B=typeof N.task_name=="string"?N.task_name:null,D=typeof N.nickname=="string"?N.nickname:B?st(B):null;if(M){const j=d.get(m.id),$=f.get(M),V={agentId:M,nickname:D??($==null?void 0:$.nickname)??(j==null?void 0:j.taskName)??null,agentPath:B??($==null?void 0:$.agentPath)??null,message:($==null?void 0:$.message)??(j==null?void 0:j.message)??"",model:($==null?void 0:$.model)??(j==null?void 0:j.model)??null,effort:($==null?void 0:$.effort)??null,agentType:($==null?void 0:$.agentType)??(j==null?void 0:j.agentType)??null,timestamp:($==null?void 0:$.timestamp)??(j==null?void 0:j.timestamp)??C,parentToolCallId:($==null?void 0:$.parentToolCallId)??m.id};f.set(M,V),_.set(m.id,M),V.agentPath&&u.set(V.agentPath,M),h(M,g,C,{status:"running"})}}catch{}if(m.name==="wait_agent"&&y&&g)try{const N=JSON.parse(y),M=U(N.status)?N.status:{};for(const[B,D]of Object.entries(M)){const j=U(D)?D:{},$=typeof j.completed=="string"?j.completed:"",V=typeof j.failed=="string"?j.failed:typeof j.error=="string"?j.error:"",tn=typeof j.interrupted=="string"?j.interrupted:"",Ys=$?"completed":V?"failed":tn?"interrupted":typeof j.status=="string"?j.status:"running";f.has(B)||f.set(B,{agentId:B,nickname:null,agentPath:null,message:"",model:null,agentType:null,timestamp:C,parentToolCallId:""}),h(B,g,C,{status:Ys,text:$||V||tn||void 0})}}catch{}continue}if(a.type==="custom_tool_call"&&typeof a.call_id=="string"){const m=Q(typeof a.name=="string"?a.name:"tool"),I=typeof a.input=="string"?a.input:"",y=a.call_id,N=I?jn(m,I,y,C,n.cwd):[];if(m!=="apply_patch"){const M={id:y,name:m==="exec_command"?"Bash":m,input:Re(I),result:null,isError:!1,timestamp:C};o.set(M.id,M),X(g,M,C)}for(const M of N)o.set(M.id,M),X(g,M,C);N.length>0&&l.set(y,{calls:N,direct:m==="apply_patch"});continue}if(a.type==="custom_tool_call_output"&&typeof a.call_id=="string"){const m=a.call_id,{text:I,isError:y,images:N}=Bt(a.output),M=l.get(m);if(M){const D=M.direct&&y?new Set(M.calls.map(j=>j.id)):Ln(I,y,M.calls);for(const j of M.calls){const $=o.get(j.id);$&&($.result=I,$.isError=D.has($.id),o.delete($.id))}l.delete(m)}const B=o.get(m);B&&(B.result=I,B.isError=y,N&&(B.resultImages=N),o.delete(m));continue}}}return x(g),{turnStartIndices:F,sessionId:n.sessionId,version:n.version,gitBranch:n.gitBranch,cwd:n.cwd,slug:n.slug,name:"",model:n.model,turns:s,stats:e!=null&&e.skipStats?pt(s.length):mt(s),rawMessages:e!=null&&e.skipStats?[]:t,branchedFrom:n.branchedFrom,agentKind:"codex"}}function Ue(t,e){const n=t.split(`
|
|
20
|
+
`).map(d=>d.trim()).filter(Boolean).map(nt).filter(Z),s=Ut(n),o=s?n.filter(d=>!s(d)):n,{turnStartIndices:i,...l}=Be(o,e);return l}function bs(t,e){const n=t.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
21
|
+
`);return Ue(n?`${n}
|
|
22
|
+
${e}`:e)}const Ts=new Set(["FINAL_ANSWER","ERROR","FAILED","INTERRUPTED"]);function Cs(t){const e=t.content;return Array.isArray(e)?e.filter(n=>U(n)&&n.type==="input_text"&&typeof n.text=="string").map(n=>n.text).join(`
|
|
23
|
+
`):""}function kt(t){if(typeof t!="string")return null;try{const e=JSON.parse(t);return U(e)?e:null}catch{return null}}function Is(t){var _,S;const e=new Map,n=new Set,s=new Map,o=new Map,i=new Map,l=new Set,d=new Map;function f(h,g,E,R){if(s.has(h))return;n.add(h);const P=e.get(h);P?P.description||(P.description=g):e.set(h,{launchedAt:E,description:g,startedAt:R})}function u(h,g){s.has(h)||s.set(h,g),n.delete(h)}for(const[h,g]of t.entries()){const E=U(g.payload)?g.payload:null;if(!E)continue;const R=typeof g.timestamp=="string"?g.timestamp:void 0,P=Se(g);if(P){const{agentId:k,agentPath:v,kind:F,eventId:W}=P,O=o.get(v),L=n.has(k)||s.has(k)||O!==void 0||i.has(W);if(F!=="started"&&!L)continue;if(O&&O!==k){const x=e.get(O);e.delete(O);const r=e.get(k);x&&!r?e.set(k,x):x&&r&&!r.description&&(r.description=x.description),n.delete(O)&&f(k,"",h,R);const c=s.get(O);c!==void 0&&u(k,c)}o.set(v,k),F==="interrupted"||F==="completed"?u(k,h):f(k,i.get(W)??"",h,R);continue}if(g.type==="response_item"){if(E.type==="function_call"&&typeof E.call_id=="string"){const k=Q(typeof E.name=="string"?E.name:"");if(k==="spawn_agent"){const v=kt(E.arguments);i.set(E.call_id,typeof(v==null?void 0:v.task_name)=="string"?v.task_name:"")}else if(k==="wait_agent")l.add(E.call_id);else if(k==="interrupt_agent"){const v=kt(E.arguments),F=[v==null?void 0:v.agent_id,...Array.isArray(v==null?void 0:v.agent_ids)?v.agent_ids:[]].filter(W=>typeof W=="string");d.set(E.call_id,F)}continue}if(E.type==="function_call_output"&&typeof E.call_id=="string"){const k=E.call_id;if(i.has(k)){const v=kt(E.output),F=typeof(v==null?void 0:v.agent_id)=="string"?v.agent_id:"";if(F){f(F,i.get(k)??"",h,R);const W=typeof(v==null?void 0:v.task_name)=="string"?v.task_name:"";W&&!o.has(W)&&o.set(W,F)}}else if(l.has(k)){const v=kt(E.output),F=U(v==null?void 0:v.status)?v.status:{};for(const[W,O]of Object.entries(F)){const L=U(O)?O:{},x=typeof L.status=="string"?L.status:"";(typeof L.completed=="string"||typeof L.failed=="string"||typeof L.error=="string"||typeof L.interrupted=="string"||x==="completed"||x==="failed"||x==="interrupted")&&u(W,h)}}else if(d.has(k))for(const v of d.get(k)??[])u(v,h);continue}if(E.type==="agent_message"&&typeof E.author=="string"){const v=((S=(_=Cs(E).match(/^Message Type:\s*([^\r\n]+)/))==null?void 0:_[1])==null?void 0:S.trim().toUpperCase())??"";if(!Ts.has(v))continue;u(o.get(E.author)??E.author,h)}}}return[...e.entries()].map(([h,{description:g,startedAt:E,launchedAt:R}])=>({agent:{description:g,startedAt:E},launchedAt:R,endedAt:n.has(h)?void 0:s.get(h)??R}))}function xs(t){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n.type==="event_msg"){const s=n.payload;switch(s==null?void 0:s.type){case"task_complete":return Mt(Is(t))??{status:"completed"};case"task_started":return{status:"processing"};case"agent_message":return{status:"thinking"};case"token_count":continue}}if(n.type==="response_item"){const s=n.payload;if(!s)continue;if(s.type==="function_call")return{status:"tool_use",toolName:s.name?Q(s.name):s.name};if(s.type==="message"){if(s.role==="assistant")return{status:"thinking"};if(s.role==="user")return{status:"processing"}}}}return{status:"idle"}}function As(t,e,n,s){const o=U(t.payload)?{...t.payload}:{},i=typeof o.id=="string"?o.id:"";return o.id=e,o.branchedFrom={sessionId:i,turnIndex:n,at:new Date(s).toISOString()},{record:{...t,payload:o},originalId:i}}function Ss(t){return Be(t,{skipStats:!0}).turnStartIndices}const ws=/^(?:assistant|auto_mode|auto_mode_switch|background_tasks|canvas|command|custom|elicitation|exit_plan_mode|extensions|external_tool|factory|hook|managed_settings|mcp|model|pending_messages|permission|sampling|session|skill|subagent|system|tool|ui|user_input)\./;function q(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function De(t){return typeof t.agentId!="string"||t.agentId.length===0}function Fe(t){return!q(t)||typeof t.type!="string"||!q(t.data)?!1:t.type==="abort"||t.type==="binary_asset"||t.type==="user.message"||ws.test(t.type)}function $e(t){try{const e=JSON.parse(t);return Fe(e)?e:null}catch{return null}}function Ms(t){return t.split(`
|
|
24
|
+
`).map(e=>e.trim()).filter(Boolean).map($e).filter(e=>e!==null)}function A(...t){return t.find(e=>typeof e=="string")??""}function H(t){return typeof t=="number"&&Number.isFinite(t)?t:0}function rt(t){return typeof t.timestamp=="string"?t.timestamp:""}function G(t,e){var n,s;return typeof t.id=="string"&&t.id?t.id:((s=(n=globalThis.crypto)==null?void 0:n.randomUUID)==null?void 0:s.call(n))??`${e}-${Math.random().toString(36).slice(2,10)}`}function Oe(t){const e=G(t,"copilot-turn"),n=A(t.data.turnId);return n?`${n}@${e}`:e}function $t(t,e){if(!q(t))return;const n=A(t.cwd),s=A(t.branch);n&&(e.cwd=n),s&&(e.gitBranch=s)}function je(t){const e={sessionId:"",version:"",gitBranch:"",cwd:"",model:"",slug:"",name:"",firstUserMessage:"",lastUserMessage:"",timestamp:"",lastTimestamp:"",turnCount:0,isSubagent:!1,parentSessionId:null};for(const n of t){if(!De(n))continue;const{data:s}=n,o=rt(n);if(o&&(e.lastTimestamp=o),n.type==="session.start"){e.sessionId||(e.sessionId=A(s.sessionId)),e.version||(e.version=A(s.copilotVersion)||(typeof s.version=="number"?String(s.version):A(s.version))),$t(s.context,e),e.model=A(s.selectedModel)||e.model;continue}if(n.type==="session.resume"){$t(s.context,e),e.model=A(s.selectedModel)||e.model;continue}if(n.type==="session.context_changed"){$t(s,e);continue}if(n.type==="session.auto_mode_resolved"){e.model=A(s.chosenModel)||e.model;continue}if(n.type==="session.model_change"){e.model=A(s.newModel)||e.model;continue}if(n.type==="session.title_changed"){e.name=A(s.title)||e.name;continue}if(n.type==="session.shutdown"){e.model=A(s.currentModel)||e.model;continue}if((n.type==="assistant.turn_start"||n.type==="assistant.turn_end"||n.type==="assistant.message"||n.type==="assistant.usage"||n.type==="tool.execution_start"||n.type==="tool.execution_complete")&&(e.model=A(s.model)||e.model),n.type!=="user.message")continue;e.turnCount++,e.timestamp||(e.timestamp=o);const i=A(s.content).trim();i&&(e.firstUserMessage||(e.firstUserMessage=i),e.lastUserMessage=i)}return e.lastTimestamp||(e.lastTimestamp=e.timestamp),e}function Es(t){for(const e of t.split(`
|
|
25
|
+
`)){const n=e.trim();if(n)try{const s=JSON.parse(n);if(Fe(s))return!0}catch{}}return!1}function Ns(t){var e;return zs((e=t[0])==null?void 0:e.type)}function vs(t){const e=t.map(n=>$e(n.trim())).filter(n=>n!==null);return je(e)}function Ot(t){if(typeof t=="string")return t;if(t===void 0)return"";try{return JSON.stringify(t)}catch{return String(t)}}function Le(t){return typeof t=="string"?t:Array.isArray(t)?t.flatMap(e=>{const n=typeof e=="string"?e:q(e)?A(e.text,e.content):"";return n?[n]:[]}).join(`
|
|
26
|
+
`):""}function Rs(t){const e=new Map;for(const n of t){if(n.type!=="session.binary_asset"&&n.type!=="binary_asset")continue;const s=A(n.data.assetId),o=A(n.data.data),i=A(n.data.mimeType);s&&o&&i&&e.set(s,{data:o,mimeType:i})}return e}function Ps(t,e){if(!q(t))return null;const n=e.get(A(t.assetId)),s=A(t.mimeType,n==null?void 0:n.mimeType).toLowerCase(),o=A(t.data,n==null?void 0:n.data);return!s.startsWith("image/")||!o?null:{type:"image",source:{type:"base64",media_type:s,data:o}}}function We(t,e){if(!Array.isArray(t))return[];const n=[],s=new Set;for(const o of t){const i=Ps(o,e);if(!i)continue;const l=`${i.source.media_type}:${i.source.data}`;s.has(l)||(s.add(l),n.push(i))}return n}function Bs(t,e){const n=A(t.content),s=We(t.attachments,e);return s.length===0?n:[...s,...n?[{type:"text",text:n}]:[]]}function Us(t,e){return q(t.result)?We([...Array.isArray(t.result.contents)?t.result.contents:[],...Array.isArray(t.result.binaryResultsForLlm)?t.result.binaryResultsForLlm:[]],e):[]}function jt(t,e=!1){const n=H(t.cacheWriteTokens),s=H(t.cacheReadTokens),o=H(t.inputTokens),i={input_tokens:e?Math.max(0,o-n-s):o,output_tokens:H(t.outputTokens),cache_creation_input_tokens:n,cache_read_input_tokens:s},l=H(t.reasoningTokens);return l&&(i.output_tokens_details={thinking_tokens:l}),i.input_tokens===0&&i.output_tokens===0&&i.cache_creation_input_tokens===0&&i.cache_read_input_tokens===0&&l===0?null:i}function Ds(t){if(!q(t.modelMetrics))return null;let e=null;for(const n of Object.values(t.modelMetrics)){if(!q(n)||!q(n.usage))continue;const s=jt(n.usage,!0);s&&(e=K(e,s))}return e}function Fs(t){if(typeof t=="string")return{label:t};if(!q(t))return null;const e=A(t.label,t.title,t.value,t.name);if(!e)return null;const n=A(t.description);return n?{label:e,description:n}:{label:e}}function $s(t){return Array.isArray(t)?t.map(Fs).filter(e=>e!==null):[]}function Os(t){if(!q(t))return null;const e=A(t.question,t.prompt,t.text,t.message);if(!e)return null;const n=A(t.header,t.title),s=typeof t.multiSelect=="boolean"?t.multiSelect:typeof t.multi_select=="boolean"?t.multi_select:void 0;return{question:e,...n?{header:n}:{},options:$s(t.options??t.choices),...s===void 0?{}:{multiSelect:s}}}function js(t){const n=(Array.isArray(t.questions)?t.questions:[t]).map(Os).filter(s=>s!==null);return n.length>0?{...t,questions:n}:t}function at(t){switch(t.toLowerCase().replace(/-/g,"_")){case"ask_user":return"AskUserQuestion";case"bash":case"powershell":case"shell":return"Bash";case"create":return"Write";case"edit":return"Edit";default:return t}}function bt(t,e){const n=q(e)?e:e===void 0?{}:{value:e};return t==="AskUserQuestion"?js(n):t==="Edit"?{...n,file_path:A(n.file_path,n.path),old_string:A(n.old_string,n.old_str),new_string:A(n.new_string,n.new_str)}:t==="Write"?{...n,file_path:A(n.file_path,n.path),content:A(n.content,n.file_text)}:t==="Bash"&&typeof n.command!="string"&&typeof n.cmd=="string"?{...n,command:n.cmd}:n}function Ls(t){const e=t.error;if(typeof e=="string")return e;if(q(e)){const s=A(e.message,e.code);if(s)return s}const n=t.result;if(typeof n=="string")return n;if(!q(n))return n===void 0?"":Ot(n);if(typeof n.detailedContent=="string")return n.detailedContent;if(typeof n.content=="string")return n.content;if(Array.isArray(n.contents)){const s=n.contents.flatMap(o=>{const i=typeof o=="string"?o:q(o)?A(o.text,o.content,o.output):"";return i?[i]:[]}).join(`
|
|
27
|
+
`);if(s)return s}return n.structuredContent!==void 0?Ot(n.structuredContent):Ot(n)}function qe(t,e,n,s){if(!e||t.thinking.some(l=>l.thinking===e))return;const o={type:"thinking",thinking:e,signature:s};t.thinking.push(o);const i=t.contentBlocks[t.contentBlocks.length-1];if((i==null?void 0:i.kind)==="thinking"){i.blocks.push(o);return}t.contentBlocks.push({kind:"thinking",blocks:[o],timestamp:n})}function Tt(t,e,n){t.toolCalls.push(e);const s=t.contentBlocks[t.contentBlocks.length-1];if((s==null?void 0:s.kind)==="tool_calls"){s.toolCalls.push(e);return}t.contentBlocks.push({kind:"tool_calls",toolCalls:[e],timestamp:n})}function lt(t,e,n,s){return{id:t,name:e,input:n,result:null,isError:!1,timestamp:s}}function ze(t,e,n){if(!Array.isArray(t))return[];const s=[];for(const o of t){if(!q(o))continue;const i=A(o.toolCallId),l=A(o.name);if(!i||!l||n(i))continue;const d=at(l);s.push(lt(i,d,bt(d,o.arguments),e))}return s}function Je(t,e,n,s){t.name=e,t.input=bt(e,n),t.timestamp=s||t.timestamp}function Ve(t,e,n){t.result=Ls(e);const s=Us(e,n);s.length>0&&(t.resultImages=s),t.isError=e.success===!1||e.error!==void 0&&e.error!==null}function He(t,e,n,s,o,i){return{id:t,userMessage:n,contentBlocks:[],thinking:[],assistantText:[],toolCalls:[],subAgentActivity:[],timestamp:e,durationMs:null,tokenUsage:null,model:s,...o?{effort:o}:{},...i?{isFragment:!0}:{}}}function Ws(t){return t.userMessage!==null||t.assistantText.length>0||t.thinking.length>0||t.toolCalls.length>0||t.subAgentActivity.length>0}function Ge(t,e){const n=Ms(t),s=je(n),o=Rs(n),i=[],l=new Map,d=new Map,f=new Map,u=new WeakMap,_=new WeakMap;let S=null,h=null,g,E=!1,R=!1,P=null;function k(x,r){r&&u.set(x,r)}function v(x){return S||(S=He(Oe(x),rt(x),null,h,g,!0)),S}function F(){S&&(Ws(S)&&i.push(S),S=null)}function W(x){var w;const r=typeof x.agentId=="string"?x.agentId:"";if(!r)return null;const c=d.get(r);if(c)return c.message;const b=x.data,p=A(b.toolCallId),T=p?((w=l.get(p))==null?void 0:w.turn)??S:S;if(!T)return null;const a=A(b.executionMode),C={agentId:r,...p?{parentToolUseId:p}:{},agentName:A(b.agentDisplayName,b.agentName)||null,subagentType:A(b.agentType,b.agentName)||null,type:"assistant",content:null,toolCalls:[],thinking:[],text:[],timestamp:rt(x),tokenUsage:null,model:A(b.model)||null,isBackground:a==="background",...A(b.description)?{prompt:A(b.description)}:{},status:"running"};return T.subAgentActivity.push(C),T.contentBlocks.push({kind:C.isBackground?"background_agent":"sub_agent",messages:[C],timestamp:C.timestamp}),d.set(r,{message:C,turn:T}),C}function O(x){if(De(x))return!1;const r=W(x);if(!r)return!0;const{data:c}=x,b=rt(x);if(x.type==="subagent.started"||x.type==="subagent.configured")return r.parentToolUseId||(r.parentToolUseId=A(c.toolCallId)||void 0),r.agentName=A(c.agentDisplayName,c.agentName)||r.agentName,r.subagentType=A(c.agentType,c.agentName)||r.subagentType,r.model=A(c.model)||r.model,r.prompt||(r.prompt=A(c.description)||void 0),r.isBackground||(r.isBackground=A(c.executionMode)==="background"),r.status="running",!0;if(x.type==="subagent.completed"||x.type==="subagent.failed"){r.agentName=A(c.agentDisplayName,c.agentName)||r.agentName,r.subagentType=A(c.agentType,c.agentName)||r.subagentType,r.model=A(c.model)||r.model,r.durationMs=H(c.durationMs)||r.durationMs,r.toolUseCount=H(c.totalToolCalls)||r.toolUseCount,r.status=x.type==="subagent.completed"?"completed":"failed";const p=A(c.error,c.message);return p&&!r.text.includes(p)&&r.text.push(p),!0}if(x.type==="user.message")return r.prompt||(r.prompt=A(c.content)||void 0),!0;if(x.type==="assistant.reasoning"){const p=A(c.content);return p&&!r.thinking.includes(p)&&r.thinking.push(p),!0}if(x.type==="assistant.message"){r.model=A(c.model)||r.model;const p=A(c.reasoningText);p&&!r.thinking.includes(p)&&r.thinking.push(p);const T=Le(c.content);T&&!r.text.includes(T)&&r.text.push(T);for(const a of ze(c.toolRequests,b,C=>f.has(C)))r.toolCalls.push(a),f.set(a.id,{call:a,message:r});return!0}if(x.type==="assistant.usage"){r.model=A(c.model)||r.model;const p=jt(c);return p&&(r.tokenUsage=K(r.tokenUsage,p)),!0}if(x.type==="tool.execution_start"){const p=A(c.toolCallId)||G(x,"copilot-agent-tool"),T=A(c.toolName)||"Tool",a=at(T),C=f.get(p);if(C)Je(C.call,a,c.arguments,b);else{const w=lt(p,a,bt(a,c.arguments),b);r.toolCalls.push(w),f.set(p,{call:w,message:r})}return!0}if(x.type==="tool.execution_complete"){const p=A(c.toolCallId)||G(x,"copilot-agent-tool");let T=f.get(p);if(!T){const a=A(c.toolName)||"Tool",C=at(a),w=lt(p,C,{},b);r.toolCalls.push(w),T={call:w,message:r}}return Ve(T.call,c,o),f.delete(p),!0}return!0}for(const x of n){if(O(x))continue;const{data:r}=x,c=rt(x);if(x.type==="session.start"||x.type==="session.resume"){h=A(r.selectedModel)||h,g=A(r.reasoningEffort)||g;continue}if(x.type==="session.auto_mode_resolved"){h=A(r.chosenModel)||h,S&&(S.model=h);continue}if(x.type==="session.model_change"){h=A(r.newModel)||h;const b=r.reasoningEffort;typeof b=="string"&&(g=b),S&&(S.model=h,g&&(S.effort=g));continue}if(x.type==="session.shutdown"){h=A(r.currentModel)||h,S&&!S.model&&(S.model=h),P=Ds(r)??P;const b=H(r.totalApiDurationMs);S&&!R&&b&&_.set(S,b);continue}if(x.type==="user.message"){F(),S=He(Oe(x),c,Bs(r,o),h,g,!1),k(S,c);continue}if(x.type==="assistant.turn_start"){h=A(r.model)||h;const b=v(x);b.model=h,g&&(b.effort=g),k(b,c);continue}if(x.type==="assistant.reasoning"){const b=v(x);qe(b,A(r.content),c,A(r.reasoningId)||G(x,"copilot-thinking")),k(b,c);continue}if(x.type==="assistant.message"){h=A(r.model)||h;const b=v(x);b.model=h,g&&(b.effort=g),qe(b,A(r.reasoningText),c,G(x,"copilot-thinking")),Pt(b,Le(r.content),c);for(const p of ze(r.toolRequests,c,T=>l.has(T)))Tt(b,p,c),l.set(p.id,{call:p,turn:b});k(b,c);continue}if(x.type==="assistant.usage"){h=A(r.model)||h,g=A(r.reasoningEffort)||g;const b=jt(r),p=H(r.duration);b&&(E=!0),p&&(R=!0);const T=v(x);T.model=h,g&&(T.effort=g),b&&(T.tokenUsage=K(T.tokenUsage,b)),p&&_.set(T,(_.get(T)??0)+p),k(T,c);continue}if(x.type==="tool.execution_start"){h=A(r.model)||h;const b=v(x);b.model=h;const p=A(r.toolCallId)||G(x,"copilot-tool"),T=A(r.toolName)||"Tool",a=at(T),C=l.get(p);if(C)Je(C.call,a,r.arguments,c);else{const w=lt(p,a,bt(a,r.arguments),c);Tt(b,w,c),l.set(p,{call:w,turn:b})}k(b,c);continue}if(x.type==="tool.execution_complete"){h=A(r.model)||h;const b=A(r.toolCallId)||G(x,"copilot-tool");let p=l.get(b);if(!p){const T=v(x),a=A(r.toolName)||"Tool",C=at(a),w=lt(b,C,{},c);Tt(T,w,c),p={call:w,turn:T}}Ve(p.call,r,o),l.delete(b),k(p.turn,c);continue}if(x.type==="session.error"){const b=v(x),T={errorType:A(r.errorType)||"unknown"};typeof r.statusCode=="number"&&(T.statusCode=r.statusCode),typeof r.errorCode=="string"&&(T.errorCode=r.errorCode),Tt(b,{id:G(x,"copilot-error"),name:"Error",input:T,result:A(r.message)||"Copilot session error",isError:!0,timestamp:c},c),k(b,c);continue}(x.type==="assistant.turn_end"||x.type==="assistant.idle"||x.type==="session.idle")&&S&&k(S,c)}if(F(),!E&&P&&i.length===1&&(i[0].tokenUsage=K(i[0].tokenUsage,P)),s.model)for(const x of i)x.model||(x.model=s.model);for(const x of i){const r=u.get(x),c=Date.parse(x.timestamp),b=r?Date.parse(r):Number.NaN;if(Number.isFinite(c)&&Number.isFinite(b)&&b>=c)x.durationMs=b-c;else{const p=_.get(x)??0;p&&(x.durationMs=p)}}const L=e!=null&&e.skipStats?pt(i.length):mt(i);return!(e!=null&&e.skipStats)&&!E&&P&&i.length>1&&(L.totalInputTokens=P.input_tokens,L.totalOutputTokens=P.output_tokens,L.totalCacheCreationTokens=P.cache_creation_input_tokens??0,L.totalCacheReadTokens=P.cache_read_input_tokens??0),{sessionId:s.sessionId,version:s.version,gitBranch:s.gitBranch,cwd:s.cwd,slug:s.slug,name:s.name,model:s.model,turns:i,stats:L,rawMessages:e!=null&&e.skipStats?[]:n,agentKind:"copilot"}}function qs(t,e){const n=t.rawMessages.map(s=>JSON.stringify(s)).join(`
|
|
28
|
+
`);return Ge(n?`${n}
|
|
29
|
+
${e}`:e)}function zs(t){return typeof t=="string"&&(t==="abort"||t==="binary_asset"||t==="user.message"||t.startsWith("assistant.")||t.startsWith("permission.")||t.startsWith("session.")||t.startsWith("subagent.")||t.startsWith("tool.")||t.startsWith("user_input."))}function Js(t){const e=new Map;for(const[i,l]of t.entries()){const d=typeof l.agentId=="string"?l.agentId:"";if(!d&&(l.type==="abort"||l.type==="session.shutdown"||l.type==="session.error")){e.clear();continue}if(!d||!l.type.startsWith("subagent."))continue;const f=q(l.data)?l.data:{},u=e.get(d);if(l.type==="subagent.completed"||l.type==="subagent.failed"){u&&(u.endedAt??(u.endedAt=i));continue}if(l.type==="subagent.started"||l.type==="subagent.configured"){const _=[f.agentDisplayName,f.description,f.agentName].find(S=>typeof S=="string")??"";if(!u||u.endedAt!==void 0){const S=typeof l.timestamp=="string"?l.timestamp:void 0;e.set(d,{agent:{description:_,startedAt:S},launchedAt:i})}else _&&(u.agent.description=_)}}const n=Mt([...e.values()]);if(n)return n;let s=!1;const o=new Set;for(let i=t.length-1;i>=0;i--){const l=t[i];if(typeof l.agentId=="string"&&l.agentId)continue;const d=q(l.data)?l.data:{};switch(l.type){case"abort":case"session.shutdown":return{status:"completed"};case"assistant.turn_end":{for(let f=i-1;f>=0;f--){const u=t[f];if(typeof u.agentId=="string"&&u.agentId)continue;if(u.type==="user.message")break;if(u.type==="abort")return{status:"completed"};if(u.type!=="assistant.message")continue;const _=q(u.data)?u.data:{};return Array.isArray(_.toolRequests)&&_.toolRequests.length>0?{status:"processing"}:{status:"completed"}}return{status:"processing"}}case"session.error":return{status:"completed",terminalReason:typeof d.message=="string"?d.message:"Copilot session error"};case"assistant.idle":case"session.idle":return{status:s?"completed":"idle"};case"permission.completed":{const f=typeof d.requestId=="string"?d.requestId:"";f&&o.add(f);continue}case"permission.requested":{const f=typeof d.requestId=="string"?d.requestId:"";if(f&&o.has(f))continue;return{status:"deferred"}}case"user_input.requested":return{status:"tool_use",toolName:"AskUserQuestion"};case"tool.execution_start":return o.size>0?{status:"thinking"}:{status:"tool_use",toolName:typeof d.toolName=="string"?Q(d.toolName):typeof d.name=="string"?Q(d.name):void 0};case"tool.execution_complete":return{status:"thinking"};case"assistant.turn_start":return{status:"processing"};case"assistant.message":case"assistant.message_delta":case"assistant.reasoning":case"assistant.reasoning_delta":return{status:"thinking"};case"user.message":return s=!0,{status:"processing"};case"session.start":case"session.resume":return{status:s?"processing":"idle"}}}return{status:"idle"}}function Vs(){throw new Error("Copilot sessions branch through the CLI's fork API, not by copying the transcript")}function Hs(t){const e=[];for(let n=0;n<t.length;n++){const s=t[n];if(s.type!=="user.message"||typeof s.agentId=="string")continue;const o=s.data;!o||typeof o!="object"||Array.isArray(o)||typeof s.id!="string"||!s.id||e.push(n)}return e}const Ke=Ct[Ct.length-1],Qe=()=>!1,Gs={kind:"codex",descriptor:ft("codex"),detectsText:ys,detectsRecords:_s,parse:Ue,append:bs,metadataFromLines:ks,status:xs,isNoiseLine:Qe,pageHeaderLine:ts,brandBranch:As,turnBoundaries:Ss},Ks={kind:"copilot",descriptor:ft("copilot"),detectsText:Es,detectsRecords:Ns,parse:Ge,append:qs,metadataFromLines:vs,status:Js,isNoiseLine:Qe,brandBranch:Vs,turnBoundaries:Hs},Ze={kind:"claude",descriptor:ft("claude"),detectsText:fe,detectsRecords:fe,parse:_e,append:ke,metadataFromLines:vn,status:Dn,isNoiseLine:me,brandBranch:Fn,turnBoundaries:$n},Lt=Object.freeze({acp:{...Ze,kind:"acp",descriptor:ft("acp"),detectsText:t=>{var e;return((e=t.split(`
|
|
30
|
+
`,1)[0])==null?void 0:e.includes('"type":"acp_session"'))??!1},detectsRecords:t=>{var e;return((e=t[0])==null?void 0:e.type)==="acp_session"},parse:(t,e)=>({..._e(t,e),agentKind:"acp"}),append:(t,e)=>({...ke(t,e),agentKind:"acp"})},claude:Ze,codex:Gs,copilot:Ks});function Xe(t){for(const e of Ct)if(t(Lt[e]))return Lt[e];return Lt[Ke]}function Ye(t){return Xe(e=>e.detectsText(t))}function Qs(t){return Xe(e=>e.detectsRecords(t))}function Zs(t,e){return Ye(t).parse(t,e)}function Xs(t,e){const n=Qs(t.rawMessages),o=(n.kind===Ke?Ye(e):n).append(t,e);return t.instanceId?en(o,t.instanceId):o}self.onmessage=t=>{const e=t.data;try{let n;e.type==="parse"?n=Zs(e.text):n=Xs(e.existing,e.newText),self.postMessage({type:"result",id:e.id,session:n})}catch(n){self.postMessage({type:"error",id:e.id,error:n instanceof Error?n.message:String(n)})}}})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c,j as n}from"./vendor-react-gGw_S5I_.js";import{J as u}from"./index-
|
|
1
|
+
import{c,j as n}from"./vendor-react-gGw_S5I_.js";import{J as u}from"./index-COB3e1_W.js";import{g as p,h as f}from"./vendor-ui-DKYSMrjf.js";function b(l){const e=c.c(11);let a,t,s;e[0]!==l?({className:a,size:s,...t}=l,e[0]=l,e[1]=a,e[2]=t,e[3]=s):(a=e[1],t=e[2],s=e[3]);const o=s===void 0?"default":s;let i;e[4]!==a?(i=u("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input data-disabled:cursor-not-allowed data-disabled:opacity-50",a),e[4]=a,e[5]=i):i=e[5];let r;e[6]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(f,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-foreground ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0"}),e[6]=r):r=e[6];let d;return e[7]!==t||e[8]!==o||e[9]!==i?(d=n.jsx(p,{"data-slot":"switch","data-size":o,className:i,...t,children:r}),e[7]=t,e[8]=o,e[9]=i,e[10]=d):d=e[10],d}export{b as S};
|