sessiongraph 1.0.12 → 1.0.13
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/assets/{external-links-D0O8IeG0.js → external-links-BcKDmn29.js} +1 -1
- package/dist/assets/{index-CIhs02tq.js → index-CDA8pT1Q.js} +32 -31
- package/dist/assets/{index-BS2Voifb.js → index-CJb-F0VY.js} +1 -1
- package/dist/assets/{index-Vq4WYmzW.js → index-DYhIhreE.js} +1 -1
- package/dist/assets/{index-GTrhxXlP.js → index-HzUuskn3.js} +1 -1
- package/dist/assets/{publishing-ofssf6d6.js → publishing-CpVLG7_B.js} +1 -1
- package/dist/assets/{scene-KCDTPCOD.js → scene-BkoCsbA8.js} +1 -1
- package/dist/assets/{share-DKeJCFAo.js → share-CS1dKayZ.js} +3 -3
- package/dist/index.html +1 -1
- package/dist-server/cli.mjs +92 -32
- package/dist-server/server.mjs +90 -30
- package/docs/guide.md +2 -1
- package/docs/import-coverage.md +2 -2
- package/docs/importer-comparison.md +48 -0
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as a,n as i,C as R}from"./index-
|
|
1
|
+
import{R as a,n as i,C as R}from"./index-CDA8pT1Q.js";var w;(function(n){n[n.Audio=1]="Audio",n[n.Cache=2]="Cache",n[n.Config=3]="Config",n[n.Data=4]="Data",n[n.LocalData=5]="LocalData",n[n.Document=6]="Document",n[n.Download=7]="Download",n[n.Picture=8]="Picture",n[n.Public=9]="Public",n[n.Video=10]="Video",n[n.Resource=11]="Resource",n[n.Temp=12]="Temp",n[n.AppConfig=13]="AppConfig",n[n.AppData=14]="AppData",n[n.AppLocalData=15]="AppLocalData",n[n.AppCache=16]="AppCache",n[n.AppLog=17]="AppLog",n[n.Desktop=18]="Desktop",n[n.Executable=19]="Executable",n[n.Font=20]="Font",n[n.Home=21]="Home",n[n.Runtime=22]="Runtime",n[n.Template=23]="Template"})(w||(w={}));var d;(function(n){n[n.Start=0]="Start",n[n.Current=1]="Current",n[n.End=2]="End"})(d||(d={}));function u(n){return{isFile:n.isFile,isDirectory:n.isDirectory,isSymlink:n.isSymlink,size:n.size,mtime:n.mtime!==null?new Date(n.mtime):null,atime:n.atime!==null?new Date(n.atime):null,birthtime:n.birthtime!==null?new Date(n.birthtime):null,readonly:n.readonly,fileAttributes:n.fileAttributes,dev:n.dev,ino:n.ino,mode:n.mode,nlink:n.nlink,uid:n.uid,gid:n.gid,rdev:n.rdev,blksize:n.blksize,blocks:n.blocks}}function U(n){const e=new Uint8ClampedArray(n),t=e.byteLength;let o=0;for(let r=0;r<t;r++){const s=e[r];o*=256,o+=s}return o}class g extends a{async read(e){if(e.byteLength===0)return 0;const t=await i("plugin:fs|read",{rid:this.rid,len:e.byteLength}),o=U(t.slice(-8)),r=t instanceof ArrayBuffer?new Uint8Array(t):t;return e.set(r.slice(0,r.length-8)),o===0?null:o}async seek(e,t){return await i("plugin:fs|seek",{rid:this.rid,offset:e,whence:t})}async stat(){const e=await i("plugin:fs|fstat",{rid:this.rid});return u(e)}async truncate(e){await i("plugin:fs|ftruncate",{rid:this.rid,len:e})}async write(e){return await i("plugin:fs|write",{rid:this.rid,data:e})}}async function b(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const t=await i("plugin:fs|create",{path:n instanceof URL?n.toString():n,options:e});return new g(t)}async function p(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const t=await i("plugin:fs|open",{path:n instanceof URL?n.toString():n,options:e});return new g(t)}async function S(n,e,t){if(n instanceof URL&&n.protocol!=="file:"||e instanceof URL&&e.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|copy_file",{fromPath:n instanceof URL?n.toString():n,toPath:e instanceof URL?e.toString():e,options:t})}async function A(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|mkdir",{path:n instanceof URL?n.toString():n,options:e})}async function T(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");return await i("plugin:fs|read_dir",{path:n instanceof URL?n.toString():n,options:e})}async function E(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const t=await i("plugin:fs|read_file",{path:n instanceof URL?n.toString():n,options:e});return t instanceof ArrayBuffer?new Uint8Array(t):Uint8Array.from(t)}async function _(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const t=await i("plugin:fs|read_text_file",{path:n instanceof URL?n.toString():n,options:e}),o=t instanceof ArrayBuffer?t:Uint8Array.from(t);return new TextDecoder(e?.encoding??"utf-8").decode(o)}async function x(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const t=n instanceof URL?n.toString():n;return await Promise.resolve({path:t,rid:null,async next(){const o=new TextDecoder(e?.encoding??"utf-8");if(this.rid===null){const l=o.encoding;this.rid=await i("plugin:fs|read_text_file_lines",{path:t,options:e!=null?{...e,encoding:l}:void 0})}let r;try{r=await i("plugin:fs|read_text_file_lines_next",{rid:this.rid})}catch(l){throw this.rid=null,l}const s=r instanceof ArrayBuffer?new Uint8Array(r):Uint8Array.from(r),f=s[s.byteLength-1]===1;return f?(this.rid=null,{value:null,done:f}):{value:o.decode(s.slice(0,s.byteLength-1)),done:f}},async return(){if(this.rid!==null){const o=this.rid;this.rid=null,await new a(o).close()}return{value:null,done:!0}},[Symbol.asyncIterator](){return this}})}async function v(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|remove",{path:n instanceof URL?n.toString():n,options:e})}async function M(n,e,t){if(n instanceof URL&&n.protocol!=="file:"||e instanceof URL&&e.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|rename",{oldPath:n instanceof URL?n.toString():n,newPath:e instanceof URL?e.toString():e,options:t})}async function C(n,e){const t=await i("plugin:fs|stat",{path:n instanceof URL?n.toString():n,options:e});return u(t)}async function k(n,e){const t=await i("plugin:fs|lstat",{path:n instanceof URL?n.toString():n,options:e});return u(t)}async function F(n,e,t){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|truncate",{path:n instanceof URL?n.toString():n,len:e,options:t})}async function z(n,e,t){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");if(e instanceof ReadableStream){const o=await p(n,{read:!1,create:!0,write:!0,...t,truncate:!t?.append}),r=e.getReader();try{for(;;){const{done:s,value:f}=await r.read();if(s)break;await o.write(f)}}finally{r.releaseLock(),await o.close()}}else await i("plugin:fs|write_file",e,{headers:{path:encodeURIComponent(n instanceof URL?n.toString():n),options:JSON.stringify(t)}})}async function I(n,e,t){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const o=new TextEncoder;await i("plugin:fs|write_text_file",o.encode(e),{headers:{path:encodeURIComponent(n instanceof URL?n.toString():n),options:JSON.stringify(t)}})}async function H(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");return await i("plugin:fs|exists",{path:n instanceof URL?n.toString():n,options:e})}class y extends a{}async function L(n,e,t){const o=Array.isArray(n)?n:[n];for(const c of o)if(c instanceof URL&&c.protocol!=="file:")throw new TypeError("Must be a file URL.");const r=new R;r.onmessage=e;const s=await i("plugin:fs|watch",{paths:o.map(c=>c instanceof URL?c.toString():c),options:t,onEvent:r}),f=new y(s);return()=>{f.close()}}async function J(n,e,t){return await L(n,e,{delayMs:2e3,...t})}async function N(n,e,t){return await L(n,e,{...t,delayMs:void 0})}async function O(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");return await i("plugin:fs|size",{path:n instanceof URL?n.toString():n,options:e})}async function V(n){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|start_accessing_security_scoped_resource",{path:n instanceof URL?n.toString():n})}async function h(n){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|stop_accessing_security_scoped_resource",{path:n instanceof URL?n.toString():n})}export{w as BaseDirectory,g as FileHandle,d as SeekMode,S as copyFile,b as create,H as exists,k as lstat,A as mkdir,p as open,T as readDir,E as readFile,_ as readTextFile,x as readTextFileLines,v as remove,M as rename,O as size,V as startAccessingSecurityScopedResource,C as stat,h as stopAccessingSecurityScopedResource,F as truncate,J as watch,N as watchImmediate,z as writeFile,I as writeTextFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as a,R as i,C as o}from"./index-
|
|
1
|
+
import{n as a,R as i,C as o}from"./index-CDA8pT1Q.js";class l extends i{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(e,s){const d=new o;e&&(d.onmessage=e);const r=await a("plugin:updater|download",{onEvent:d,rid:this.rid,...s,headers:t(s?.headers)});await this.downloadedBytes?.close().catch(()=>{}),this.downloadedBytes=new i(r)}async install(e){if(!this.downloadedBytes)throw new Error("Update.install called before Update.download");await a("plugin:updater|install",{updateRid:this.rid,bytesRid:this.downloadedBytes.rid,...e}),this.downloadedBytes=void 0}async downloadAndInstall(e,s){const d=new o;e&&(d.onmessage=e),await a("plugin:updater|download_and_install",{onEvent:d,rid:this.rid,...s,headers:t(s?.headers)})}async close(){await this.downloadedBytes?.close(),await super.close()}}async function w(n){const e=await a("plugin:updater|check",{...n,headers:t(n?.headers)});return e?new l(e):null}function t(n){return n?Array.from(new Headers(n).entries()):void 0}export{l as Update,w as check};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as i}from"./index-
|
|
1
|
+
import{n as i}from"./index-CDA8pT1Q.js";function r(e){if(e!==void 0){if(typeof e=="string")return e;if("ok"in e&&"cancel"in e)return{OkCancelCustom:[e.ok,e.cancel]};if("yes"in e&&"no"in e&&"cancel"in e)return{YesNoCancelCustom:[e.yes,e.no,e.cancel]};if("ok"in e)return{OkCustom:e.ok}}}async function f(e={}){return typeof e=="object"&&Object.freeze(e),await i("plugin:dialog|open",{options:e})}async function k(e={}){return typeof e=="object"&&Object.freeze(e),await i("plugin:dialog|save",{options:e})}async function l(e,a){return await i("plugin:dialog|message",{message:e,title:a?.title,kind:a?.kind,buttons:r(a?.buttons)})}async function s(e,a){const n=typeof a=="string"?{title:a}:a;return n&&!n.buttons&&n.okLabel&&(n.buttons={ok:n.okLabel}),l(e,n)}async function u(e,a){const n=typeof a=="string"?{title:a}:a,c=n?.okLabel||n?.cancelLabel,t=n?.okLabel??"Yes";return await l(e,{title:n?.title,kind:n?.kind,buttons:c?{ok:t,cancel:n.cancelLabel??"No"}:"YesNo"})===t}async function d(e,a){const n=typeof a=="string"?{title:a}:a,c=n?.okLabel||n?.cancelLabel,t=n?.okLabel??"Ok";return await l(e,{title:n?.title,kind:n?.kind,buttons:c?{ok:t,cancel:n.cancelLabel??"Cancel"}:"OkCancel"})===t}export{u as ask,d as confirm,s as message,f as open,k as save};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as pe,j as me,m as ge,D as be,a as ae,k as q,l as ie,t as he,P as fe,g as ye,c as we,i as V}from"./index-
|
|
1
|
+
import{h as pe,j as me,m as ge,D as be,a as ae,k as q,l as ie,t as he,P as fe,g as ye,c as we,i as V}from"./index-CDA8pT1Q.js";import{TimelineScene as ve}from"./scene-BkoCsbA8.js";import{s as ke,e as Se,o as Ce}from"./external-links-BcKDmn29.js";import"./three-D_1Qt16u.js";const xe=["svg",pe,[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}],["path",{d:"M9 18c-4.51 2-5-2-7-2"}]]],Ae={tokens:"Token counts",timestamps:"Session timestamps",messageCounts:"Message counts",messageTimestamps:"Message timestamps",model:"Model used",harness:"Harness used"},Z={tokens:!0,timestamps:!0,messageCounts:!0,messageTimestamps:!0,model:!0,harness:!0};function oe(t){const r={...Z};if(ce(t))for(const n of Object.keys(r))typeof t[n]=="boolean"&&(r[n]=t[n]);return(!r.timestamps||!r.messageCounts)&&(r.messageTimestamps=!1),r}const re=1e4,Ee=2e6,Pe=1e5,Me="Always excluded: project and session names, messages, code, paths, source IDs, and costs. Anonymous groups and recorded branch links are included. Your GitHub username identifies this profile. Your published graph will appear in Explore graphs. Selected timestamps and usage will be public.",Te=/^(?:gpt-[3-6](?:\.[0-9])?(?:-(?:turbo|mini|nano|pro|codex|astra|instant|thinking|chat|latest|preview|[0-9]{4,8}))*|o[1-4](?:-(?:mini|pro|preview|[0-9]{4,8}))*|claude-(?:(?:sonnet|opus|haiku)-[3-5](?:[.-][0-9])?|[3-5](?:-[0-9])?-(?:sonnet|opus|haiku))(?:-(?:latest|thinking|[0-9]{8}))*|gemini-[1-4](?:\.[0-9])?-(?:pro|flash)(?:-(?:lite|preview|exp|latest|[0-9]{2,4}))*|deepseek-(?:chat|reasoner|v[3-4](?:\.[0-9])?|r1)|grok-[2-5](?:\.[0-9])?(?:-(?:fast|code|reasoning|non-reasoning|[0-9]))*|kimi-k[1-3](?:\.[0-9])?(?:-thinking)?|minimax-m[1-3](?:\.[0-9])?)$/i,Le=t=>{const r=t.split("/").at(-1)||"";return r.length<=100&&Te.test(r)?r.toLowerCase():null},ce=t=>!!t&&typeof t=="object"&&!Array.isArray(t),B=(t,r)=>ce(t)&&Object.keys(t).length===r.length&&r.every(n=>Object.hasOwn(t,n)),Y=(t,r=Number.MAX_SAFE_INTEGER)=>Number.isSafeInteger(t)&&t>=0&&t<=r,W=t=>Y(t,Date.UTC(2100,0,1)),z=t=>t===null||Y(t);function de(t){const r=()=>{throw new Error("Invalid anonymous graph. Reopen the publishing preview and try again.")};if(!B(t,["version","settings","sessions"])||t.version!==1||!Array.isArray(t.sessions)||!B(t.settings,Object.keys(Z))||Object.values(t.settings).some(f=>typeof f!="boolean"))return r();const n=t.settings;if(n.messageTimestamps&&(!n.timestamps||!n.messageCounts))return r();if(t.sessions.length<1||t.sessions.length>re)throw new Error(`Choose between 1 and ${re.toLocaleString("en")} sessions to publish.`);const e=["id","group","parent","fork",...n.timestamps?["timestamps"]:[],...n.tokens?["tokens"]:[],...n.messageCounts?["messages"]:[],...n.messageTimestamps?["messageTimes"]:[],...n.model?["model"]:[],...n.harness?["harness"]:[]];let m=0;for(let f=0;f<t.sessions.length;f++){const i=t.sessions[f];if(!B(i,e)||i.id!==f||!Y(i.group,t.sessions.length-1))return r();for(const p of["parent","fork"])if(i[p]!==null&&(!Y(i[p],t.sessions.length-1)||i[p]===f))return r();if(n.timestamps&&(!B(i.timestamps,["created","lastMessageAt"])||!W(i.timestamps.created)||i.timestamps.lastMessageAt!==null&&!W(i.timestamps.lastMessageAt))||n.tokens&&!z(i.tokens)||n.messageCounts&&(!B(i.messages,["count","untimed","partial"])||!z(i.messages.count)||!z(i.messages.untimed)||typeof i.messages.partial!="boolean")||n.messageTimestamps&&(!B(i.messageTimes,["values","limited"])||!Array.isArray(i.messageTimes.values)||i.messageTimes.values.length>2e3||typeof i.messageTimes.limited!="boolean"||i.messageTimes.values.some(p=>!W(p))||(m+=i.messageTimes.values.length,m>Pe))||n.model&&i.model!==null&&(typeof i.model!="string"||Le(i.model)!==i.model)||n.harness&&i.harness!==null&&(typeof i.harness!="string"||!me(i.harness)))return r()}const o=t.sessions,l=new Uint8Array(o.length);for(let f=0;f<o.length;f++){if(l[f])continue;const i=[[f,!1]];for(;i.length;){const[p,M]=i.pop();if(M){l[p]=2;continue}if(l[p]===1)return r();if(l[p]!==2){l[p]=1,i.push([p,!0]);for(const S of[o[p].parent,o[p].fork])S!==null&&i.push([S,!1])}}}if(new TextEncoder().encode(JSON.stringify(t)).length>Ee)throw new Error("This graph is too large. Choose a smaller date range.");return t}function le(t,r){const n=de(t),e=n.sessions.filter(l=>!r||r.has(l.id)).map(l=>({id:String(l.id),projectID:String(l.group),title:`Session ${l.id+1}`,directory:"",created:l.timestamps?.created??l.id*36e5,updated:l.timestamps?.created??l.id*36e5,tokens:l.tokens??null,cost:null,archived:!1,model:l.model??"",provider:"",agent:"",source:l.harness??void 0,activity:{firstMessageAt:null,lastMessageAt:l.timestamps?.lastMessageAt??null,userMessages:0,untimedUserMessages:0},...l.parent===null?{}:{parentID:String(l.parent)},...l.fork===null?{}:{forkID:String(l.fork)}})),m=[...new Set(n.sessions.map(l=>l.group))].map(l=>({id:String(l),name:`Group ${l+1}`,directory:"",worktrees:[]})),o=ge(e.map(l=>({...l,source:void 0})),m);for(const l of o.nodes)l.session.source=n.sessions[Number(l.session.id)].harness??void 0;return o}function $e(t){const r=t.settings.tokens?t.sessions.filter(e=>typeof e.tokens=="number"):[],n=r.reduce((e,m)=>e+m.tokens,0);return{sessionCount:t.sessions.length,tokenCount:r.length&&Number.isSafeInteger(n)?n:null,tokensPartial:r.length>0&&r.length<t.sessions.length}}function ue(t){const r=$e(t),n=[`${r.sessionCount.toLocaleString()} sessions`];if(t.settings.tokens&&n.push(r.tokenCount===null?"Tokens unavailable":`${r.tokenCount.toLocaleString()} recorded tokens${r.tokensPartial?" (partial coverage)":""}`),t.settings.messageCounts){const e=t.sessions.filter(m=>m.messages?.count!=null);n.push(e.length?`${e.reduce((m,o)=>m+o.messages.count,0).toLocaleString()} recorded messages${e.length<t.sessions.length||t.sessions.some(m=>m.messages?.partial)?" (partial history)":""}`:"Message counts unavailable")}return n.join(" · ")}const Q=t=>t==null?"Unknown":t.toLocaleString(),R=t=>t===null?"Unknown":new Date(t).toLocaleString();function Ie(t,r,n={}){const e=de(r);let m=le(e);t.classList.add("public-viewer"),t.classList.toggle("public-viewer-full",!!n.fullscreen),t.innerHTML=`
|
|
2
2
|
<div class="public-canvas" aria-label="Interactive public session graph"></div>
|
|
3
3
|
<div class="public-toolbar"><button type="button" data-sessions aria-expanded="true">☷ Sessions</button><span class="public-badge">Public snapshot</span></div>
|
|
4
4
|
<nav class="public-view-controls" aria-label="Graph controls"><div class="public-view-switch"><button type="button" data-view="3d" aria-pressed="true">3D</button><button type="button" data-view="2d" aria-pressed="false">2D</button></div><button type="button" data-fit title="Fit view (F)">Fit view</button><button type="button" data-motion aria-pressed="true">Motion</button><button type="button" data-timeline aria-expanded="true">Timeline</button></nav>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{M as oe,C as L,S as ce,a as M,G,P as ae,I as ne,b as k,D as F,c as I,A as T,d as Y,e as N,B as D,F as S,f as re,g as H,W as ke,h as Pe,O as Se,i as Ae,H as Ce,E as Re,R as Fe,U as Ee,V as O,j as Ie,k as Te,l as ze,m as Be,n as Ue,o as V,p as Ge,q as g,r as De,s as ee,t as Oe,u as Le,v as j,w as te,x as ie,y as He,L as Ne,z as de,J as ue,K as Xe,N as _e}from"./three-D_1Qt16u.js";import{h as ge,o as R,c as Ve,D as $e,l as je,q as C,r as $,u as We,v as qe,w as Ye,x as se,y as fe}from"./index-
|
|
1
|
+
import{M as oe,C as L,S as ce,a as M,G,P as ae,I as ne,b as k,D as F,c as I,A as T,d as Y,e as N,B as D,F as S,f as re,g as H,W as ke,h as Pe,O as Se,i as Ae,H as Ce,E as Re,R as Fe,U as Ee,V as O,j as Ie,k as Te,l as ze,m as Be,n as Ue,o as V,p as Ge,q as g,r as De,s as ee,t as Oe,u as Le,v as j,w as te,x as ie,y as He,L as Ne,z as de,J as ue,K as Xe,N as _e}from"./three-D_1Qt16u.js";import{h as ge,o as R,c as Ve,D as $e,l as je,q as C,r as $,u as We,v as qe,w as Ye,x as se,y as fe}from"./index-CDA8pT1Q.js";const Ke=["svg",ge,[["path",{d:"M12 8V4H8"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}],["path",{d:"M2 14h2"}],["path",{d:"M20 14h2"}],["path",{d:"M15 13v2"}],["path",{d:"M9 13v2"}]]];const Qe=["svg",ge,[["circle",{cx:"12",cy:"8",r:"5"}],["path",{d:"M20 21a8 8 0 0 0-16 0"}]]],ye=`
|
|
2
2
|
attribute float nodeIndex;
|
|
3
3
|
uniform float uSelected;
|
|
4
4
|
uniform float uHovered;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{TimelineScene as V}from"./scene-
|
|
3
|
-
https://github.com/arvindell/sessiongraph`,be=`https://x.com/intent/tweet?text=${encodeURIComponent(I)}`,z=e=>e instanceof Error&&e.name==="AbortError";async function ve(e,l,t){const{label:s,description:i,mime:p,filename:r}=$[t];try{if(U()){const[{save:a},{writeFile:o}]=await Promise.all([G(()=>import("./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-HzUuskn3.js","assets/index-CDA8pT1Q.js","assets/index-cVgPCrFV.css","assets/index-CJb-F0VY.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{TimelineScene as V}from"./scene-BkoCsbA8.js";import{i as U,_ as G,c as X,S as J,p as Y,a as Z,t as K,s as Q,b as H,d as ee,e as te,f as ae,g as oe}from"./index-CDA8pT1Q.js";import{s as re,o as se}from"./external-links-BcKDmn29.js";import"./three-D_1Qt16u.js";const ne="#b0e9d6",ie="#dbe7e3",L=128,le=10,ce="M102 24 86 40H36a14 14 0 0 0 0 28h40a14 14 0 0 1 0 28H22",de=[[102,24],[36,40],[22,96]],ue=10;let O;function he(e,l,t,s,i=ne){O??=new Path2D(ce),e.save(),e.translate(l,t),e.scale(s/L,s/L),e.strokeStyle=e.fillStyle=i,e.lineWidth=le,e.lineCap=e.lineJoin="round",e.stroke(O);for(const[p,r]of de)e.beginPath(),e.arc(p,r,ue,0,Math.PI*2),e.fill();e.restore()}const pe="Cosmic Wobbly Disco Sneaky Bouncy Galactic Crispy Dizzy Fuzzy Noodle Groovy Sleepy Spicy Jolly Loopy Squishy Turbo Giggly Velvet Soggy Zippy Fluffy Moonwalking Wiggly Fizzy Snazzy Goofy Jazzy Tiny Chunky Dapper Wacky".split(" "),ye="Wombat Pickle Pancake Badger Potato Narwhal Noodle Goblin Otter Turnip Hamster Comet Dumpling Goose Biscuit Llama Muffin Squid Raccoon Toaster Waffle Penguin Yeti Pudding Walrus Taco Jellybean Platypus Sloth Cactus Donut Mongoose".split(" ");function fe(e,l=()=>crypto.getRandomValues(new Uint32Array(1))[0]/2**32){const t=pe.flatMap(s=>ye.map(i=>`${s} ${i}`));for(let s=t.length-1;s>0;s--){const i=Math.floor(l()*(s+1));[t[s],t[i]]=[t[i],t[s]]}return Array.from({length:e},(s,i)=>{const p=Math.floor(i/t.length);return`Project ${"Mega".repeat(p)}${t[i%t.length]}`})}function me(e){const l=fe(e.lanes.length),t=new Map(e.nodes.map((r,a)=>[r.session.id,`session-${a}`])),s=new Map(e.lanes.flatMap((r,a)=>r.nodes.map(o=>[o.session.id,`project-${a}`]))),i=e.nodes.map(r=>{const a=r.session,o={id:t.get(a.id),title:"Session",projectID:s.get(a.id),directory:"",created:a.created,updated:a.created,activity:a.activity&&{firstMessageAt:a.activity.firstMessageAt,lastMessageAt:a.activity.lastMessageAt,userMessages:a.activity.userMessages,untimedUserMessages:a.activity.untimedUserMessages},archived:!1,model:"",provider:"",agent:"",cost:null,source:a.source==="continue"?"continue":a.source==="opencode"||!a.source?"opencode":"unknown",tokens:a.tokens};return a.parentID&&t.has(a.parentID)&&(o.parentID=t.get(a.parentID)),a.forkID&&t.has(a.forkID)&&(o.forkID=t.get(a.forkID)),{session:o,position:[...r.position],startPosition:[...r.startPosition],color:r.color,radius:r.radius}}),p=new Map(i.map(r=>[r.session.id,r]));return{start:e.start,end:e.end,timeFrame:e.timeFrame&&{...e.timeFrame},nodes:i,edges:e.edges.map(r=>({from:t.get(r.from),to:t.get(r.to),kind:r.kind})),lanes:e.lanes.map((r,a)=>({key:`project-${a}`,label:l[a],color:r.color,kind:"directory",y:r.y,z:r.z,nodes:r.nodes.map(o=>p.get(t.get(o.session.id)))}))}}const $={mp4:{label:"MP4",description:"MP4 video",mime:"video/mp4",filename:"sessiongraph-playback.mp4"}},I=`My coding sessions, visualized with SessionGraph.
|
|
3
|
+
https://github.com/arvindell/sessiongraph`,be=`https://x.com/intent/tweet?text=${encodeURIComponent(I)}`,z=e=>e instanceof Error&&e.name==="AbortError";async function ve(e,l,t){const{label:s,description:i,mime:p,filename:r}=$[t];try{if(U()){const[{save:a},{writeFile:o}]=await Promise.all([G(()=>import("./index-HzUuskn3.js"),__vite__mapDeps([0,1,2])),G(()=>import("./index-CJb-F0VY.js"),__vite__mapDeps([3,1,2]))]),c=await a({title:`Save SessionGraph ${s}`,defaultPath:r,filters:[{name:i,extensions:[t]}]});if(!c)return"cancelled";await o(c,new Uint8Array(await e.arrayBuffer()))}else{const a=window.showSaveFilePicker;if(a){const c=await(await a.call(window,{suggestedName:r,types:[{description:i,accept:{[p]:[`.${t}`]}}]})).createWritable();try{await c.write(e),await c.close()}catch(d){throw await c.abort().catch(()=>{}),d}}else{const o=document.createElement("a");return o.href=l,o.download=r,document.body.append(o),o.click(),o.remove(),"downloaded"}}return"saved"}catch(a){if(z(a))return"cancelled";throw a}}const S=960,T=600,we=e=>Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e);function ge(e,l,t,s,i,p){const o=T-122,c=Math.max(1,...s);e.save(),he(e,24,14,28),e.fillStyle=ie,e.font='600 14px "Geist Variable", sans-serif',e.textAlign="left",e.textBaseline="middle",e.fillText("SessionGraph",58,28),e.restore();for(let h=0;h<s.length;h++){const f=Math.max(2,s[h]/c*22);e.fillStyle=h/s.length<=t?"#91bfae":"#253d39",e.fillRect(260+h/s.length*440,o-f,440/s.length-2,f)}e.fillStyle="#d6f4e8",e.fillRect(260+440*t,o-27,1,31);const d=l.start+(l.end-l.start)*t,k=i.at(d,t===1).tokens;e.textAlign="center",e.fillStyle="#a0baae",e.font='12px "IBM Plex Mono", monospace',e.fillText(oe(d,l.end-l.start),S/2,o+23),e.fillStyle="#e7f5ee",e.font='36px "Geist Variable", sans-serif',e.fillText(p(d,t===1).toLocaleString("en"),S/2-105,o+66),e.fillText(i.recorded?we(k):"—",S/2+105,o+66),e.font='12px "Geist Variable", sans-serif',e.fillStyle="#92b0a3",e.fillText("Sessions",S/2-105,o+87),e.fillText("Burnt tokens",S/2+105,o+87),e.textAlign="left"}async function Se(e,l,t,s){t.throwIfAborted();const{label:i,mime:p}=$.mp4,r=Y(e.nodes.map(y=>y.session)),a=Z(e.nodes.map(y=>y.session)),o=K(e.nodes.map(y=>Q(y.session)),e.start,e.end),c=document.createElement("div");c.className="share-render-host",c.setAttribute("aria-hidden","true"),c.style.cssText=`position:fixed;left:-12000px;top:0;width:${S}px;height:${T}px;pointer-events:none;visibility:hidden`,document.body.append(c);const d=document.createElement("canvas");d.width=S,d.height=T;const k=d.getContext("2d",{willReadFrequently:!0});let h,f;try{if(!k)throw new Error("Canvas export is unavailable.");h=new V(c,{onSelect(){},onHover(){},onPlaybackInterrupt(){},onEvent(){},onEventHover(){}},{manual:!0}),h.applyPreferences({...l,quality:"balanced",motion:"on",labels:!0,focusDimming:!1,trails:l.trails==="selected"?"all":l.trails}),h.setGraph(e,!0),h.prepareCapture(),await document.fonts.ready,t.throwIfAborted(),f=new Worker(new URL("/assets/mp4-worker-Dc_1QUwS.js",import.meta.url),{type:"module"});const y=(m,C=[])=>new Promise((A,b)=>{t.throwIfAborted();const v=()=>{clearTimeout(D),t.removeEventListener("abort",w),f.onmessage=null,f.onerror=null},w=()=>{v(),b(t.reason)},D=setTimeout(()=>{v(),b(new Error(`${i} encoding timed out. Please try again.`))},6e4);t.addEventListener("abort",w,{once:!0}),f.onmessage=M=>{v(),M.data.error?b(new Error(M.data.error)):A(M.data)},f.onerror=()=>{v(),b(new Error(`Could not start the ${i} encoder.`))},f.postMessage(m,C)});await y({init:!0,width:S,height:T});for(let m=0;m<H;m++){t.throwIfAborted();const C=ee(m);h.captureFrame(C,1/te,k,ae(m)),ge(k,e,C,o,r,a);const A=k.getImageData(0,0,S,T).data.buffer;await y({rgba:A,width:S,height:T},[A]),s((m+1)/H)}const _=await y({finish:!0});return new Blob([_.bytes],{type:p})}finally{f?.terminate(),h?.dispose(),c.remove()}}function De(e,l){const t=document.createElement("dialog");t.className="share-dialog",t.setAttribute("aria-labelledby","share-title"),t.innerHTML=`<p>Create a private MP4 video. Project and session names are hidden, and nothing is uploaded.</p>
|
|
4
4
|
<div class="share-preview"><video aria-label="SessionGraph playback with hidden project and session names" muted loop playsinline controls hidden></video><div class="share-progress"><progress max="100" value="0" aria-label="Creating video"></progress><span role="status">Creating video… 0%</span></div></div>
|
|
5
5
|
<p class="share-notice" role="status" hidden></p>
|
|
6
6
|
<div class="share-actions"><button class="text-button share-close">Cancel</button><button class="secondary-button share-retry" hidden>Try again</button><a class="secondary-button share-x" target="_blank" rel="noopener noreferrer" hidden>Share in X</a><button class="secondary-button share-system" aria-label="Open share tray" aria-controls="playback-share-tray" aria-expanded="false" hidden>Share…</button><button class="primary-button share-save" hidden>Save MP4</button></div>
|
package/dist/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<link rel="icon" sizes="any" href="/favicon.ico" />
|
|
13
13
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
14
14
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
15
|
-
<script type="module" crossorigin src="/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-CDA8pT1Q.js"></script>
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/assets/index-cVgPCrFV.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
package/dist-server/cli.mjs
CHANGED
|
@@ -182,6 +182,14 @@ function blockEvents(message2, content, transform = (v3) => v3) {
|
|
|
182
182
|
return [eventFor(message2, id2, "event", `${part.type || "Unknown"} content`, "This content type is not represented as text.", { ...fields2, partial: true })];
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
|
+
function userBlockEvents(message2, content, normalize2) {
|
|
186
|
+
const context = [];
|
|
187
|
+
return blockEvents(message2, content, (value) => {
|
|
188
|
+
const text3 = normalize2(value);
|
|
189
|
+
context.push(Boolean(value && !text3));
|
|
190
|
+
return text3 || value;
|
|
191
|
+
}).map((event) => event.kind === "message" && context.shift() ? { ...event, kind: "event", role: "system", name: "Session context", nativeType: "user-context" } : event);
|
|
192
|
+
}
|
|
185
193
|
function normalizedEvents(message2, sessionID) {
|
|
186
194
|
let events = message2.events;
|
|
187
195
|
if (!events) {
|
|
@@ -31136,7 +31144,7 @@ function withSqliteSnapshot(path, read3, expected, pinned = false) {
|
|
|
31136
31144
|
const retained = copies.get(path);
|
|
31137
31145
|
if (pinned && expected && retained?.revision === expected) return read3(retained.db);
|
|
31138
31146
|
const revision2 = sqliteRevision(path);
|
|
31139
|
-
if (expected && revision2 !== expected) throw new
|
|
31147
|
+
if (expected && revision2 !== expected) throw new SqliteSnapshotChangedError("History database changed during import; import again.");
|
|
31140
31148
|
let copy = copies.get(path);
|
|
31141
31149
|
if (copy?.revision !== revision2) {
|
|
31142
31150
|
close(path);
|
|
@@ -31155,7 +31163,7 @@ function withSqliteSnapshot(path, read3, expected, pinned = false) {
|
|
|
31155
31163
|
throw error;
|
|
31156
31164
|
}
|
|
31157
31165
|
}
|
|
31158
|
-
if (sqliteRevision(path) !== revision2) throw new
|
|
31166
|
+
if (sqliteRevision(path) !== revision2) throw new SqliteSnapshotChangedError("History database changed while copying; import again.");
|
|
31159
31167
|
db2 = new DatabaseSync2(destination, { readOnly: true, enableDoubleQuotedStringLiterals: false, allowExtension: false });
|
|
31160
31168
|
db2.exec("PRAGMA query_only=ON; PRAGMA trusted_schema=OFF; PRAGMA busy_timeout=1000; BEGIN;");
|
|
31161
31169
|
copy = { revision: revision2, directory: directory2, db: db2 };
|
|
@@ -31170,19 +31178,21 @@ function withSqliteSnapshot(path, read3, expected, pinned = false) {
|
|
|
31170
31178
|
}
|
|
31171
31179
|
}
|
|
31172
31180
|
const result = read3(copy.db);
|
|
31173
|
-
if (!pinned && sqliteRevision(path) !== revision2) throw new
|
|
31181
|
+
if (!pinned && sqliteRevision(path) !== revision2) throw new SqliteSnapshotChangedError("History database changed during reading; import again.");
|
|
31174
31182
|
return result;
|
|
31175
31183
|
}
|
|
31176
31184
|
function hasTable(db2, name) {
|
|
31177
31185
|
const row = db2.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name=?").get(name);
|
|
31178
31186
|
return typeof row?.sql === "string" && !/CREATE\s+VIRTUAL/i.test(row.sql);
|
|
31179
31187
|
}
|
|
31180
|
-
var copies, close;
|
|
31188
|
+
var copies, SqliteSnapshotChangedError, close;
|
|
31181
31189
|
var init_sqlite_snapshot = __esm({
|
|
31182
31190
|
"server/adapters/sqlite-snapshot.ts"() {
|
|
31183
31191
|
"use strict";
|
|
31184
31192
|
init_common();
|
|
31185
31193
|
copies = /* @__PURE__ */ new Map();
|
|
31194
|
+
SqliteSnapshotChangedError = class extends Error {
|
|
31195
|
+
};
|
|
31186
31196
|
close = (path) => {
|
|
31187
31197
|
const copy = copies.get(path);
|
|
31188
31198
|
if (!copy) return;
|
|
@@ -31271,18 +31281,23 @@ function sqliteHistoryAdapter(source) {
|
|
|
31271
31281
|
let unavailable = false;
|
|
31272
31282
|
for (const path of await source.paths()) {
|
|
31273
31283
|
try {
|
|
31274
|
-
const snapshot2 = sqliteRevision(path), rev = digest([2, source.id, snapshot2]);
|
|
31284
|
+
const snapshot2 = sqliteRevision(path), rev = digest([source.version || 2, source.id, snapshot2]);
|
|
31275
31285
|
let cached2 = metadata2.get(path);
|
|
31276
31286
|
if (!cached2 || cached2.revision !== rev) {
|
|
31277
31287
|
cached2 = withSqliteSnapshot(path, (db2) => {
|
|
31278
31288
|
const table2 = typeof source.table === "string" ? source.table : source.table(db2);
|
|
31279
31289
|
const values2 = rows(db2, table2, source.fields, void 0, source.key, 2e4), found = [];
|
|
31280
31290
|
const blocked2 = [], warnings2 = [];
|
|
31291
|
+
let empty = 0;
|
|
31281
31292
|
for (const row of values2) {
|
|
31282
31293
|
try {
|
|
31283
31294
|
const h3 = parseHistory(source, db2, row, path);
|
|
31284
31295
|
if (!h3) continue;
|
|
31285
|
-
if (source.history !== false && !h3.messages.length)
|
|
31296
|
+
if (source.history !== false && !h3.messages.length) {
|
|
31297
|
+
blocked2.push(identity(source.id, String(row[source.key])));
|
|
31298
|
+
empty++;
|
|
31299
|
+
continue;
|
|
31300
|
+
}
|
|
31286
31301
|
if (!h3.nativeID || h3.nativeID.length > 512) throw new Error("Missing native session identity.");
|
|
31287
31302
|
const created = time(h3.session?.created) || h3.messages.map((m) => time(m.time)).find(Boolean);
|
|
31288
31303
|
if (!created) throw new Error("Session has no recorded creation or message date.");
|
|
@@ -31302,7 +31317,8 @@ function sqliteHistoryAdapter(source) {
|
|
|
31302
31317
|
blocked2.push(identity(source.id, String(row[source.key])));
|
|
31303
31318
|
}
|
|
31304
31319
|
}
|
|
31305
|
-
if (blocked2.length) warnings2.push(`${blocked2.length} ${source.name} sessions had unsupported, undated, missing, or oversized history; saved imports are kept.`);
|
|
31320
|
+
if (blocked2.length > empty) warnings2.push(`${blocked2.length - empty} ${source.name} sessions had unsupported, undated, missing, or oversized history; saved imports are kept.`);
|
|
31321
|
+
if (empty) warnings2.push(`${empty} empty ${source.name} sessions had no saved messages; previous imports are kept.`);
|
|
31306
31322
|
return { revision: rev, candidates: found, blocked: blocked2, warnings: warnings2 };
|
|
31307
31323
|
}, snapshot2);
|
|
31308
31324
|
metadata2.set(path, cached2);
|
|
@@ -31669,9 +31685,14 @@ function changedPaths(value) {
|
|
|
31669
31685
|
function codexUserText(value) {
|
|
31670
31686
|
if (typeof value !== "string") return "";
|
|
31671
31687
|
let text3 = value.trim();
|
|
31688
|
+
for (; ; ) {
|
|
31689
|
+
const context = text3.match(/^<(environment_context|permissions|user_instructions|turn_aborted|system_instruction|recommended_plugins|external_codex_[\w-]+)(?:\s[^>]*)?>/i);
|
|
31690
|
+
if (!context) break;
|
|
31691
|
+
const end = text3.toLowerCase().indexOf(`</${context[1].toLowerCase()}>`, context[0].length);
|
|
31692
|
+
if (end < 0) return "";
|
|
31693
|
+
text3 = text3.slice(end + context[1].length + 3).trim();
|
|
31694
|
+
}
|
|
31672
31695
|
if (/^# (?:AGENTS\.md|Instructions for)/i.test(text3)) return "";
|
|
31673
|
-
text3 = text3.replace(/<(environment_context|permissions|user_instructions|turn_aborted|external_codex_[\w-]+)>[\s\S]*?<\/\1>/g, "").trim();
|
|
31674
|
-
if (/^<(?:environment_context|permissions|user_instructions|turn_aborted|external_codex_[\w-]+)(?:>|\s)/.test(text3)) return "";
|
|
31675
31696
|
return text3;
|
|
31676
31697
|
}
|
|
31677
31698
|
async function sessionNames() {
|
|
@@ -31724,8 +31745,7 @@ function codexRecord(raw, offset, candidate) {
|
|
|
31724
31745
|
const role = p.role === "user" ? "user" : p.role === "assistant" ? "assistant" : p.type === "message" ? "system" : "tool";
|
|
31725
31746
|
const msg = blankMessage(`item:${raw.ordinal ?? offset}`, Date.parse(raw.timestamp) || 0, role);
|
|
31726
31747
|
const fields2 = { nativeID: p.id, nativeType: p.type, callID: p.call_id };
|
|
31727
|
-
msg.events = p.type === "message" ? blockEvents(msg, p.content) : ["function_call", "custom_tool_call"].includes(p.type) ? [eventFor(msg, "call", "tool_call", p.name || "Tool call", "", { ...fields2, role: "assistant", input: eventText(p.arguments ?? p.input), status: "unknown" })] : ["function_call_output", "custom_tool_call_output"].includes(p.type) ? [eventFor(msg, "result", "tool_result", "Tool result", "", { ...fields2, output: eventText(p.output, 64e3), status: "unknown" })] : [eventFor(msg, "event", p.type === "reasoning" ? "reasoning" : "event", p.type === "reasoning" ? "Recorded reasoning summary" : p.type || "Unknown event", eventText(p.type === "reasoning" ? p.summary : p), { ...fields2, partial: p.type === "reasoning" })];
|
|
31728
|
-
if (role === "user") msg.events = msg.events.map((event) => event.kind === "message" && event.text && !codexUserText(event.text) ? { ...event, kind: "event", role: "system", name: "Session context", nativeType: "user-context" } : event);
|
|
31748
|
+
msg.events = p.type === "message" ? role === "user" ? userBlockEvents(msg, p.content, codexUserText) : blockEvents(msg, p.content) : ["function_call", "custom_tool_call"].includes(p.type) ? [eventFor(msg, "call", "tool_call", p.name || "Tool call", "", { ...fields2, role: "assistant", input: eventText(p.arguments ?? p.input), status: "unknown" })] : ["function_call_output", "custom_tool_call_output"].includes(p.type) ? [eventFor(msg, "result", "tool_result", "Tool result", "", { ...fields2, output: eventText(p.output, 64e3), status: "unknown" })] : [eventFor(msg, "event", p.type === "reasoning" ? "reasoning" : "event", p.type === "reasoning" ? "Recorded reasoning summary" : p.type || "Unknown event", eventText(p.type === "reasoning" ? p.summary : p), { ...fields2, partial: p.type === "reasoning" })];
|
|
31729
31749
|
if (p.type === "message") {
|
|
31730
31750
|
for (const part of Array.isArray(p.content) ? p.content : []) if (["input_text", "output_text", "text"].includes(part.type)) addText(msg, role === "user" ? codexUserText(part.text) : part.text, role === "user" ? "You" : "Assistant");
|
|
31731
31751
|
} else if (["function_call", "custom_tool_call"].includes(p.type)) {
|
|
@@ -31752,7 +31772,7 @@ var init_codex = __esm({
|
|
|
31752
31772
|
root2 = () => sourcePath("codex") || process.env.CODEX_HOME || join10(homedir6(), ".codex");
|
|
31753
31773
|
revision = async (path) => {
|
|
31754
31774
|
const s = await stat2(path);
|
|
31755
|
-
return digest([
|
|
31775
|
+
return digest([9, s.mtimeMs, s.size]);
|
|
31756
31776
|
};
|
|
31757
31777
|
codexAdapter = {
|
|
31758
31778
|
id: "codex",
|
|
@@ -32097,8 +32117,14 @@ var init_t3_code = __esm({
|
|
|
32097
32117
|
async discover() {
|
|
32098
32118
|
const path = await databasePath2();
|
|
32099
32119
|
if (!path) return { sessions: [], projects: [], warnings: ["T3 Code database is unavailable. Saved history is retained."] };
|
|
32100
|
-
|
|
32101
|
-
|
|
32120
|
+
for (let attempt = 0; ; attempt++) {
|
|
32121
|
+
const databaseRevision = sqliteRevision(path);
|
|
32122
|
+
try {
|
|
32123
|
+
return withSqliteSnapshot(path, (db2) => hasTable(db2, "orchestration_v2_projection_threads") ? discoverV2(db2, path, databaseRevision) : discoverV1(db2, path, databaseRevision), databaseRevision);
|
|
32124
|
+
} catch (error) {
|
|
32125
|
+
if (!(error instanceof SqliteSnapshotChangedError) || attempt >= 2) throw error;
|
|
32126
|
+
}
|
|
32127
|
+
}
|
|
32102
32128
|
},
|
|
32103
32129
|
async read(candidate, cursor) {
|
|
32104
32130
|
return withSqliteSnapshot(candidate.locator.path, (db2) => candidate.locator.format === "v2" ? readV2(db2, candidate, cursor) : readV1(db2, candidate, cursor), candidate.locator.databaseRevision, true);
|
|
@@ -32112,8 +32138,26 @@ function cursorTime(value) {
|
|
|
32112
32138
|
const time3 = typeof value === "number" ? value : typeof value === "string" && /(?:Z|[+-]\d\d:\d\d)$/.test(value) ? Date.parse(value) : 0;
|
|
32113
32139
|
return Number.isFinite(time3) && time3 > 0 && time3 <= 864e13 ? time3 : 0;
|
|
32114
32140
|
}
|
|
32141
|
+
function cursorEnvelope(text3) {
|
|
32142
|
+
let value = text3.trim(), timestamp;
|
|
32143
|
+
for (; ; ) {
|
|
32144
|
+
value = value.replace(/^(?:\[Image\]\s*)+(?=<image_files>)/, "");
|
|
32145
|
+
const clock = value.match(/^<timestamp>([^<]+)<\/timestamp>\s*/);
|
|
32146
|
+
if (clock) {
|
|
32147
|
+
timestamp ??= clock[1];
|
|
32148
|
+
value = value.slice(clock[0].length);
|
|
32149
|
+
continue;
|
|
32150
|
+
}
|
|
32151
|
+
const context = value.match(/^<(user_info|environment_context|system_reminder|external_links|attached_files|image_files)(?:\s[^>]*)?>/);
|
|
32152
|
+
if (!context) break;
|
|
32153
|
+
const end = value.indexOf(`</${context[1]}>`, context[0].length);
|
|
32154
|
+
if (end < 0) return { text: "", timestamp };
|
|
32155
|
+
value = value.slice(end + context[1].length + 3).trim();
|
|
32156
|
+
}
|
|
32157
|
+
return { text: value, timestamp };
|
|
32158
|
+
}
|
|
32115
32159
|
function cursorEnvelopeTime(text3) {
|
|
32116
|
-
const value = text3.
|
|
32160
|
+
const value = cursorEnvelope(text3).timestamp;
|
|
32117
32161
|
if (!value) return 0;
|
|
32118
32162
|
const iso = cursorTime(value);
|
|
32119
32163
|
if (iso) return iso;
|
|
@@ -32122,17 +32166,21 @@ function cursorEnvelopeTime(text3) {
|
|
|
32122
32166
|
return cursorTime(Date.parse(`${match2[1]} ${match2[2]} GMT${match2[3]}${match2[4].padStart(2, "0")}${match2[5] || "00"}`));
|
|
32123
32167
|
}
|
|
32124
32168
|
function cursorUserText(text3) {
|
|
32125
|
-
|
|
32126
|
-
for (; ; ) {
|
|
32127
|
-
const stripped = value.replace(/^<(user_info|environment_context|system_reminder)>[\s\S]*?<\/\1>\s*/, "");
|
|
32128
|
-
if (stripped === value) break;
|
|
32129
|
-
value = stripped;
|
|
32130
|
-
}
|
|
32169
|
+
const value = cursorEnvelope(text3).text;
|
|
32131
32170
|
const query = value.match(/^<user_query>([\s\S]*?)<\/user_query>(?:\s*<system_reminder>[\s\S]*?<\/system_reminder>)*\s*$/);
|
|
32132
32171
|
return (query ? query[1] : value).trim();
|
|
32133
32172
|
}
|
|
32134
32173
|
function cursorMessage(raw, fallbackID) {
|
|
32135
32174
|
if (!raw || typeof raw !== "object") return;
|
|
32175
|
+
if (raw.type === "turn_ended") {
|
|
32176
|
+
const message2 = blankMessage(typeof raw.id === "string" && raw.id.length <= 512 ? raw.id : fallbackID, cursorTime(raw.timestamp), "system");
|
|
32177
|
+
const failed = raw.status === "error" || raw.status === "failed";
|
|
32178
|
+
message2.events = [eventFor(message2, "turn-ended", failed ? "error" : "event", failed ? "Cursor turn failed" : "Cursor turn ended", eventText(raw.error), {
|
|
32179
|
+
nativeType: "turn_ended",
|
|
32180
|
+
status: failed ? "failed" : raw.status === "completed" || raw.status === "success" ? "completed" : "unknown"
|
|
32181
|
+
})];
|
|
32182
|
+
return message2;
|
|
32183
|
+
}
|
|
32136
32184
|
const body = raw.message && typeof raw.message === "object" ? raw.message : raw;
|
|
32137
32185
|
const role = raw.role || body.role;
|
|
32138
32186
|
if (!["user", "assistant", "tool", "system"].includes(role)) return;
|
|
@@ -32141,7 +32189,7 @@ function cursorMessage(raw, fallbackID) {
|
|
|
32141
32189
|
const time3 = cursorTime(raw.timestamp) || cursorTime(body.timestamp) || cursorTime(body.createdAt) || (role === "user" && typeof firstText === "string" ? cursorEnvelopeTime(firstText) : 0);
|
|
32142
32190
|
const native = [raw.uuid, raw.id, body.uuid, body.id].find((id2) => typeof id2 === "string" && id2.length && id2.length <= 512);
|
|
32143
32191
|
const msg = blankMessage(native || fallbackID, time3, role);
|
|
32144
|
-
msg.events = role === "tool" ? [eventFor(msg, "result", "tool_result", body.name || "Tool result", "", { callID: body.tool_call_id, output: eventText(content, 64e3), status: "unknown" })] : blockEvents(msg, content);
|
|
32192
|
+
msg.events = role === "tool" ? [eventFor(msg, "result", "tool_result", body.name || "Tool result", "", { callID: body.tool_call_id, output: eventText(content, 64e3), status: "unknown" })] : role === "user" ? userBlockEvents(msg, content, cursorUserText) : blockEvents(msg, content);
|
|
32145
32193
|
const kind = role === "user" ? "You" : role === "assistant" ? "Assistant" : "Tool";
|
|
32146
32194
|
const text3 = (value) => addText(msg, role === "user" && typeof value === "string" ? cursorUserText(value) : value, kind);
|
|
32147
32195
|
if (typeof content === "string") text3(content);
|
|
@@ -32375,7 +32423,7 @@ function discoverComposers(path, workspace = "") {
|
|
|
32375
32423
|
for (const table2 of ["cursorDiskKV", "ItemTable"]) {
|
|
32376
32424
|
if (!hasTable(db2, table2)) continue;
|
|
32377
32425
|
let failed = 0, count = 0;
|
|
32378
|
-
const rows2 = db2.prepare(`SELECT key, CASE WHEN length(value)<=? THEN value END AS value FROM ${table2} WHERE key LIKE 'composerData:%' ORDER BY key LIMIT 20001`).iterate(MAX_VALUE2);
|
|
32426
|
+
const rows2 = db2.prepare(`SELECT key, CASE WHEN length(value)<=? THEN value END AS value FROM ${table2} WHERE key LIKE 'composerData:%' AND value IS NOT NULL ORDER BY key LIMIT 20001`).iterate(MAX_VALUE2);
|
|
32379
32427
|
for (const row of rows2) {
|
|
32380
32428
|
if (++count > 2e4) {
|
|
32381
32429
|
warnings.push("Cursor Composer listing reached its 20,000-session limit.");
|
|
@@ -32396,7 +32444,7 @@ function discoverComposers(path, workspace = "") {
|
|
|
32396
32444
|
session.model = text2(data.modelConfig?.modelName) || "Unknown model";
|
|
32397
32445
|
session.archived = data.isArchived === true;
|
|
32398
32446
|
const children = Array.isArray(data.subagentComposerIds) ? data.subagentComposerIds.filter((id2) => typeof id2 === "string") : [];
|
|
32399
|
-
sessions.push({ session, revision: digest([
|
|
32447
|
+
sessions.push({ session, revision: digest([2, snapshot2, table2, nativeID]), locator: { path, kind: "composer", table: table2, snapshot: snapshot2, nativeID, children: JSON.stringify(children) } });
|
|
32400
32448
|
} catch {
|
|
32401
32449
|
failed++;
|
|
32402
32450
|
}
|
|
@@ -32647,7 +32695,7 @@ function createCursorAdapter(options = {}) {
|
|
|
32647
32695
|
session.projectID = project("cursor", session.directory).id;
|
|
32648
32696
|
if (session.directory) delete locator.directoryNote;
|
|
32649
32697
|
}
|
|
32650
|
-
const candidate = { session, locator, revision: digest([
|
|
32698
|
+
const candidate = { session, locator, revision: digest([5, kind, path, before, session.created, session.directory, session.parentID]) };
|
|
32651
32699
|
if (!previous || rank(candidate) > rank(previous) || rank(candidate) === rank(previous) && session.updated > previous.session.updated) found.set(session.id, candidate);
|
|
32652
32700
|
} catch {
|
|
32653
32701
|
unreadable++;
|
|
@@ -32727,7 +32775,7 @@ function createCursorAdapter(options = {}) {
|
|
|
32727
32775
|
const messages = page2.rows.flatMap((row) => {
|
|
32728
32776
|
const message2 = cursorMessage(row.value, `offset:${row.offset}`);
|
|
32729
32777
|
if (!message2) page2.partial = true;
|
|
32730
|
-
return message2 && message2.role !== "system" ? [message2] : [];
|
|
32778
|
+
return message2 && (message2.role !== "system" || row.value?.type === "turn_ended") ? [message2] : [];
|
|
32731
32779
|
});
|
|
32732
32780
|
await verify();
|
|
32733
32781
|
if (!offset && page2.cursor === void 0 && !messages.length) throw new Error("Cursor transcript has no readable conversation. Previous imports are retained.");
|
|
@@ -33506,6 +33554,14 @@ var init_harness_files = __esm({
|
|
|
33506
33554
|
// server/adapters/harness-databases.ts
|
|
33507
33555
|
import { lstat as lstat6, readFile as readFile4 } from "node:fs/promises";
|
|
33508
33556
|
import { isAbsolute as isAbsolute6, join as join22 } from "node:path";
|
|
33557
|
+
function hermesContent(value) {
|
|
33558
|
+
if (typeof value !== "string" || !value.startsWith("\0json:")) return value;
|
|
33559
|
+
try {
|
|
33560
|
+
return JSON.parse(value.slice(6));
|
|
33561
|
+
} catch {
|
|
33562
|
+
return value;
|
|
33563
|
+
}
|
|
33564
|
+
}
|
|
33509
33565
|
function dbPaths(id2, defaults, match2) {
|
|
33510
33566
|
return async () => {
|
|
33511
33567
|
const override = sourcePath(id2) || process.env[`SESSIONGRAPH_${id2.replace(/-/g, "_").toUpperCase()}_HISTORY_DIR`];
|
|
@@ -33548,7 +33604,7 @@ function forkStore(id2, name, defaultPath, desktop) {
|
|
|
33548
33604
|
}
|
|
33549
33605
|
};
|
|
33550
33606
|
}
|
|
33551
|
-
var
|
|
33607
|
+
var millisOrSeconds, hermes, goose, openclaw, zed, devin, crushDirectories, crush, octofriend, unsloth, kiro, databaseHarnessAdapters;
|
|
33552
33608
|
var init_harness_databases = __esm({
|
|
33553
33609
|
"server/adapters/harness-databases.ts"() {
|
|
33554
33610
|
"use strict";
|
|
@@ -33560,11 +33616,11 @@ var init_harness_databases = __esm({
|
|
|
33560
33616
|
init_harness_paths();
|
|
33561
33617
|
init_harness_files();
|
|
33562
33618
|
init_source_paths();
|
|
33563
|
-
parsedContent = (v3) => typeof v3 === "string" && /^[\[{]/.test(v3.trim()) ? optionalJSON(v3) : v3;
|
|
33564
33619
|
millisOrSeconds = (v3) => typeof v3 === "number" && v3 > 0 && v3 < 1e10 ? seconds(v3) : time(v3);
|
|
33565
33620
|
hermes = {
|
|
33566
33621
|
id: "hermes",
|
|
33567
33622
|
name: "Hermes Agent",
|
|
33623
|
+
version: 3,
|
|
33568
33624
|
paths: async () => (await historyFiles(harnessRoots("hermes", () => [envHome("HERMES_HOME", ".hermes")])(), (p) => p === "state.db" || /^profiles\/[^/]+\/state\.db$/.test(p))).files,
|
|
33569
33625
|
table: "sessions",
|
|
33570
33626
|
key: "id",
|
|
@@ -33572,7 +33628,7 @@ var init_harness_databases = __esm({
|
|
|
33572
33628
|
parse(db2, r) {
|
|
33573
33629
|
const messages = rows(db2, "messages", ["id", "message_uid", "role", "content", "timestamp", "tool_call_id", "tool_calls", "tool_name", "_compressed_summary"], ["session_id", r.id], "id").map((m) => {
|
|
33574
33630
|
if (m._compressed_summary) return recordEvent(m, text2(m.message_uid) || nativeText(m.id), "Context summary", seconds(m.timestamp), m.content);
|
|
33575
|
-
return conversationMessage({ role: m.role, content:
|
|
33631
|
+
return conversationMessage({ role: m.role, content: hermesContent(m.content), timestamp: seconds(m.timestamp), tool_call_id: m.tool_call_id, toolCalls: optionalJSON(m.tool_calls), toolName: m.tool_name }, text2(m.message_uid) || nativeText(m.id));
|
|
33576
33632
|
});
|
|
33577
33633
|
const h3 = sessionHistory({ ...r, created_at: seconds(r.started_at), updated_at: seconds(r.last_activity_at), provider: r.billing_provider }, messages, "Hermes saved message rows, including retained summaries. Compression/reset parent links are not subagent ancestry. Session usage aggregates are not used as message times.");
|
|
33578
33634
|
if (r.source === "subagent") h3.parent = text2(r.parent_session_id) || void 0;
|
|
@@ -34130,10 +34186,13 @@ function normalizeViewState(value) {
|
|
|
34130
34186
|
function visibleSessions(sessions) {
|
|
34131
34187
|
const owners = /* @__PURE__ */ new Map();
|
|
34132
34188
|
for (const session of sessions) {
|
|
34133
|
-
if (session.source !== "t3-code"
|
|
34134
|
-
for (const id2 of session.linkedSessionIDs || []) owners.set(id2, [...owners.get(id2) || [], session
|
|
34189
|
+
if (session.source !== "t3-code") continue;
|
|
34190
|
+
for (const id2 of new Set(session.linkedSessionIDs || [])) owners.set(id2, [...owners.get(id2) || [], session]);
|
|
34135
34191
|
}
|
|
34136
|
-
const unique = new Map([...owners].flatMap(([native,
|
|
34192
|
+
const unique = new Map([...owners].flatMap(([native, claims]) => {
|
|
34193
|
+
const owner = claims[0];
|
|
34194
|
+
return claims.length === 1 && ["complete", "partial"].includes(owner.coverage?.history || "") && owner.activity?.userMessages ? [[native, owner.id]] : [];
|
|
34195
|
+
}));
|
|
34137
34196
|
return sessions.filter((session) => !unique.has(session.id)).map((session) => ({
|
|
34138
34197
|
...session,
|
|
34139
34198
|
parentID: session.parentID ? unique.get(session.parentID) || session.parentID : void 0,
|
|
@@ -34817,6 +34876,7 @@ var Importer = class {
|
|
|
34817
34876
|
} while (cursor);
|
|
34818
34877
|
const values = [...messages.values()];
|
|
34819
34878
|
if (adapter.id === "opencode") values.reverse();
|
|
34879
|
+
if (saved?.activity?.userMessages && values.every((message2) => message2.role === "system")) throw new Error("Source has no readable conversation. Previous imports are retained.");
|
|
34820
34880
|
this.store.replace(candidate, values, partial, note);
|
|
34821
34881
|
this.status.imported++;
|
|
34822
34882
|
} catch (error) {
|