dsh-thoughtdag 0.4.20 → 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-mCpjqoou.js → canonical-BAKMmYtu.js} +2 -2
- package/dist-app/assets/canvas-record-v0T9A4JC.js +1 -0
- package/dist-app/assets/{claude-code-session-DJkcGfvB.js → claude-code-session-WliRGG8W.js} +4 -4
- package/dist-app/assets/{codex-session-Crw7-bHo.js → codex-session-CIpFw1w2.js} +4 -4
- package/dist-app/assets/dsh-session-rxnDGmEX.js +6 -0
- package/dist-app/assets/{experiment-loop-CkNvS6b1.js → experiment-loop-CQaQhKai.js} +1 -1
- package/dist-app/assets/{http-bridge-CJvoQLgy.js → http-bridge-CFJoyZSa.js} +1 -1
- package/dist-app/assets/index-93ujsGjx.css +1 -0
- package/dist-app/assets/{index-B6lBI8ja.js → index-BPz35wb6.js} +1 -1
- package/dist-app/assets/index-D0VdUWYE.js +883 -0
- package/dist-app/assets/{index-CT3R4H-W.js → index-DE0h-KA1.js} +1 -1
- package/dist-app/assets/{index-ZITmlOUw.js → index-DxbomCNl.js} +3 -3
- package/dist-app/assets/{pi-session-CBjuXvCc.js → pi-session-BjtG1-5k.js} +8 -8
- package/dist-app/assets/{sensitive-scan-CjmPZxkv.js → sensitive-scan-Bu7x2N6Y.js} +1 -1
- package/dist-app/assets/{session-handoff-DGfX02CE.js → session-handoff-BYVQEntk.js} +2 -2
- package/dist-app/assets/{shared-z6Es4wHy.js → shared-BuierUP1.js} +4 -4
- package/dist-app/assets/{turndown-plugin-gfm.cjs-KFp3duAG.js → turndown-plugin-gfm.cjs-CukkoPc7.js} +3 -3
- package/dist-app/assets/{update-check-D5kNTq-_.js → update-check-BIhP2KP4.js} +1 -1
- package/dist-app/index.html +2 -2
- package/lib/index.js +50 -1
- package/lib/why.mjs +616 -26
- package/package.json +1 -1
- package/dist-app/assets/canvas-record-di62TikJ.js +0 -1
- package/dist-app/assets/dsh-session-DbEtbF5u.js +0 -6
- package/dist-app/assets/index-B-DuMDps.css +0 -1
- package/dist-app/assets/index-BMFFskkL.js +0 -789
- package/dist-app/assets/live-mirror-D-eP76Rm.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
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,14 +1,14 @@
|
|
|
1
|
-
import{
|
|
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
|
|
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
|
+
`):"";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
|
-
${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(
|
|
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??""}
|
|
5
5
|
--- old
|
|
6
|
-
${
|
|
6
|
+
${o.oldText??""}
|
|
7
7
|
+++ new
|
|
8
|
-
${
|
|
8
|
+
${o.newText??""}`).join(`
|
|
9
9
|
|
|
10
|
-
`);return{...l(d,h),paths:n}}}return e==="run"&&typeof s.command=="string"?{...l(s.command,m),paths:n}:{...l(JSON.stringify(t??{}),m),paths:n,...
|
|
10
|
+
`);return{...l(d,h),paths:n}}}return e==="run"&&typeof s.command=="string"?{...l(s.command,m),paths:n}:{...l(JSON.stringify(t??{}),m),paths:n,...i?{locator:i}:{}}}class q{turns=[];pending=new Map;current=null;sessionId=null;cwd=null;firstQuestion=null;feedLine(t){const s=t.trim();if(!s)return;let e;try{e=JSON.parse(s)}catch{return}this.feed(e)}flush(){const t=this.current;t&&(t.question||t.response||t.tools.length)&&this.turns.push(t),this.current=null}feed(t){if(t.type==="session"&&typeof t.id=="string"){this.sessionId||(this.sessionId=t.id),typeof t.cwd=="string"&&!this.cwd&&(this.cwd=t.cwd);return}if(t.type!=="message"){this.current&&typeof t.id=="string"&&this.current.itemIds.push(t.id);return}const s=t.message;if(s){if(s.role==="user"){const e=f(s.content).trim();if(!e)return;this.flush(),this.firstQuestion||(this.firstQuestion=e.split(`
|
|
11
11
|
`)[0].slice(0,80));const n=typeof t.timestamp=="string"?t.timestamp:typeof s.timestamp=="number"?new Date(s.timestamp).toISOString():void 0;this.current={question:e,response:"",itemIds:typeof t.id=="string"?[t.id]:[],tools:[],...typeof t.parentId=="string"?{parentItemId:t.parentId}:{},...n?{at:n}:{}};return}if(s.role==="assistant"){const e=this.current??(this.current={question:"",response:"",itemIds:[],tools:[]});typeof t.id=="string"&&e.itemIds.push(t.id);const n=f(s.content).trim();if(n&&(e.response=e.response?`${e.response}
|
|
12
12
|
|
|
13
|
-
${n}`:n),Array.isArray(s.content))for(const
|
|
14
|
-
`))t.feedLine(s);return t}function
|
|
13
|
+
${n}`:n),Array.isArray(s.content))for(const i of s.content){if(i?.type!=="toolCall"||typeof i.id!="string"||typeof i.name!="string")continue;const a=b(i.name,i.arguments);this.pending.set(i.id,{name:i.name,call:a.text,truncated:a.truncated,op:I(i.name),paths:a.paths,...a.locator?{locator:a.locator}:{}})}return}if(s.role==="toolResult"){const e=s.toolCallId;if(!e)return;const n=this.pending.get(e);if(!n)return;const i=this.current??(this.current={question:"",response:"",itemIds:[],tools:[]});typeof t.id=="string"&&i.itemIds.push(t.id);const a=l(f(s.content),L);i.tools.push({name:n.name,call:n.call,result:a.text,truncated:n.truncated||a.truncated,op:n.op,nativeCallId:e,...n.paths.length?{paths:n.paths}:{},...n.locator?{locator:n.locator}:{}}),this.pending.delete(e)}}}finish(){if(this.flush(),!this.sessionId)return null;const t=this.firstQuestion??`session ${this.sessionId.slice(0,8)}`;return{sessionId:this.sessionId,title:t,turns:C(this.turns),...this.cwd?{cwd:this.cwd}:{}}}toConversation(){const t=this.finish();return!t||t.turns.length===0?null:{title:t.title,messageCount:t.turns.length,source:"pi",sessionId:t.sessionId,build:()=>M(t.turns,t.sessionId,t.cwd)}}}function y(r){const t=new q;for(const s of r.split(`
|
|
14
|
+
`))t.feedLine(s);return t}function M(r,t,s){const e=s?{cwd:s}:{},n=[],i=[],a=new Map,c=(u,o)=>i.push({id:T(),source:u.id,target:o.id,type:"smoothstep"});let d=null;for(const u of r){const o=w(u.question||"(tool-only turn)",u.response,d===null);o.data.importSource={runner:"pi",sessionId:t,itemIds:u.itemIds,...e},o.data.source={question:o.data.question,response:o.data.response},o.data.attachments=O(u),S(o),n.push(o);const p=u.parentItemId?a.get(u.parentItemId):void 0;p?c(p,o):d&&c(d,o);for(const g of u.itemIds)a.set(g,o);d=o}return{nodes:x(n,i),edges:i}}function _(r,t){const s=y(r).finish();return s?A(s.turns,s.sessionId,"pi",t,s.cwd):null}function Q(r){return y(r).toConversation()}export{q as PiSessionCollector,M as buildGraphFromTurns,_ as piSessionAsBranch,Q as piSessionConversation};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as c,a,
|
|
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,10 +1,10 @@
|
|
|
1
|
-
import{
|
|
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
|
-
${t.result}`,...t.paths?.length?{paths:t.paths}:{},...t.op?{op:t.op}:{}}))}function
|
|
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??""}
|
|
5
5
|
|
|
6
|
-
${n.content}`:
|
|
6
|
+
${n.content}`:o==="edit"&&typeof n.new_string=="string"?`${n.file_path??n.notebook_path??""}${n.replace_all?" (replace all)":""}
|
|
7
7
|
--- old
|
|
8
8
|
${n.old_string??""}
|
|
9
9
|
+++ new
|
|
10
|
-
${n.new_string}`:JSON.stringify(t??{})}export{O as A,S as T,y as a,
|
|
10
|
+
${n.new_string}`:JSON.stringify(t??{})}export{O as A,S as T,y as a,k as b,q as c,M as d,I as e,L as f,x as g,w as m,C as r,b as s,A as t};
|
package/dist-app/assets/{turndown-plugin-gfm.cjs-KFp3duAG.js → turndown-plugin-gfm.cjs-CukkoPc7.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
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+`
|
|
@@ -6,7 +6,7 @@ import{A as W}from"./index-BMFFskkL.js";function Y(d,p){for(var g=0;g<p.length;g
|
|
|
6
6
|
|
|
7
7
|
`}})}function g(t){t.addRule("strikethrough",{filter:["del","s","strike"],replacement:function(e){return"~~"+e+"~~"}})}var s=Array.prototype.indexOf,c=Array.prototype.every,o={},O={left:":---",right:"---:",center:":---:"};let m=null,C=null;const A=new WeakMap;function $(t){return t?(t.getAttribute("align")||t.style.textAlign||"").toLowerCase():""}function k(t){return t?O[t]:"---"}function w(t,e){for(var r={left:0,right:0,center:0,"":0},n="",l=0;l<t.rows.length;++l){var i=t.rows[l];if(e<i.childNodes.length){var a=$(i.childNodes[e]);++r[a],r[a]>r[n]&&(n=a)}}return n}o.tableCell={filter:["th","td"],replacement:function(t,e){return v(P(e))?t:T(t,e)}},o.tableRow={filter:"tr",replacement:function(t,e){const r=P(e);if(v(r))return t;var n="";if(D(e)){const a=_(r);for(var l=0;l<a;l++){const f=l<e.childNodes.length?e.childNodes[l]:null;var i=k(w(r,l));n+=T(i,f,l)}}return`
|
|
8
8
|
`+t+(n?`
|
|
9
|
-
`+n:"")}},o.table={filter:function(t,e){return t.nodeName==="TABLE"},replacement:function(t,e){if(S(e,C)){let f=e.outerHTML,h=
|
|
9
|
+
`+n:"")}},o.table={filter:function(t,e){return t.nodeName==="TABLE"},replacement:function(t,e){if(S(e,C)){let f=e.outerHTML,h=F(e);return h===null||!h.classList.contains("joplin-table-wrapper")?`
|
|
10
10
|
|
|
11
11
|
<div class="joplin-table-wrapper">${f}</div>
|
|
12
12
|
|
|
@@ -19,4 +19,4 @@ import{A as W}from"./index-BMFFskkL.js";function Y(d,p){for(var g=0;g<p.length;g
|
|
|
19
19
|
|
|
20
20
|
${K}${Q}
|
|
21
21
|
|
|
22
|
-
`}}},o.tableCaption={filter:["caption"],replacement:()=>""},o.tableColgroup={filter:["colgroup","col"],replacement:()=>""},o.tableSection={filter:["thead","tbody","tfoot"],replacement:function(t){return t}};function D(t){var e=t.parentNode;return e.nodeName==="THEAD"||e.firstChild===t&&(e.nodeName==="TABLE"||R(e))&&c.call(t.childNodes,function(r){return r.nodeName==="TH"})}function R(t){var e=t.previousSibling;return t.nodeName==="TBODY"&&(!e||e.nodeName==="THEAD"&&/^\s*$/i.test(e.textContent))}function T(t,e=null,r=null){r===null&&(r=s.call(e.parentNode.childNodes,e));var n=" ";r===0&&(n="| ");let l=t.trim().replace(/\n\r/g,"<br>").replace(/\n/g,"<br>");for(l=l.replace(/\|+/g,"\\|");l.length<3;)l+=" ";return e&&(l=
|
|
22
|
+
`}}},o.tableCaption={filter:["caption"],replacement:()=>""},o.tableColgroup={filter:["colgroup","col"],replacement:()=>""},o.tableSection={filter:["thead","tbody","tfoot"],replacement:function(t){return t}};function D(t){var e=t.parentNode;return e.nodeName==="THEAD"||e.firstChild===t&&(e.nodeName==="TABLE"||R(e))&&c.call(t.childNodes,function(r){return r.nodeName==="TH"})}function R(t){var e=t.previousSibling;return t.nodeName==="TBODY"&&(!e||e.nodeName==="THEAD"&&/^\s*$/i.test(e.textContent))}function T(t,e=null,r=null){r===null&&(r=s.call(e.parentNode.childNodes,e));var n=" ";r===0&&(n="| ");let l=t.trim().replace(/\n\r/g,"<br>").replace(/\n/g,"<br>");for(l=l.replace(/\|+/g,"\\|");l.length<3;)l+=" ";return e&&(l=U(l,e," ")),n+l+" |"}function y(t){if(!t.childNodes)return!1;for(let e=0;e<t.childNodes.length;e++){const r=t.childNodes[e];if(r.nodeName==="TABLE"||y(r))return!0}return!1}const b=(t,e)=>{if(!t.childNodes)return!1;for(let r=0;r<t.childNodes.length;r++){const n=t.childNodes[r];if(e==="code"&&m&&m(n)||e.includes(n.nodeName)||b(n,e))return!0}return!1},I=["background-color","background","border-color","border","border-top","border-right","border-bottom","border-left","border-style","border-width","padding","padding-top","padding-right","padding-bottom","padding-left","float","margin-left","margin-right"],B=["bgcolor","bordercolor","background"],G=t=>{if(!t||!t.getAttribute)return!1;const e=t.getAttribute("style");if(!e)return!1;const r=e.split(";").map(n=>n.split(":")[0].trim().toLowerCase()).filter(n=>n.length>0);for(let n=0;n<r.length;n++)if(I.includes(r[n]))return!0;return!1},L=(t,e)=>{if(!t||!t.getAttribute)return!1;const r=t.getAttribute(e);if(r===null)return!1;const n=`${r}`.trim().toLowerCase();return!(!n||n==="0"||n==="0px")},M=t=>{if(!t||!t.getAttribute)return!1;for(let e=0;e<B.length;e++){const r=t.getAttribute(B[e]);if(r!==null&&`${r}`.trim()!=="")return!0}return!!(t.nodeName==="TABLE"&&(L(t,"cellpadding")||L(t,"cellspacing")))},N=t=>G(t)||M(t),q=t=>{if(N(t))return!0;const e=t.rows;if(!e)return!1;for(let r=0;r<e.length;r++){const n=e[r];if(N(n))return!0;for(let l=0;l<n.childNodes.length;l++){const i=n.childNodes[l];if((i.nodeName==="TD"||i.nodeName==="TH")&&N(i))return!0}}return!1},S=(t,e)=>{const r=["UL","OL","H1","H2","H3","H4","H5","H6","HR","BLOCKQUOTE"];return e.preserveNestedTables&&r.push("TABLE"),b(t,"code")||b(t,r)||e.preserveTableStyles&&q(t)};function v(t){const e=A.get(t);if(e!==void 0)return e;const r=z(t);return A.set(t,r),r}function z(t){return!!(!t||!t.rows||t.rows.length===1&&t.rows[0].childNodes.length<=1||y(t))}function F(t){let e=t.parentNode;for(;e.nodeName!=="DIV";)if(e=e.parentNode,!e)return null;return e}function P(t){let e=t.parentNode;for(;e.nodeName!=="TABLE";)if(e=e.parentNode,!e)return null;return e}function U(t,e,r){const n=e.getAttribute("colspan")||1;for(let l=1;l<n;l++)t+=" | "+r.repeat(3);return t}function _(t){let e=0;for(let r=0;r<t.rows.length;r++){const l=t.rows[r].childNodes.length;l>e&&(e=l)}return e}function H(t){m=t.isCodeBlock,C=t.options,t.keep(function(r){return!!(r.nodeName==="TABLE"&&S(r,t.options))});for(var e in o)t.addRule(e,o[e])}function j(t){t.addRule("taskListItems",{filter:function(e){const r=e.parentNode,n=r.parentNode,l=!!n&&n.nodeName==="LI";return(e.type==="checkbox"||e.getAttribute("role")==="checkbox")&&(r.nodeName==="LI"||r.nodeName==="LABEL"&&l||r.nodeName==="SPAN"&&l)},replacement:function(e,r){return((r.nodeName==="INPUT"?r.checked:r.getAttribute("aria-checked")==="true")?"[x]":"[ ]")+" "}})}function V(t){t.use([p,g,H,j])}return u.gfm=V,u.highlightedCodeBlock=p,u.strikethrough=g,u.tables=H,u.taskListItems=j,u}var x=J();const X=W(x),tt=Y({__proto__:null,default:X},[x]);export{tt as t};
|
|
@@ -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,8 +22,8 @@
|
|
|
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-
|
|
26
|
-
<link rel="stylesheet" crossorigin href="/thoughtdag/assets/index-
|
|
25
|
+
<script type="module" crossorigin src="/thoughtdag/assets/index-D0VdUWYE.js"></script>
|
|
26
|
+
<link rel="stylesheet" crossorigin href="/thoughtdag/assets/index-93ujsGjx.css">
|
|
27
27
|
</head>
|
|
28
28
|
<body>
|
|
29
29
|
<div id="root"></div>
|
package/lib/index.js
CHANGED
|
@@ -797,7 +797,7 @@ async function runAgentTurn(ctx, body, emit, isClosed, { answerApprovals = true
|
|
|
797
797
|
const text = blocks.filter(b => b.type === 'text').map(b => b.text).join('')
|
|
798
798
|
if (text) { fullText += text; emit({ text }) }
|
|
799
799
|
}
|
|
800
|
-
} else if (event.type === 'tool/call' || event.type === 'tool/code-dispatch-start') {
|
|
800
|
+
} else if (event.type === 'tool/call' || event.type === 'tool/code-dispatch-start' || event.type === 'tool/ptc-dispatch-start') {
|
|
801
801
|
if (event.data?.callId) turnEntry.calls.set(event.data.callId, { name: event.data?.name ?? 'tool', arguments: event.data?.arguments })
|
|
802
802
|
emit({ tool: { name: event.data?.name ?? 'tool', query: toolQuery(event.data?.name, event.data?.arguments) } })
|
|
803
803
|
} else if (event.type === 'turn/end') {
|
|
@@ -876,6 +876,9 @@ const WHY_PROMPT = `ThoughtDAG why layer. The tools why_check, why_file, why_fin
|
|
|
876
876
|
- why_find(phrase) finds where exact words were asked or answered; why_recall(session, turn) reads one turn in full.
|
|
877
877
|
Cite what you learn briefly; do not restate whole turns.`
|
|
878
878
|
|
|
879
|
+
/** the loaded why library, for the HTTP routes the canvas asks (null until installWhyLayer ran) */
|
|
880
|
+
let whyLib = null
|
|
881
|
+
|
|
879
882
|
async function installWhyLayer(ctx, config) {
|
|
880
883
|
const wantTools = config?.whyTools !== false
|
|
881
884
|
const wantPrompt = config?.whyPrompt !== false
|
|
@@ -891,6 +894,7 @@ async function installWhyLayer(ctx, config) {
|
|
|
891
894
|
return
|
|
892
895
|
}
|
|
893
896
|
whyStatus.loaded = true
|
|
897
|
+
whyLib = why
|
|
894
898
|
const ask = async (mcpName, args, cwd) => {
|
|
895
899
|
const a = { ...args }
|
|
896
900
|
for (const k of PATH_ARGS) if (typeof a[k] === 'string') a[k] = resolveAgainst(cwd, a[k])
|
|
@@ -996,6 +1000,29 @@ export async function apply(ctx, config) {
|
|
|
996
1000
|
return sendJson(res, 200, { session: sessionSummary(session) })
|
|
997
1001
|
}
|
|
998
1002
|
if (path === '/why/status' && req.method === 'GET') return sendJson(res, 200, whyStatus)
|
|
1003
|
+
// ── the why layer for the canvas: find across sessions and memories, recall one turn or entry, list the memory files ──
|
|
1004
|
+
if (path.startsWith('/why/') && req.method === 'GET') {
|
|
1005
|
+
if (!whyLib) return sendJson(res, 503, { error: 'why layer not loaded', ...whyStatus })
|
|
1006
|
+
if (path === '/why/find') {
|
|
1007
|
+
const phrase = url.searchParams.get('phrase') ?? ''
|
|
1008
|
+
const scope = url.searchParams.get('scope') ?? 'all'
|
|
1009
|
+
const limit = Number(url.searchParams.get('limit') ?? 20) || 20
|
|
1010
|
+
const cwd = url.searchParams.get('cwd') ?? undefined
|
|
1011
|
+
return sendJson(res, 200, await whyLib.findJson(phrase, { scope, limit, ...(cwd ? { cwd } : {}) }))
|
|
1012
|
+
}
|
|
1013
|
+
if (path === '/why/recall') {
|
|
1014
|
+
try { return sendJson(res, 200, await whyLib.recallJson(url.searchParams.get('session') ?? '', Number(url.searchParams.get('turn') ?? 0))) }
|
|
1015
|
+
catch (e) { return sendJson(res, 404, { error: e instanceof Error ? e.message : String(e) }) }
|
|
1016
|
+
}
|
|
1017
|
+
if (path === '/why/memories') return sendJson(res, 200, await whyLib.memoriesJson())
|
|
1018
|
+
if (path === '/why/suggest') return sendJson(res, 200, await whyLib.suggestJson(url.searchParams.get('term') ?? '', Number(url.searchParams.get('limit') ?? 8) || 8))
|
|
1019
|
+
if (path === '/why/topics') return sendJson(res, 200, await whyLib.topicsJson())
|
|
1020
|
+
if (path === '/why/by-topic') return sendJson(res, 200, await whyLib.byTopicJson((url.searchParams.get('ids') ?? '').split(',').filter(Boolean), { minP: Number(url.searchParams.get('minP') ?? 0.6) || 0.6, limit: Number(url.searchParams.get('limit') ?? 60) || 60 }))
|
|
1021
|
+
if (path === '/why/sample') return sendJson(res, 200, await whyLib.sampleQuestions(Number(url.searchParams.get('n') ?? 120) || 120))
|
|
1022
|
+
if (path === '/why/dossiers') return sendJson(res, 200, await whyLib.dossiersJson())
|
|
1023
|
+
if (path === '/why/dossier') return sendJson(res, 200, await whyLib.dossierJson(url.searchParams.get('id') ?? ''))
|
|
1024
|
+
if (path === '/why/dossier/new') return sendJson(res, 200, await whyLib.dossierNewTurns(url.searchParams.get('id') ?? '', { limit: Number(url.searchParams.get('limit') ?? 120) || 120 }))
|
|
1025
|
+
}
|
|
999
1026
|
if (path === '/version' && req.method === 'GET') return sendJson(res, 200, { version: PLUGIN_VERSION, latest: await latestPluginVersion(), checkedAt: latestLookup.at || null })
|
|
1000
1027
|
// ── the other agents' session files ──
|
|
1001
1028
|
if (path === '/roots' && req.method === 'GET') {
|
|
@@ -1020,6 +1047,28 @@ export async function apply(ctx, config) {
|
|
|
1020
1047
|
return sendJson(res, 200, await rangeOfFile(abs, url.searchParams.get('start'), url.searchParams.get('length')))
|
|
1021
1048
|
}
|
|
1022
1049
|
// ── link snapshots: the SPA's /api/fetch-url on the harness's bounded fetcher ──
|
|
1050
|
+
// ── topics: the table and the labelling job (POST) ──
|
|
1051
|
+
if (path.startsWith('/why/') && req.method === 'POST') {
|
|
1052
|
+
if (!whyLib) return sendJson(res, 503, { error: 'why layer not loaded', ...whyStatus })
|
|
1053
|
+
const body = await readJson(req)
|
|
1054
|
+
if (path === '/why/topics') return sendJson(res, 200, await whyLib.setTopics(Array.isArray(body?.topics) ? body.topics : []))
|
|
1055
|
+
if (path === '/why/label/start') { try { return sendJson(res, 200, await whyLib.labelStart(body?.call, body?.opts ?? {})) } catch (e) { return sendJson(res, 400, { error: e instanceof Error ? e.message : String(e) }) } }
|
|
1056
|
+
if (path === '/why/label/stop') return sendJson(res, 200, whyLib.labelStop())
|
|
1057
|
+
if (path === '/why/dossier') return sendJson(res, 200, await whyLib.setDossier(String(body?.id ?? ''), body?.dossier ?? {}))
|
|
1058
|
+
if (path === '/why/dossier/delete') { await whyLib.deleteDossier(String(body?.id ?? '')); return sendJson(res, 200, { ok: true }) }
|
|
1059
|
+
if (path === '/why/dossier/pending') return sendJson(res, 200, await whyLib.dossierAddPending(String(body?.id ?? ''), body?.item ?? { text: '' }))
|
|
1060
|
+
}
|
|
1061
|
+
// ── the judge (a System One decision endpoint) forwarded for the canvas; the key rides in the request ──
|
|
1062
|
+
if (path === '/judge' && req.method === 'POST') {
|
|
1063
|
+
const body = await readJson(req)
|
|
1064
|
+
const target = typeof body?.url === 'string' ? body.url.trim() : ''
|
|
1065
|
+
if (!/^https?:\/\//i.test(target)) return sendJson(res, 400, { error: 'url must be http(s)' })
|
|
1066
|
+
try {
|
|
1067
|
+
const r = await fetch(target, { method: 'POST', headers: { 'Content-Type': 'application/json', ...(body.headers && typeof body.headers === 'object' ? body.headers : {}) }, body: JSON.stringify(body.body ?? {}), signal: AbortSignal.timeout(60000) })
|
|
1068
|
+
const text = await r.text()
|
|
1069
|
+
res.writeHead(r.status, { 'content-type': 'application/json; charset=utf-8' }); res.end(text || '{}'); return
|
|
1070
|
+
} catch (error) { return sendJson(res, 502, { error: error instanceof Error ? error.message : String(error) }) }
|
|
1071
|
+
}
|
|
1023
1072
|
if (path === '/fetch-url' && req.method === 'POST') {
|
|
1024
1073
|
const body = await readJson(req)
|
|
1025
1074
|
const target = typeof body?.url === 'string' ? body.url.trim() : ''
|