dsh-thoughtdag 0.5.0 → 0.5.1
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-app/assets/{canonical-BlzQbV3x.js → canonical-BAKMmYtu.js} +2 -2
- package/dist-app/assets/{canvas-record-CHx9KBrZ.js → canvas-record-v0T9A4JC.js} +1 -1
- package/dist-app/assets/{claude-code-session-BfwTY3ne.js → claude-code-session-WliRGG8W.js} +1 -1
- package/dist-app/assets/{codex-session-BNnk6Ozy.js → codex-session-CIpFw1w2.js} +1 -1
- package/dist-app/assets/dsh-session-rxnDGmEX.js +6 -0
- package/dist-app/assets/{experiment-loop-CBfcRt8t.js → experiment-loop-CQaQhKai.js} +1 -1
- package/dist-app/assets/{http-bridge-CK02uyVL.js → http-bridge-CFJoyZSa.js} +1 -1
- package/dist-app/assets/{index-no3SFEm4.js → index-BPz35wb6.js} +1 -1
- package/dist-app/assets/{index-F8ykUu-e.js → index-D0VdUWYE.js} +147 -147
- package/dist-app/assets/{index-U1FDd3d6.js → index-DE0h-KA1.js} +1 -1
- package/dist-app/assets/{index-Vln2-D4p.js → index-DxbomCNl.js} +3 -3
- package/dist-app/assets/{pi-session-DfX1QntM.js → pi-session-BjtG1-5k.js} +1 -1
- package/dist-app/assets/{sensitive-scan-NeBfDua2.js → sensitive-scan-Bu7x2N6Y.js} +1 -1
- package/dist-app/assets/{session-handoff-Bi6J6owx.js → session-handoff-BYVQEntk.js} +2 -2
- package/dist-app/assets/{shared-B_zE0vyL.js → shared-BuierUP1.js} +1 -1
- package/dist-app/assets/{turndown-plugin-gfm.cjs-t7mTv0d4.js → turndown-plugin-gfm.cjs-CukkoPc7.js} +1 -1
- package/dist-app/assets/{update-check-CmPLQTC0.js → update-check-BIhP2KP4.js} +1 -1
- package/dist-app/index.html +1 -1
- package/lib/why.mjs +67 -28
- package/package.json +1 -1
- package/dist-app/assets/dsh-session-BXjdZH-4.js +0 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as Os,y as pn,z as Is}from"./index-
|
|
1
|
+
import{x as Os,y as pn,z as Is}from"./index-D0VdUWYE.js";function Ns(e,n){for(var t=0;t<n.length;t++){const r=n[t];if(typeof r!="string"&&!Array.isArray(r)){for(const c in r)if(c!=="default"&&!(c in e)){const i=Object.getOwnPropertyDescriptor(r,c);i&&Object.defineProperty(e,c,i.get?i:{enumerable:!0,get:()=>r[c]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Ze={},Ii="1.13.8",Fa=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||Function("return this")()||{},nr=Array.prototype,Ni=Object.prototype,Ca=typeof Symbol<"u"?Symbol.prototype:null,Ls=nr.push,dt=nr.slice,it=Ni.toString,Ms=Ni.hasOwnProperty,$c=typeof ArrayBuffer<"u",qs=typeof DataView<"u",Ps=Array.isArray,Sa=Object.keys,Ba=Object.create,ka=$c&&ArrayBuffer.isView,zs=isNaN,js=isFinite,Yc=!{toString:null}.propertyIsEnumerable("toString"),Wa=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],Xs=Math.pow(2,53)-1;function ze(e,n){return n=n==null?e.length-1:+n,function(){for(var t=Math.max(arguments.length-n,0),r=Array(t),c=0;c<t;c++)r[c]=arguments[c+n];switch(n){case 0:return e.call(this,r);case 1:return e.call(this,arguments[0],r);case 2:return e.call(this,arguments[0],arguments[1],r)}var i=Array(n+1);for(c=0;c<n;c++)i[c]=arguments[c];return i[n]=r,e.apply(this,i)}}function bn(e){var n=typeof e;return n==="function"||n==="object"&&!!e}function Kc(e){return e===null}function Li(e){return e===void 0}function Mi(e){return e===!0||e===!1||it.call(e)==="[object Boolean]"}function Qc(e){return!!(e&&e.nodeType===1)}function Pe(e){var n="[object "+e+"]";return function(t){return it.call(t)===n}}const tr=Pe("String"),qi=Pe("Number"),Jc=Pe("Date"),eu=Pe("RegExp"),nu=Pe("Error"),Pi=Pe("Symbol"),zi=Pe("ArrayBuffer");var tu=Pe("Function"),Vs=Fa.document&&Fa.document.childNodes;typeof/./!="function"&&typeof Int8Array!="object"&&typeof Vs!="function"&&(tu=function(e){return typeof e=="function"||!1});const qe=tu,ru=Pe("Object");var iu=qs&&(!/\[native code\]/.test(String(DataView))||ru(new DataView(new ArrayBuffer(8)))),ji=typeof Map<"u"&&ru(new Map),Hs=Pe("DataView");function Gs(e){return e!=null&&qe(e.getInt8)&&zi(e.buffer)}const at=iu?Gs:Hs,yn=Ps||Pe("Array");function Dn(e,n){return e!=null&&Ms.call(e,n)}var Ri=Pe("Arguments");(function(){Ri(arguments)||(Ri=function(e){return Dn(e,"callee")})})();const rr=Ri;function au(e){return!Pi(e)&&js(e)&&!isNaN(parseFloat(e))}function Xi(e){return qi(e)&&zs(e)}function Vi(e){return function(){return e}}function ou(e){return function(n){var t=e(n);return typeof t=="number"&&t>=0&&t<=Xs}}function cu(e){return function(n){return n?.[e]}}const Yt=cu("byteLength"),Zs=ou(Yt);var $s=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;function Ys(e){return ka?ka(e)&&!at(e):Zs(e)&&$s.test(it.call(e))}const Hi=$c?Ys:Vi(!1),Me=cu("length");function Ks(e){for(var n={},t=e.length,r=0;r<t;++r)n[e[r]]=!0;return{contains:function(c){return n[c]===!0},push:function(c){return n[c]=!0,e.push(c)}}}function uu(e,n){n=Ks(n);var t=Wa.length,r=e.constructor,c=qe(r)&&r.prototype||Ni,i="constructor";for(Dn(e,i)&&!n.contains(i)&&n.push(i);t--;)i=Wa[t],i in e&&e[i]!==c[i]&&!n.contains(i)&&n.push(i)}function Oe(e){if(!bn(e))return[];if(Sa)return Sa(e);var n=[];for(var t in e)Dn(e,t)&&n.push(t);return Yc&&uu(e,n),n}function su(e){if(e==null)return!0;var n=Me(e);return typeof n=="number"&&(yn(e)||tr(e)||rr(e))?n===0:Me(Oe(e))===0}function Gi(e,n){var t=Oe(n),r=t.length;if(e==null)return!r;for(var c=Object(e),i=0;i<r;i++){var a=t[i];if(n[a]!==c[a]||!(a in c))return!1}return!0}function Ae(e){if(e instanceof Ae)return e;if(!(this instanceof Ae))return new Ae(e);this._wrapped=e}Ae.VERSION=Ii;Ae.prototype.value=function(){return this._wrapped};Ae.prototype.valueOf=Ae.prototype.toJSON=Ae.prototype.value;Ae.prototype.toString=function(){return String(this._wrapped)};function Ra(e){return new Uint8Array(e.buffer||e,e.byteOffset||0,Yt(e))}var Oa="[object DataView]";function du(e,n){for(var t=[{a:e,b:n}],r=[],c=[];t.length;){var i=t.pop();if(i===!0){r.pop(),c.pop();continue}if(e=i.a,n=i.b,e===n){if(e!==0||1/e===1/n)continue;return!1}if(e==null||n==null)return!1;if(e!==e){if(n!==n)continue;return!1}var a=typeof e;if(a!=="function"&&a!=="object"&&typeof n!="object")return!1;e instanceof Ae&&(e=e._wrapped),n instanceof Ae&&(n=n._wrapped);var o=it.call(e);if(o!==it.call(n))return!1;if(iu&&o=="[object Object]"&&at(e)){if(!at(n))return!1;o=Oa}switch(o){case"[object RegExp]":case"[object String]":if(""+e==""+n)continue;return!1;case"[object Number]":t.push({a:+e,b:+n});continue;case"[object Date]":case"[object Boolean]":if(+e==+n)continue;return!1;case"[object Symbol]":if(Ca.valueOf.call(e)===Ca.valueOf.call(n))continue;return!1;case"[object ArrayBuffer]":case Oa:t.push({a:Ra(e),b:Ra(n)});continue}var u=o==="[object Array]";if(!u&&Hi(e)){var h=Yt(e);if(h!==Yt(n))return!1;if(e.buffer===n.buffer&&e.byteOffset===n.byteOffset)continue;u=!0}if(!u){if(typeof e!="object"||typeof n!="object")return!1;var b=e.constructor,m=n.constructor;if(b!==m&&!(qe(b)&&b instanceof b&&qe(m)&&m instanceof m)&&"constructor"in e&&"constructor"in n)return!1}for(var g=r.length;g--;)if(r[g]===e){if(c[g]===n)break;return!1}if(!(g>=0))if(r.push(e),c.push(n),t.push(!0),u){if(g=e.length,g!==n.length)return!1;for(;g--;)t.push({a:e[g],b:n[g]})}else{var f=Oe(e),y;if(g=f.length,Oe(n).length!==g)return!1;for(;g--;){if(y=f[g],!Dn(n,y))return!1;t.push({a:e[y],b:n[y]})}}}return!0}function jn(e){if(!bn(e))return[];var n=[];for(var t in e)n.push(t);return Yc&&uu(e,n),n}function Zi(e){var n=Me(e);return function(t){if(t==null)return!1;var r=jn(t);if(Me(r))return!1;for(var c=0;c<n;c++)if(!qe(t[e[c]]))return!1;return e!==hu||!qe(t[$i])}}var $i="forEach",lu="has",Yi=["clear","delete"],fu=["get",lu,"set"],Qs=Yi.concat($i,fu),hu=Yi.concat(fu),Js=["add"].concat(Yi,$i,lu);const pu=ji?Zi(Qs):Pe("Map"),gu=ji?Zi(hu):Pe("WeakMap"),mu=ji?Zi(Js):Pe("Set"),bu=Pe("WeakSet");function kn(e){for(var n=Oe(e),t=n.length,r=Array(t),c=0;c<t;c++)r[c]=e[n[c]];return r}function yu(e){for(var n=Oe(e),t=n.length,r=Array(t),c=0;c<t;c++)r[c]=[n[c],e[n[c]]];return r}function Ki(e){for(var n={},t=Oe(e),r=0,c=t.length;r<c;r++)n[e[t[r]]]=t[r];return n}function ot(e){var n=[];for(var t in e)qe(e[t])&&n.push(t);return n.sort()}function Qi(e,n){return function(t){var r=arguments.length;if(n&&(t=Object(t)),r<2||t==null)return t;for(var c=1;c<r;c++)for(var i=arguments[c],a=e(i),o=a.length,u=0;u<o;u++){var h=a[u];(!n||t[h]===void 0)&&(t[h]=i[h])}return t}}const Ji=Qi(jn),Pn=Qi(Oe),ea=Qi(jn,!0);function ed(){return function(){}}function Du(e){if(!bn(e))return{};if(Ba)return Ba(e);var n=ed();n.prototype=e;var t=new n;return n.prototype=null,t}function vu(e,n){var t=Du(e);return n&&Pn(t,n),t}function xu(e){return bn(e)?yn(e)?e.slice():Ji({},e):e}function _u(e,n){return n(e),e}function na(e){return yn(e)?e:[e]}Ae.toPath=na;function lt(e){return Ae.toPath(e)}function ta(e,n){for(var t=n.length,r=0;r<t;r++){if(e==null)return;e=e[n[r]]}return t?e:void 0}function ra(e,n,t){var r=ta(e,lt(n));return Li(r)?t:r}function Uu(e,n){n=lt(n);for(var t=n.length,r=0;r<t;r++){var c=n[r];if(!Dn(e,c))return!1;e=e[c]}return!!t}function ir(e){return e}function Bn(e){return e=Pn({},e),function(n){return Gi(n,e)}}function ar(e){return e=lt(e),function(n){return ta(n,e)}}function ft(e,n,t){if(n===void 0)return e;switch(t??3){case 1:return function(r){return e.call(n,r)};case 3:return function(r,c,i){return e.call(n,r,c,i)};case 4:return function(r,c,i,a){return e.call(n,r,c,i,a)}}return function(){return e.apply(n,arguments)}}function Tu(e,n,t){return e==null?ir:qe(e)?ft(e,n,t):bn(e)&&!yn(e)?Bn(e):ar(e)}function or(e,n){return Tu(e,n,1/0)}Ae.iteratee=or;function je(e,n,t){return Ae.iteratee!==or?Ae.iteratee(e,n):Tu(e,n,t)}function wu(e,n,t){n=je(n,t);for(var r=Oe(e),c=r.length,i={},a=0;a<c;a++){var o=r[a];i[o]=n(e[o],o,e)}return i}function ia(){}function Eu(e){return e==null?ia:function(n){return ra(e,n)}}function Au(e,n,t){var r=Array(Math.max(0,e));n=ft(n,t,1);for(var c=0;c<e;c++)r[c]=n(c);return r}function Kt(e,n){return n==null&&(n=e,e=0),e+Math.floor(Math.random()*(n-e+1))}const zn=Date.now||function(){return new Date().getTime()};function Fu(e){var n=function(i){return e[i]},t="(?:"+Oe(e).join("|")+")",r=RegExp(t),c=RegExp(t,"g");return function(i){return i=i==null?"":""+i,r.test(i)?i.replace(c,n):i}}const Cu={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Su=Fu(Cu),nd=Ki(Cu),Bu=Fu(nd),ku=Ae.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var Fr=/(.)^/,td={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},rd=/\\|'|\r|\n|\u2028|\u2029/g;function id(e){return"\\"+td[e]}var ad=/^\s*(\w|\$)+\s*$/;function Wu(e,n,t){!n&&t&&(n=t),n=ea({},n,Ae.templateSettings);var r=RegExp([(n.escape||Fr).source,(n.interpolate||Fr).source,(n.evaluate||Fr).source].join("|")+"|$","g"),c=0,i="__p+='";e.replace(r,function(h,b,m,g,f){return i+=e.slice(c,f).replace(rd,id),c=f+h.length,b?i+=`'+
|
|
2
2
|
((__t=(`+b+`))==null?'':_.escape(__t))+
|
|
3
3
|
'`:m?i+=`'+
|
|
4
4
|
((__t=(`+m+`))==null?'':__t)+
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/claude-code-session-
|
|
2
|
-
import{_ as e}from"./index-
|
|
3
|
-
`);n=w.pop()??"";for(const l of w)r.feedLine(l),a.feedLine(l),c.feedLine(l),o.feedLine(l)}return n&&(r.feedLine(n),a.feedLine(n),c.feedLine(n),o.feedLine(n)),r.toConversation()??a.toConversation()??c.toConversation()??o.toConversation()}async function f(s,i){const{claudeCodeSessionAsBranch:_}=await e(async()=>{const{claudeCodeSessionAsBranch:n}=await import("./claude-code-session-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/claude-code-session-WliRGG8W.js","assets/index-D0VdUWYE.js","assets/index-93ujsGjx.css","assets/shared-BuierUP1.js","assets/codex-session-CIpFw1w2.js","assets/dsh-session-rxnDGmEX.js","assets/pi-session-BjtG1-5k.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as e}from"./index-D0VdUWYE.js";async function S(s){const{claudeCodeSessionConversation:i}=await e(async()=>{const{claudeCodeSessionConversation:o}=await import("./claude-code-session-WliRGG8W.js");return{claudeCodeSessionConversation:o}},__vite__mapDeps([0,1,2,3])),_=i(s);if(_)return _;const{codexSessionConversation:u}=await e(async()=>{const{codexSessionConversation:o}=await import("./codex-session-CIpFw1w2.js");return{codexSessionConversation:o}},__vite__mapDeps([4,1,2,3])),d=u(s);if(d)return d;const{dshSessionConversation:r}=await e(async()=>{const{dshSessionConversation:o}=await import("./dsh-session-rxnDGmEX.js");return{dshSessionConversation:o}},__vite__mapDeps([5,1,2,3])),a=r(s);if(a)return a;const{piSessionConversation:c}=await e(async()=>{const{piSessionConversation:o}=await import("./pi-session-BjtG1-5k.js");return{piSessionConversation:o}},__vite__mapDeps([6,1,2,3]));return c(s)}async function E(s){const{ClaudeSessionCollector:i}=await e(async()=>{const{ClaudeSessionCollector:t}=await import("./claude-code-session-WliRGG8W.js");return{ClaudeSessionCollector:t}},__vite__mapDeps([0,1,2,3])),{CodexSessionCollector:_}=await e(async()=>{const{CodexSessionCollector:t}=await import("./codex-session-CIpFw1w2.js");return{CodexSessionCollector:t}},__vite__mapDeps([4,1,2,3])),{DshSessionCollector:u}=await e(async()=>{const{DshSessionCollector:t}=await import("./dsh-session-rxnDGmEX.js");return{DshSessionCollector:t}},__vite__mapDeps([5,1,2,3])),{PiSessionCollector:d}=await e(async()=>{const{PiSessionCollector:t}=await import("./pi-session-BjtG1-5k.js");return{PiSessionCollector:t}},__vite__mapDeps([6,1,2,3])),r=new i,a=new _,c=new u,o=new d;let n="";for(let t=await s();t!==null;t=await s()){if(!t)continue;const w=(n+t).split(`
|
|
3
|
+
`);n=w.pop()??"";for(const l of w)r.feedLine(l),a.feedLine(l),c.feedLine(l),o.feedLine(l)}return n&&(r.feedLine(n),a.feedLine(n),c.feedLine(n),o.feedLine(n)),r.toConversation()??a.toConversation()??c.toConversation()??o.toConversation()}async function f(s,i){const{claudeCodeSessionAsBranch:_}=await e(async()=>{const{claudeCodeSessionAsBranch:n}=await import("./claude-code-session-WliRGG8W.js");return{claudeCodeSessionAsBranch:n}},__vite__mapDeps([0,1,2,3])),u=_(s,i);if(u)return u;const{codexSessionAsBranch:d}=await e(async()=>{const{codexSessionAsBranch:n}=await import("./codex-session-CIpFw1w2.js");return{codexSessionAsBranch:n}},__vite__mapDeps([4,1,2,3])),r=d(s,i);if(r)return r;const{dshSessionAsBranch:a}=await e(async()=>{const{dshSessionAsBranch:n}=await import("./dsh-session-rxnDGmEX.js");return{dshSessionAsBranch:n}},__vite__mapDeps([5,1,2,3])),c=a(s,i);if(c)return c;const{piSessionAsBranch:o}=await e(async()=>{const{piSessionAsBranch:n}=await import("./pi-session-BjtG1-5k.js");return{piSessionAsBranch:n}},__vite__mapDeps([6,1,2,3]));return o(s,i)}export{f as anyRunnerSessionAsBranch,S as anyRunnerSessionConversation,E as streamRunnerConversation};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{q as w,A as x,n as T}from"./index-
|
|
1
|
+
import{q as w,A as x,n as T}from"./index-D0VdUWYE.js";import{t as A,a as I,e as l,d as C,T as L,A as h,g as m,f as O,s as S}from"./shared-BuierUP1.js";const f=r=>typeof r=="string"?r:Array.isArray(r)?r.filter(t=>t&&t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
2
2
|
`):"";function b(r,t){const s=t&&typeof t=="object"?t:{},e=I(r),n=typeof s.path=="string"&&s.path&&(e==="read"||e==="edit"||e==="write")?[s.path]:[];let i;if(e==="read"&&(typeof s.offset=="number"||typeof s.limit=="number")){const c=Math.max(1,typeof s.offset=="number"?s.offset:1),d=typeof s.limit=="number"?c+Math.max(0,s.limit)-1:c;i={lines:[c,Math.max(c,d)]}}if(e==="write"&&typeof s.content=="string")return{...l(`${s.path??""}
|
|
3
3
|
|
|
4
4
|
${s.content}`,h),paths:n};if(e==="edit"){const c=Array.isArray(s.edits)?s.edits:typeof s.newText=="string"?[{oldText:s.oldText,newText:s.newText}]:[];if(c.length){const d=c.map(o=>`${s.path??""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as c,a,v as g}from"./index-
|
|
1
|
+
import{f as c,a,v as g}from"./index-D0VdUWYE.js";const k=[{kind:"sk-… key",re:/\bsk-[A-Za-z0-9_-]{16,}\b/g},{kind:"GitHub token",re:/\bgh[pousr]_[A-Za-z0-9]{20,}\b/g},{kind:"AWS access key",re:/\bAKIA[0-9A-Z]{16}\b/g},{kind:"Slack token",re:/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g},{kind:"Google API key",re:/\bAIza[0-9A-Za-z_-]{35}\b/g},{kind:"JWT",re:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{6,}\b/g},{kind:"private key block",re:/-----BEGIN [A-Z ]*PRIVATE KEY-----/g},{kind:"token assignment",re:/\b(?:API_KEY|APIKEY|SECRET|TOKEN|PASSWORD|ACCESS_KEY|AUTH_TOKEN)[A-Z_]*\s*[=:]\s*['"]?[A-Za-z0-9_/+-]{16,}/g},{kind:"HuggingFace token",re:/\bhf_[A-Za-z0-9]{30,}\b/g},{kind:"npm token",re:/\bnpm_[A-Za-z0-9]{30,}\b/g}],f=t=>t.length<=10?`${t.slice(0,4)}…`:`${t.slice(0,6)}…${t.slice(-2)}`;function o(t,e,s){if(t)for(const{kind:i,re:n}of k){n.lastIndex=0;const r=n.exec(t);if(r&&s.push({where:e,kind:i,sample:f(r[0])}),s.length>=20)return}}function l(t){const e=[];for(const s of t){const i=(s.data.question||s.data.summaries?.[0]||s.id).replace(/\s+/g," ").slice(0,28);o(s.data.question,i,e);for(const n of s.data.responses??[])o(n,i,e);for(const n of s.data.attachments??[])n.type.startsWith("image/")||o(n.content,`${i} · ${n.name}`,e);if(e.length>=20)break}return e}async function b(t){const e=l(t);if(e.length===0)return!0;const s=e.slice(0,5).map(n=>`· ${n.where} — ${n.kind}(${n.sample})`).join(`
|
|
2
2
|
`),i=e.length>5?`
|
|
3
3
|
${c(a("sensitive.more"),{n:e.length-5})}`:"";return g({title:a("sensitive.title"),message:`${c(a("sensitive.body"),{n:e.length})}
|
|
4
4
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/canonical-
|
|
2
|
-
import{t as n,a as e,_ as p,f as a,u as h}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/canonical-BAKMmYtu.js","assets/index-D0VdUWYE.js","assets/index-93ujsGjx.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as n,a as e,_ as p,f as a,u as h}from"./index-D0VdUWYE.js";const l=/^http:\/\/(127\.0\.0\.1|localhost|\[::1\])(:\d+)?\//i;async function w(){const s=window.location.hash,r=s.match(/[#&]import-url=([^&]+)/);if(!r)return;const c=/[#&]mode=harvest\b/.test(s);history.replaceState(null,"",window.location.pathname+window.location.search);const i=decodeURIComponent(r[1]);if(!l.test(i)){n("error",e("handoff.notLoopback"),9e3);return}try{const o=await fetch(i);if(!o.ok)throw new Error(`HTTP ${o.status}`);const d=await o.text(),{importOrAppendSession:f}=await p(async()=>{const{importOrAppendSession:u}=await import("./canonical-BAKMmYtu.js");return{importOrAppendSession:u}},__vite__mapDeps([0,1,2])),t=await f(d);if(!t)throw new Error(e("handoff.notASession"));t.kind==="appended"?n("success",a(e("atlas.appended"),{n:t.turns}),9e3):t.kind==="mounted"?n("success",a(e(t.mode==="continue"?"atlas.mountedChapter":"atlas.mountedBranch"),{n:t.turns}),12e3):t.kind==="opened"?n("info",e("atlas.upToDate"),6e3):n("info",a(e("handoff.saved"),{n:t.nodeCount}),12e3,{label:e("handoff.backupAction"),run:()=>h.getState().setBackupDialogOpen(!0)})}catch(o){n("error",a(e("handoff.failed"),{msg:o instanceof Error?o.message:String(o)}),12e3)}}export{w as consumeSessionHandoff};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{q as m,n as p,A as h,B as g}from"./index-
|
|
1
|
+
import{q as m,n as p,A as h,B as g}from"./index-D0VdUWYE.js";const _=[[/^(Read|NotebookRead|read_file|view_image)$/i,"read"],[/^(Write|write_file)$/i,"write"],[/^(Edit|MultiEdit|NotebookEdit|apply_patch)$/i,"edit"],[/^(Bash|BashOutput|Shell|exec_command|local_shell|write_stdin)$/i,"run"],[/^(Grep|Glob|LS|Search|WebSearch|web_search)$/i,"search"],[/^(WebFetch|Fetch)$/i,"fetch"],[/^(Task|Agent)$/i,"agent"]];function y(e){return _.find(([t])=>t.test(e))?.[1]??"other"}const x=800,O=32e3,S=4e3,I=(e,t)=>e.length>t?{text:`${e.slice(0,t)}
|
|
2
2
|
…[truncated, ${e.length} chars total]`,truncated:!0}:{text:e,truncated:!1},$=["<command-name>/thoughtdag</command-name>","[[thoughtdag:command]]"];function M(e){return e.filter(t=>!$.some(n=>t.question.includes(n)))}function w(e){e.width=460}function b(e){const t=g(e.data.response,90);t&&(e.data.summaries=[t])}function L(e){return e.tools.map(t=>({id:p(),name:`tool: ${t.name}${t.truncated?" (truncated)":""}`,type:"text/plain",size:t.call.length+t.result.length,content:`[call] ${t.call}
|
|
3
3
|
[result]
|
|
4
4
|
${t.result}`,...t.paths?.length?{paths:t.paths}:{},...t.op?{op:t.op}:{}}))}function A(e,t,n,o,i){if(e.length===0)return null;const r=[],l=[];let u={id:o.id};for(const s of e){const a=m(s.question||"(tool-only turn)",s.response,!1);a.data.importSource={runner:n,sessionId:t,itemIds:s.itemIds,...i?{cwd:i}:{}},a.data.source={question:a.data.question,response:a.data.response},a.data.attachments=L(s),b(a),r.length===0&&(a.data.isBranch=!0),r.push(a),l.push({id:p(),source:u.id,target:a.id,type:"smoothstep"}),u=a}const c=h(r,l.filter(s=>s.source!==o.id)),f=Math.min(...c.map(s=>s.position.x)),d=Math.min(...c.map(s=>s.position.y));for(const s of c)s.position={x:s.position.x-f+o.x+560,y:s.position.y-d+o.y};return{nodes:c,edges:l,turnCount:e.length}}function k(e){const t=e??{},n={};typeof t.url=="string"&&/^https?:\/\//.test(t.url)&&(n.url=t.url);const o={};if(typeof t.pages=="string"&&t.pages.trim()&&(o.pages=t.pages.trim()),typeof t.offset=="number"||typeof t.limit=="number"){const i=Math.max(1,typeof t.offset=="number"?t.offset:1),r=typeof t.limit=="number"?i+Math.max(0,t.limit)-1:i;o.lines=[i,Math.max(i,r)]}return Object.keys(o).length&&(n.locator=o),n}function q(e){const t=e??{},n=t.file_path??t.notebook_path;return typeof n=="string"&&n?[n]:[]}function C(e,t){const n=t??{},o=y(e);return o==="write"&&typeof n.content=="string"?`${n.file_path??""}
|
package/dist-app/assets/{turndown-plugin-gfm.cjs-t7mTv0d4.js → turndown-plugin-gfm.cjs-CukkoPc7.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as W}from"./index-
|
|
1
|
+
import{z as W}from"./index-D0VdUWYE.js";function Y(d,p){for(var g=0;g<p.length;g++){const s=p[g];if(typeof s!="string"&&!Array.isArray(s)){for(const c in s)if(c!=="default"&&!(c in d)){const o=Object.getOwnPropertyDescriptor(s,c);o&&Object.defineProperty(d,c,o.get?o:{enumerable:!0,get:()=>s[c]})}}}return Object.freeze(Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}))}var u={},E;function J(){if(E)return u;E=1,Object.defineProperty(u,"__esModule",{value:!0});var d=/highlight-(?:text|source)-([a-z0-9]+)/;function p(t){t.addRule("highlightedCodeBlock",{filter:function(e){var r=e.firstChild;return e.nodeName==="DIV"&&d.test(e.className)&&r&&r.nodeName==="PRE"},replacement:function(e,r,n){var l=r.className||"",i=(l.match(d)||[null,""])[1];return`
|
|
2
2
|
|
|
3
3
|
`+n.fence+i+`
|
|
4
4
|
`+r.firstChild.textContent+`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as u,a as n,f}from"./index-
|
|
1
|
+
import{t as u,a as n,f}from"./index-D0VdUWYE.js";const h=15*6e4;let i=!1;const d=new URLSearchParams(window.location.search),s=d.get("dv"),p=d.get("su")==="1",w=30*6e4;let c=!1,r=0;async function a(){if(!(!s||p||c)&&!(Date.now()-r<w)){r=Date.now();try{const t=await fetch("https://api.github.com/repos/chenxiachan/thoughtdag/releases?per_page=1");if(!t.ok)return;const o=(await t.json())?.[0]?.tag_name?.replace(/^v/,"");if(!o||o===s)return;c=!0,u("info",f(n("update.desktopAvailable"),{v:o}),0,{label:n("update.desktopDownload"),run:()=>window.open("https://chenxiachan.github.io/thoughtdag/#download","_blank")})}catch{}}}function v(){for(const t of document.querySelectorAll("script[src]")){const e=t.src.match(/assets\/index-[^/?#]+\.js/);if(e)return e[0]}return null}async function m(){try{const t=await fetch(`${window.location.pathname}?u=${Date.now()}`,{cache:"no-store"});if(!t.ok)return null;const e=(await t.text()).match(/assets\/index-[^"'?#]+\.js/);return e?e[0]:null}catch{return null}}async function l(){if(i)return;const t=v();if(!t)return;const e=await m();e&&e!==t&&(i=!0,u("info",n("update.available"),0,{label:n("update.refresh"),run:()=>window.location.reload()}))}function b(){document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(l(),a())}),setInterval(()=>{l(),a()},h),s&&setTimeout(()=>{a()},5e3)}export{b as bootUpdateCheck};
|
package/dist-app/index.html
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<meta name="twitter:title" content="ThoughtDAG — Your thinking deserves a map" />
|
|
23
23
|
<meta name="twitter:description" content="Wires are the context: an infinite canvas where LLM conversations grow into an editable thought graph. No signup; the example canvas needs no key." />
|
|
24
24
|
<meta name="twitter:image" content="https://app.thoughtdag.workers.dev/og-twitter.jpg" />
|
|
25
|
-
<script type="module" crossorigin src="/thoughtdag/assets/index-
|
|
25
|
+
<script type="module" crossorigin src="/thoughtdag/assets/index-D0VdUWYE.js"></script>
|
|
26
26
|
<link rel="stylesheet" crossorigin href="/thoughtdag/assets/index-93ujsGjx.css">
|
|
27
27
|
</head>
|
|
28
28
|
<body>
|
package/lib/why.mjs
CHANGED
|
@@ -964,6 +964,12 @@ function buildGraphFromTurns2(turns, sessionId, cwd) {
|
|
|
964
964
|
}
|
|
965
965
|
|
|
966
966
|
// ../src/lib/adapters/dsh-session.ts
|
|
967
|
+
function resultFailed(data) {
|
|
968
|
+
if (!data) return false;
|
|
969
|
+
if (data.error) return true;
|
|
970
|
+
const parts = data.message?.content;
|
|
971
|
+
return Array.isArray(parts) && parts.some((p) => !!p && typeof p === "object" && p.isError === true);
|
|
972
|
+
}
|
|
967
973
|
function partsText(content, depth = 0) {
|
|
968
974
|
if (typeof content === "string") return content;
|
|
969
975
|
if (!Array.isArray(content) || depth > 2) return "";
|
|
@@ -1073,16 +1079,15 @@ ${text}` : text;
|
|
|
1073
1079
|
if (!reg) return;
|
|
1074
1080
|
const res = clipText(partsText(tr.data?.message?.content), TOOL_RESULT_LIMIT);
|
|
1075
1081
|
const t = this.ensure();
|
|
1082
|
+
const failed = resultFailed(tr.data);
|
|
1076
1083
|
t.tools.push({
|
|
1077
1084
|
name: reg.name,
|
|
1078
1085
|
call: reg.call,
|
|
1079
1086
|
result: res.text,
|
|
1080
1087
|
truncated: reg.truncated || res.truncated,
|
|
1081
|
-
op: reg.op,
|
|
1088
|
+
op: failed ? "other" : reg.op,
|
|
1082
1089
|
nativeCallId: callId,
|
|
1083
|
-
...reg.paths.length ? { paths: reg.paths } : {},
|
|
1084
|
-
...reg.url ? { url: reg.url } : {},
|
|
1085
|
-
...reg.locator ? { locator: reg.locator } : {}
|
|
1090
|
+
...failed ? {} : { ...reg.paths.length ? { paths: reg.paths } : {}, ...reg.url ? { url: reg.url } : {}, ...reg.locator ? { locator: reg.locator } : {} }
|
|
1086
1091
|
});
|
|
1087
1092
|
this.pendingTools.delete(callId);
|
|
1088
1093
|
return;
|
|
@@ -1093,6 +1098,12 @@ ${text}` : text;
|
|
|
1093
1098
|
const paths = toolPaths(d.arguments);
|
|
1094
1099
|
const scope = toolScope(d.arguments);
|
|
1095
1100
|
if (!paths.length && !scope.url) return;
|
|
1101
|
+
if (d.isError === true) {
|
|
1102
|
+
const attempt = clipText(renderCall(d.name, d.arguments), TOOL_CALL_LIMIT);
|
|
1103
|
+
const err = clipText(partsText(d.content), TOOL_RESULT_LIMIT);
|
|
1104
|
+
this.ensure().tools.push({ name: d.name, call: attempt.text, result: err.text, truncated: attempt.truncated || err.truncated, op: "other", nativeCallId: d.subCallId });
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1096
1107
|
const op = toolOpOf(d.name);
|
|
1097
1108
|
const call = clipText(renderCall(d.name, d.arguments), op === "write" || op === "edit" ? ARTIFACT_CALL_LIMIT : TOOL_CALL_LIMIT);
|
|
1098
1109
|
const res = clipText(partsText(d.content), TOOL_RESULT_LIMIT);
|
|
@@ -2009,7 +2020,7 @@ ${a.extractedText.slice(0, 4e3)}`).join("\n\n");
|
|
|
2009
2020
|
|
|
2010
2021
|
// ../cli/src/lib.ts
|
|
2011
2022
|
var readLike = (op) => op === "read" || op === "fetch" || op === "attach";
|
|
2012
|
-
var INDEX_VERSION =
|
|
2023
|
+
var INDEX_VERSION = 13;
|
|
2013
2024
|
var EXCERPT = 200;
|
|
2014
2025
|
var HOME = process.env.THOUGHTDAG_HOME ?? path.join(os.homedir(), ".thoughtdag");
|
|
2015
2026
|
var FACT_FILE = path.join(HOME, "fact-index.json");
|
|
@@ -2444,21 +2455,21 @@ async function readJson(file, empty) {
|
|
|
2444
2455
|
var tmpFor = (file) => `${file}.${process.pid}.${Date.now().toString(36)}.tmp`;
|
|
2445
2456
|
var LOCK_FILE = path.join(HOME, "index.lock");
|
|
2446
2457
|
var LOCK_STALE_MS = 10 * 6e4;
|
|
2447
|
-
async function acquireLock() {
|
|
2458
|
+
async function acquireLock(file = LOCK_FILE, staleMs = LOCK_STALE_MS) {
|
|
2448
2459
|
await fsp.mkdir(HOME, { recursive: true, mode: 448 });
|
|
2449
2460
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
2450
2461
|
try {
|
|
2451
|
-
const fh = await fsp.open(
|
|
2462
|
+
const fh = await fsp.open(file, "wx", 384);
|
|
2452
2463
|
await fh.writeFile(JSON.stringify({ pid: process.pid, at: Date.now() }));
|
|
2453
2464
|
await fh.close();
|
|
2454
2465
|
return async () => {
|
|
2455
|
-
await fsp.rm(
|
|
2466
|
+
await fsp.rm(file, { force: true }).catch(() => void 0);
|
|
2456
2467
|
};
|
|
2457
2468
|
} catch (err) {
|
|
2458
2469
|
if (err.code !== "EEXIST") throw err;
|
|
2459
2470
|
let holder = {};
|
|
2460
2471
|
try {
|
|
2461
|
-
holder = JSON.parse(await fsp.readFile(
|
|
2472
|
+
holder = JSON.parse(await fsp.readFile(file, "utf8"));
|
|
2462
2473
|
} catch {
|
|
2463
2474
|
}
|
|
2464
2475
|
const alive = (() => {
|
|
@@ -2470,9 +2481,9 @@ async function acquireLock() {
|
|
|
2470
2481
|
return false;
|
|
2471
2482
|
}
|
|
2472
2483
|
})();
|
|
2473
|
-
const stale = !alive || !holder.at || Date.now() - holder.at >
|
|
2484
|
+
const stale = !alive || !holder.at || Date.now() - holder.at > staleMs;
|
|
2474
2485
|
if (!stale) return null;
|
|
2475
|
-
await fsp.rm(
|
|
2486
|
+
await fsp.rm(file, { force: true }).catch(() => void 0);
|
|
2476
2487
|
}
|
|
2477
2488
|
}
|
|
2478
2489
|
return null;
|
|
@@ -2964,6 +2975,7 @@ ${r.response.trim() || "(none)"}
|
|
|
2964
2975
|
for (const t of r.tools) {
|
|
2965
2976
|
out.push(`- ${t.name}${t.paths?.length ? ` ${t.paths.join(", ")}` : ""}`);
|
|
2966
2977
|
if (t.op === "edit" || t.op === "write") out.push(t.call.slice(0, 1200).split("\n").map((l) => ` ${l}`).join("\n"));
|
|
2978
|
+
else if (t.op === "other" && /^error\b/i.test(t.result.trimStart())) out.push(` \u2717 ${t.result.trim().split("\n")[0].slice(0, 200)}`);
|
|
2967
2979
|
}
|
|
2968
2980
|
}
|
|
2969
2981
|
return out.join("\n");
|
|
@@ -3260,27 +3272,54 @@ async function dossiersJson() {
|
|
|
3260
3272
|
async function dossierJson(topicId) {
|
|
3261
3273
|
return (await loadDossiers()).byTopic[topicId] ?? null;
|
|
3262
3274
|
}
|
|
3275
|
+
var DOSSIERS_LOCK = path.join(HOME, "dossiers.lock");
|
|
3276
|
+
var DOSSIERS_LOCK_WAIT_MS = 5e3;
|
|
3277
|
+
var dossierWrites = Promise.resolve();
|
|
3278
|
+
async function withDossiers(fn) {
|
|
3279
|
+
const run = async () => {
|
|
3280
|
+
let release = null;
|
|
3281
|
+
const deadline = Date.now() + DOSSIERS_LOCK_WAIT_MS;
|
|
3282
|
+
while (!(release = await acquireLock(DOSSIERS_LOCK, 3e4)) && Date.now() < deadline) await new Promise((r) => setTimeout(r, 60));
|
|
3283
|
+
try {
|
|
3284
|
+
const df = await loadDossiers();
|
|
3285
|
+
const out = fn(df);
|
|
3286
|
+
await writePrivate(DOSSIERS_FILE, df);
|
|
3287
|
+
return out;
|
|
3288
|
+
} finally {
|
|
3289
|
+
await release?.();
|
|
3290
|
+
}
|
|
3291
|
+
};
|
|
3292
|
+
const p = dossierWrites.then(run, run);
|
|
3293
|
+
dossierWrites = p.catch(() => void 0);
|
|
3294
|
+
return p;
|
|
3295
|
+
}
|
|
3263
3296
|
async function setDossier(topicId, d) {
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3297
|
+
return withDossiers((df) => {
|
|
3298
|
+
const cur = df.byTopic[topicId] ?? emptyDossier(topicId);
|
|
3299
|
+
const { consumePending, ...rest } = d;
|
|
3300
|
+
const patch = Object.fromEntries(Object.entries(rest).filter(([, v]) => v !== void 0));
|
|
3301
|
+
const next = { ...cur, ...patch, topicId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3302
|
+
if (consumePending) {
|
|
3303
|
+
const read = new Set(consumePending);
|
|
3304
|
+
next.pending = cur.pending.filter((p) => !read.has(p.id));
|
|
3305
|
+
}
|
|
3306
|
+
df.byTopic[topicId] = next;
|
|
3307
|
+
return next;
|
|
3308
|
+
});
|
|
3270
3309
|
}
|
|
3271
3310
|
async function deleteDossier(topicId) {
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3311
|
+
await withDossiers((df) => {
|
|
3312
|
+
delete df.byTopic[topicId];
|
|
3313
|
+
});
|
|
3275
3314
|
}
|
|
3276
3315
|
async function dossierAddPending(topicId, item) {
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3316
|
+
return withDossiers((df) => {
|
|
3317
|
+
const cur = df.byTopic[topicId] ?? emptyDossier(topicId);
|
|
3318
|
+
cur.pending.push({ id: shortHash(`${Date.now()}:${cur.pending.length}:${item.text}`), text: item.text.slice(0, 400), at: (/* @__PURE__ */ new Date()).toISOString(), ...item.from ? { from: item.from } : {} });
|
|
3319
|
+
cur.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3320
|
+
df.byTopic[topicId] = cur;
|
|
3321
|
+
return cur;
|
|
3322
|
+
});
|
|
3284
3323
|
}
|
|
3285
3324
|
async function dossierNewTurns(topicId, opts = {}) {
|
|
3286
3325
|
const d = (await loadDossiers()).byTopic[topicId];
|
|
@@ -3326,7 +3365,7 @@ async function memoriesJson() {
|
|
|
3326
3365
|
const facts = await ensureFresh();
|
|
3327
3366
|
return Object.values(facts.sessions).filter((x) => x.kind === "memory").sort((a, b) => b.mtime - a.mtime).map((x) => ({ id: x.id, runner: x.runner, file: x.file, title: x.title, cwd: x.cwd, entries: x.turns.length, mtime: x.mtime, headings: x.turns.map((t) => t.q) }));
|
|
3328
3367
|
}
|
|
3329
|
-
var CLI_VERSION = "0.2.
|
|
3368
|
+
var CLI_VERSION = "0.2.1";
|
|
3330
3369
|
var MCP_TOOLS = [
|
|
3331
3370
|
{ name: "why_check", description: "Cheap first question before editing a file: does this artifact have any history in local agent sessions? One line; history true/false.", inputSchema: { type: "object", properties: { path: { type: "string", description: "file path (absolute or relative to cwd), URL, or arxiv:<id>" } }, required: ["path"] } },
|
|
3332
3371
|
{ name: "why_file", description: "The turns across local Claude Code, Codex, DeepSeek Harness, Pi and ThoughtDAG sessions that touched a file, URL or paper: when, what changed (\u0394, observed), what was asked, what the answer said about it (\u2248, a candidate explanation, not a verified reason). Each hit carries a deep link.", inputSchema: { type: "object", properties: { path: { type: "string" }, include_read: { type: "boolean", description: "also list turns that only read it (default false)" }, limit: { type: "number", description: "max hits (default 10)" } }, required: ["path"] } },
|
package/package.json
CHANGED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{q as T,A as w,n as C}from"./index-F8ykUu-e.js";import{t as x,a as l,b as f,c as p,e as d,r as g,d as L,T as m,A as h,g as I,f as A,s as S}from"./shared-B_zE0vyL.js";function c(o,s=0){return typeof o=="string"?o:!Array.isArray(o)||s>2?"":o.map(t=>{if(!t||typeof t!="object")return"";const e=t;return e.type==="text"&&typeof e.text=="string"?e.text:e.type==="image"?"[image omitted]":e.type==="reasoning"?"":c(e.text??e.content,s+1)}).filter(Boolean).join(`
|
|
2
|
-
`)}function q(o,s,t){const e=l(o);if(e==="run"||/^run_code$/i.test(o)){const r=t??{};return d(typeof r.code=="string"?r.code:s,h)}const n=t&&typeof t=="object"?g(o,t):s;return d(n,e==="write"||e==="edit"?h:I)}const O=o=>{try{return JSON.parse(o??"")}catch{return}};class b{turns=[];pendingTools=new Map;current=null;sessionId=null;cwd=null;title=null;firstQuestion=null;feedLine(s){const t=s.trim();if(!t)return;let e;try{e=JSON.parse(t)}catch{return}this.feed(e)}flush(){const s=this.current;s&&(s.question||s.response||s.tools.length)&&this.turns.push(s),this.current=null}ensure(){return this.current||(this.current={question:"",response:"",itemIds:[],tools:[]}),this.current}feed(s){if(s.type==="session"&&s.id&&!("timestamp"in s)){this.sessionId||(this.sessionId=s.id),s.cwd&&!this.cwd&&(this.cwd=s.cwd);return}if(s.type==="session/title"&&s.data?.title&&!this.title){this.title=s.data.title;return}if(s.type==="user/message"){const t=s,e=t.data?.source?.kind;if(e&&e!=="user")return;const n=c(t.data?.content).trim();if(!n)return;this.firstQuestion||(this.firstQuestion=n.split(`
|
|
3
|
-
`)[0].slice(0,80)),this.flush();const r=this.ensure();r.question=n,r.itemIds=[t.data?.id??`u${t.seq}`],t.time&&(r.at=new Date(t.time).toISOString());return}if(s.type==="assistant/message"&&this.current){const t=s,e=t.data?.message?.content,n=c(e).trim(),r=t.data?.message?.id;r&&this.current.itemIds.push(r),n&&(this.current.response=this.current.response?`${this.current.response}
|
|
4
|
-
|
|
5
|
-
${n}`:n);return}if(s.type==="tool/call"){const t=s;if(!t.data?.callId||!t.data?.name)return;const e=/^run_code$/i.test(t.data.name)?"run":l(t.data.name),n=O(t.data.arguments),r=q(t.data.name,t.data.arguments??"",n),i=e==="run"?{}:f(n);this.pendingTools.set(t.data.callId,{name:t.data.name,call:r.text,truncated:r.truncated,op:e,paths:e==="run"?[]:p(n),...i});return}if(s.type==="tool/result"){const t=s,e=t.data?.message?.source?.callId;if(!e)return;const n=this.pendingTools.get(e);if(!n)return;const r=d(c(t.data?.message?.content),m);this.ensure().tools.push({name:n.name,call:n.call,result:r.text,truncated:n.truncated||r.truncated,op:n.op,nativeCallId:e,...n.paths.length?{paths:n.paths}:{},...n.url?{url:n.url}:{},...n.locator?{locator:n.locator}:{}}),this.pendingTools.delete(e);return}if(s.type==="tool/code-dispatch"||s.type==="tool/ptc-dispatch"){const t=s.data;if(!t?.name||!t.subCallId)return;const e=p(t.arguments),n=f(t.arguments);if(!e.length&&!n.url)return;const r=l(t.name),i=d(g(t.name,t.arguments),r==="write"||r==="edit"?h:I),u=d(c(t.content),m);this.ensure().tools.push({name:t.name,call:i.text,result:u.text,truncated:i.truncated||u.truncated,op:r,nativeCallId:t.subCallId,...e.length?{paths:e}:{},...n.url?{url:n.url}:{},...n.locator?{locator:n.locator}:{}});return}}finish(){if(this.flush(),!this.sessionId)return null;const s=this.firstQuestion??null,t=this.title??s??`session ${this.sessionId.replace(/^session-/,"").slice(0,8)}`;return{sessionId:this.sessionId,title:t,turns:L(this.turns),...this.cwd?{cwd:this.cwd}:{}}}toConversation(){const s=this.finish();return!s||s.turns.length===0?null:{title:s.title,messageCount:s.turns.length,source:"dsh",sessionId:s.sessionId,build:()=>_(s.turns,s.sessionId,s.cwd)}}}function y(o){const s=new b;for(const t of o.split(`
|
|
6
|
-
`))s.feedLine(t);return s}function _(o,s,t){const e=t?{cwd:t}:{},n=[],r=[];let i=null;for(const u of o){const a=T(u.question||"(tool-only turn)",u.response,i===null);a.data.importSource={runner:"dsh",sessionId:s,itemIds:u.itemIds,...e},a.data.source={question:a.data.question,response:a.data.response},a.data.attachments=A(u),S(a),n.push(a),i&&r.push({id:C(),source:i.id,target:a.id,type:"smoothstep"}),i=a}return{nodes:w(n,r),edges:r}}function k(o,s){const t=y(o).finish();return t?x(t.turns,t.sessionId,"dsh",s,t.cwd):null}function M(o){return y(o).toConversation()}export{b as DshSessionCollector,_ as buildGraphFromTurns,k as dshSessionAsBranch,M as dshSessionConversation};
|