@pickaxeproject/react 6.11.0 → 6.11.2
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/cjs/common/chatMessages.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Scroll/hooks/useScroll.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/cjs/hooks/pickaxe/useConversation.js +1 -1
- package/dist/cjs/src/common/chatMessages.d.ts +3 -1
- package/dist/esm/common/chatMessages.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Scroll/hooks/useScroll.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/esm/hooks/pickaxe/useConversation.js +1 -1
- package/dist/esm/src/common/chatMessages.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=t=>{if("string"==typeof t)return t;if(null==t)return"";try{return JSON.stringify(t)}catch(e){return String(t)}},e=e=>{if(!e||"object"!=typeof e)return null;const r=e;return"string"!=typeof r.type?null:{type:r.type,content:t(r.content),isVisible:!1!==r.isVisible}},r=(t,r)=>{let s=t;if("string"==typeof s)try{const t=JSON.parse(s);Array.isArray(t)&&(s=t)}catch(t){}if(Array.isArray(s))return s.map(e).filter((t=>null!==t));const n=e(s);if(n)return[n];const i="string"==typeof s?s:r;return"string"==typeof i&&i?[{type:"text",content:i,isVisible:!0}]:[]},s=t=>{const e=r(t.parts).filter((t=>!1!==t.isVisible)),s=e.filter((t=>"text"===t.type)).map((t=>{var e;return null!==(e=t.content)&&void 0!==e?e:""})).join(""),n=s.replace(/\s+/g," ").replace(/\s*([.,!?;:])\s*/g,"$1").trim();return n?JSON.stringify({role:t.role,text:n}):JSON.stringify({role:t.role,parts:e.map((t=>{var e;return{type:t.type,content:null!==(e=t.content)&&void 0!==e?e:""}}))})};exports.getUnpersistedMemoryMessages=(t,e)=>{if(!e.length||!t.length)return t;const r=e.map(s),n=new Set(e.filter((t=>"assistant"===t.role)).map(s));let i=0;return t.filter((t=>{const e=s(t),o=r.indexOf(e,i);return-1!==o?(i=o+1,!1):"assistant"!==t.role||!n.has(e)}))},exports.normalizeHistoryMessages=t=>Array.isArray(t)?t.flatMap((t=>{var e;if(!t||"object"!=typeof t)return[];const s=t;return"user"!==s.role&&"assistant"!==s.role?[]:[Object.assign(Object.assign({},s),{documentIds:Array.isArray(s.documentIds)?s.documentIds.filter((t=>"string"==typeof t)):[],parts:r(s.parts,null!==(e=s.content)&&void 0!==e?e:s.message)})]})):[],exports.normalizeMessageParts=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./useScrollContext.js");exports.useScroll=({auto:t=!1,debug:o,smooth:n=!0})=>{const{scrollContainerRef:l,scrollTargetRef:c,hasScrolledRef:s,isLocked:u,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./useScrollContext.js");exports.useScroll=({auto:t=!1,debug:o,smooth:n=!0})=>{const{scrollContainerRef:l,scrollTargetRef:c,hasScrolledRef:s,isLocked:u,isScrollIncreasing:i,setIsLocked:a,setIsScrollSession:d,setIsScrolling:h,setIsScrollIncreasing:v}=r.useScrollContext(),b=e.useRef(null),f=e.useRef(null),g=e.useRef(!1),m=e.useRef(0),w=e.useCallback((()=>{null!==b.current&&(cancelAnimationFrame(b.current),b.current=null)}),[]),C=e.useCallback((e=>{f.current&&clearTimeout(f.current),f.current=setTimeout((()=>{g.current=!1,h(!1)}),"smooth"===e?400:100)}),[h]),S=e.useCallback(((e={})=>{var r;if(!e.force&&s.current)return;const t=null!==(r=e.behavior)&&void 0!==r?r:n?"smooth":"auto",u=l.current,i=c.current;if(u||i){if(g.current=!0,h(!0),u){const e=Math.max(0,u.scrollHeight-u.clientHeight);u.scrollTo({top:e,behavior:t})}else if(i){const e=i.getBoundingClientRect().bottom+window.scrollY,r=Math.max(0,e-window.innerHeight);window.scrollTo({top:r,behavior:t})}o&&console.log("[useScroll] scrolled to the active bottom"),C(t)}else o&&console.log("[useScroll] no scroll element detected")}),[o,C,s,l,c,h,n]),T=e.useCallback(((e={})=>{w(),b.current=requestAnimationFrame((()=>{b.current=null,S(e)}))}),[w,S]),R=e.useCallback(((e={})=>{var r;if(!e.force&&s.current)return;const t=c.current;if(!t)return void(o&&console.log("[useScroll] scroll target not detected"));const l=null!==(r=e.behavior)&&void 0!==r?r:n?"smooth":"auto",u=t.getBoundingClientRect().bottom+window.scrollY,i=Math.max(0,u-500);g.current=!0,h(!0),window.scrollTo({top:i,behavior:l}),o&&console.log("[useScroll] scrolled to the form response"),C(l)}),[o,C,s,c,h,n]),p=e.useCallback(((e={})=>{w(),b.current=requestAnimationFrame((()=>{b.current=null,R(e)}))}),[w,R]),E=e.useCallback((()=>{s.current=!1,a(!0),d(!0)}),[s,a,d]),k=e.useCallback((()=>{d(!1)}),[d]),H=e.useCallback(((e={})=>T(e)),[T]),L=e.useCallback(((e={})=>p(e)),[p]);return e.useEffect((()=>{if(!t||!u)return;let e=l.current,r=c.current,o=null,n=[];const s=()=>{var t;if(!o)return;const n=e?Math.max(0,e.scrollHeight-e.clientHeight):null!==(t=null==r?void 0:r.getBoundingClientRect().height)&&void 0!==t?t:0,l=n>m.current;m.current=n,v(l),l&&(e?T({behavior:"auto"}):p({behavior:"auto"}))},i=new ResizeObserver(s);function a(){o&&(n.forEach((e=>i.unobserve(e))),n=[o,...Array.from(o.children)],n.forEach((e=>i.observe(e))))}const d=new MutationObserver((()=>{a(),s()}));let h=null;const b=()=>{var t;e=l.current,r=c.current;const n=null!=e?e:r;return!(!n||n===o)&&(d.disconnect(),i.disconnect(),o=n,m.current=e?Math.max(0,e.scrollHeight-e.clientHeight):null!==(t=null==r?void 0:r.getBoundingClientRect().height)&&void 0!==t?t:0,a(),d.observe(o,{childList:!0,subtree:!0}),e?T({behavior:"auto"}):p({behavior:"auto"}),!0)};return b()||(h=new MutationObserver((()=>{b()&&(null==h||h.disconnect())})),h.observe(document.body,{childList:!0,subtree:!0})),()=>{null==h||h.disconnect(),d.disconnect(),i.disconnect()}}),[t,u,T,p,l,c,v]),e.useEffect((()=>{u&&(s.current=!1)}),[s,u]),e.useEffect((()=>{const e=l.current,r=null!=e?e:window,t=()=>{if(g.current)return;const r=(()=>{if(e)return e.scrollHeight-e.scrollTop-e.clientHeight<=32;const r=c.current;return!r||r.getBoundingClientRect().bottom-window.innerHeight<=32})();s.current=!r,a(r)},o=()=>{g.current&&(g.current=!1,h(!1),f.current&&(clearTimeout(f.current),f.current=null),e?e.scrollTo({top:e.scrollTop,behavior:"auto"}):window.scrollTo({top:window.scrollY,behavior:"auto"}))};return r.addEventListener("scroll",t,{passive:!0}),r.addEventListener("wheel",o,{passive:!0}),r.addEventListener("touchmove",o,{passive:!0}),()=>{r.removeEventListener("scroll",t),r.removeEventListener("wheel",o),r.removeEventListener("touchmove",o)}}),[s,l,c,a,h]),e.useEffect((()=>()=>{w(),f.current&&clearTimeout(f.current)}),[w]),{scrollContainerRef:l,scrollTargetRef:c,isScrollIncreasing:i,scrollStartSession:E,scrollEndSession:k,scrollToBottom:H,scrollToTarget:L}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),s=require("react"),n=require("./hooks/usePickaxeMarkdownContext.js"),i=require("./utils/custom-plugins.js"),t=require("react-markdown"),o=require("remark-gfm"),a=require("remark-math"),l=require("rehype-katex"),c=require("rehype-raw"),u=require("./Components/A/index.js"),d=require("./Components/A/FilePreview.js"),p=require("./Components/P/index.js"),f=require("./Components/Img/index.js"),h=require("./Components/Iframe/index.js"),m=require("./Components/Code/index.js"),x=require("./Components/Headings/index.js"),g=require("./Components/List/index.js"),j=require("./Components/Table/index.js"),w=require("./Components/Others/index.js"),v=require("./Components/Action/index.js"),b=require("./Components/Artifact/index.js"),k=require("./Components/Others/Think.js"),C=require("../../../../common/cn.js");function q(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var P=q(t),R=q(o),y=q(a),S=q(l),O=q(c);exports.PickaxeMarkdownRenderer=({className:t,style:o,children:a,value:l,maxLines:c,maxChars:q,multiLineBreaks:$,onExpandClick:A,filePreviewSeenRef:U,suppressedRichPreviewUrls:H})=>{const{colors:M,rtl:T,disableHtml:E,disableJs:I,disableCss:_}=n.usePickaxeMarkdownContext(),[N,F]=s.useState({width:0,height:0}),[L,B]=s.useState(null),z=s.useRef(null),J=s.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),$&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,$]);s.useEffect((()=>{if(q)return void B(J.length>q?J.slice(0,q)+'<span class="pxe-expand-btn">...</span>':null);if(!c)return void B(null);if(!z.current||!J||L)return;const e=z.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),s=c*r;if(!(N.height>s))return;const n=Math.floor(N.width/8),i=Math.floor(n*c);B(J.slice(0,i)+'<span class="pxe-expand-btn">...</span>')}),[J,c,q,N,L]);const W=s.useRef(new Set);U||(W.current=new Set);const D=null!=U?U:W,Q=s.useRef({colors:M,onExpandClick:A,filePreviewSeenRef:D,suppressedRichPreviewUrls:H});Q.current={colors:M,onExpandClick:A,filePreviewSeenRef:D,suppressedRichPreviewUrls:H};const G=s.useMemo((()=>({h1:x.H1,h2:x.H2,h3:x.H3,h4:x.H4,h5:x.H5,p:e=>r.jsx(p.P,Object.assign({},e,{suppressedRichPreviewUrls:Q.current.suppressedRichPreviewUrls})),a:e=>r.jsx(u.A,Object.assign({},e,{filePreviewSeenRef:Q.current.filePreviewSeenRef,suppressedRichPreviewUrls:Q.current.suppressedRichPreviewUrls})),img:e=>{const{colors:s,filePreviewSeenRef:n,suppressedRichPreviewUrls:i}=Q.current,t="string"==typeof e.src?e.src:"",o=d.getFilePreviewInfo(t);return o&&!d.shouldSuppressRichPreviewForUrl(o.url,i)?d.shouldRenderFilePreview(o,n)?r.jsx(d.default,{fileInfo:o,displayName:"string"==typeof e.alt?e.alt:void 0}):r.jsx("a",Object.assign({href:o.url,target:"_blank",rel:"noopener noreferrer",style:{color:s.accent}},{children:e.alt||o.fileName})):r.jsx(f.Img,Object.assign({},e))},iframe:h.Iframe,code:m.Code,ol:g.Ol,ul:g.Ul,li:g.Li,table:j.Table,th:j.Th,tr:j.Tr,td:j.Td,hr:w.Hr,br:w.Br,blockquote:w.Blockquote,span:s=>{var{children:n}=s,i=e.__rest(s,["children"]);const{colors:t,onExpandClick:o}=Q.current;return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:t.accent,marginLeft:".25rem",userSelect:"none"},o&&{cursor:"pointer"})},o&&{onClick:o},{children:n})):r.jsx("span",Object.assign({},i,{children:n}))},"action-caption":v.ActionCaption,"action-finished":v.ActionFinished,"action-error":v.ActionError,artifact:b.Artifact,"artifact-error":b.ArtifactError,think:k.Think})),[]);s.useEffect((()=>{if(!z.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:s}=r.contentRect;F({width:e,height:s})}}));return e.observe(z.current),()=>{e.disconnect()}}),[]);const K=L||J;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:z,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},o)},T&&{dir:"rtl"},{children:[r.jsx(P.default,Object.assign({className:C.default("pxe-prose",t),components:G,remarkPlugins:[R.default,[y.default,{singleDollarTextMath:!1}],i.remarkSmartQuotes],rehypePlugins:[i.rehypeCode,S.default,...E?[]:[O.default],[i.rehypeSanitize,{disableJs:I,disableCss:_}]]},{children:K})),a]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("@tanstack/react-query"),t=require("./usePickaxeContext.js"),r=require("./useResponseContext.js"),i=require("../../common/api/pickaxe.js"),o=require("../../common/chatMessages.js");const a=e=>e.filter(((s,t)=>"user"!==s.role||!(e=>"assistant"===(null==e?void 0:e.role)&&"scheduled_followup"===e.area)(e[t+1]))),n=(s,t)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield i.pickaxeApi2.get(`/conversation?pickaxeId=${s}&sessionId=${t}`),r=e.data;if(200!==e.status)throw new Error("[_getChat] Failed to fetch chat conversation "+r);return r}));exports.useConversation=()=>{const{pickaxeId:i,sessionId:c,pickaxe:u}=t.usePickaxeContext(),{isGenerating:l,isSwitchedToChat:d}=r.useResponseContext(),v="string"==typeof(null==u?void 0:u.intromessage)&&0===u.intromessage.trim().length,g=!(!i||!c||d||l);return s.useQuery({queryKey:["form",i,"chat",c],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return n(i,c)})),select:e=>{const s=o.normalizeHistoryMessages(e.messages),t=v?s.filter((e=>"intromessage"!==e.area)):s;return Object.assign(Object.assign({},e),{messages:a(t)})},enabled:!!i&&!!c&&!d,refetchInterval:!!g&&15e3,refetchIntervalInBackground:!1})};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type { PickaxeHistoryMessage } from "../types/history";
|
|
1
|
+
import type { PickaxeHistoryMessage, PickaxeHistoryMessagePart } from "../types/history";
|
|
2
2
|
import type { MemoryStoredChatMessage } from "../types/response";
|
|
3
|
+
export declare const normalizeMessageParts: (parts: unknown, fallbackContent?: unknown) => PickaxeHistoryMessagePart[];
|
|
4
|
+
export declare const normalizeHistoryMessages: (messages: unknown) => PickaxeHistoryMessage[];
|
|
3
5
|
export declare const getUnpersistedMemoryMessages: (memoryMessages: MemoryStoredChatMessage[], persistedMessages: PickaxeHistoryMessage[]) => MemoryStoredChatMessage[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=t=>{
|
|
1
|
+
const t=t=>{if("string"==typeof t)return t;if(null==t)return"";try{return JSON.stringify(t)}catch(r){return String(t)}},r=r=>{if(!r||"object"!=typeof r)return null;const e=r;return"string"!=typeof e.type?null:{type:e.type,content:t(e.content),isVisible:!1!==e.isVisible}},e=(t,e)=>{let n=t;if("string"==typeof n)try{const t=JSON.parse(n);Array.isArray(t)&&(n=t)}catch(t){}if(Array.isArray(n))return n.map(r).filter((t=>null!==t));const s=r(n);if(s)return[s];const i="string"==typeof n?n:e;return"string"==typeof i&&i?[{type:"text",content:i,isVisible:!0}]:[]},n=t=>Array.isArray(t)?t.flatMap((t=>{var r;if(!t||"object"!=typeof t)return[];const n=t;return"user"!==n.role&&"assistant"!==n.role?[]:[Object.assign(Object.assign({},n),{documentIds:Array.isArray(n.documentIds)?n.documentIds.filter((t=>"string"==typeof t)):[],parts:e(n.parts,null!==(r=n.content)&&void 0!==r?r:n.message)})]})):[],s=t=>{const r=e(t.parts).filter((t=>!1!==t.isVisible)),n=r.filter((t=>"text"===t.type)).map((t=>{var r;return null!==(r=t.content)&&void 0!==r?r:""})).join(""),s=n.replace(/\s+/g," ").replace(/\s*([.,!?;:])\s*/g,"$1").trim();return s?JSON.stringify({role:t.role,text:s}):JSON.stringify({role:t.role,parts:r.map((t=>{var r;return{type:t.type,content:null!==(r=t.content)&&void 0!==r?r:""}}))})},i=(t,r)=>{if(!r.length||!t.length)return t;const e=r.map(s),n=new Set(r.filter((t=>"assistant"===t.role)).map(s));let i=0;return t.filter((t=>{const r=s(t),o=e.indexOf(r,i);return-1!==o?(i=o+1,!1):"assistant"!==t.role||!n.has(r)}))};export{i as getUnpersistedMemoryMessages,n as normalizeHistoryMessages,e as normalizeMessageParts};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as e,useCallback as r,useEffect as t}from"react";import{useScrollContext as o}from"./useScrollContext.js";const n=({auto:n=!1,debug:l,smooth:c=!0})=>{const{scrollContainerRef:s,scrollTargetRef:i,hasScrolledRef:u,isLocked:a,
|
|
1
|
+
import{useRef as e,useCallback as r,useEffect as t}from"react";import{useScrollContext as o}from"./useScrollContext.js";const n=({auto:n=!1,debug:l,smooth:c=!0})=>{const{scrollContainerRef:s,scrollTargetRef:i,hasScrolledRef:u,isLocked:a,isScrollIncreasing:d,setIsLocked:h,setIsScrollSession:v,setIsScrolling:m,setIsScrollIncreasing:g}=o(),b=e(null),f=e(null),w=e(!1),T=e(0),S=r((()=>{null!==b.current&&(cancelAnimationFrame(b.current),b.current=null)}),[]),p=r((e=>{f.current&&clearTimeout(f.current),f.current=setTimeout((()=>{w.current=!1,m(!1)}),"smooth"===e?400:100)}),[m]),R=r(((e={})=>{var r;if(!e.force&&u.current)return;const t=null!==(r=e.behavior)&&void 0!==r?r:c?"smooth":"auto",o=s.current,n=i.current;if(o||n){if(w.current=!0,m(!0),o){const e=Math.max(0,o.scrollHeight-o.clientHeight);o.scrollTo({top:e,behavior:t})}else if(n){const e=n.getBoundingClientRect().bottom+window.scrollY,r=Math.max(0,e-window.innerHeight);window.scrollTo({top:r,behavior:t})}l&&console.log("[useScroll] scrolled to the active bottom"),p(t)}else l&&console.log("[useScroll] no scroll element detected")}),[l,p,u,s,i,m,c]),H=r(((e={})=>{S(),b.current=requestAnimationFrame((()=>{b.current=null,R(e)}))}),[S,R]),L=r(((e={})=>{var r;if(!e.force&&u.current)return;const t=i.current;if(!t)return void(l&&console.log("[useScroll] scroll target not detected"));const o=null!==(r=e.behavior)&&void 0!==r?r:c?"smooth":"auto",n=t.getBoundingClientRect().bottom+window.scrollY,s=Math.max(0,n-500);w.current=!0,m(!0),window.scrollTo({top:s,behavior:o}),l&&console.log("[useScroll] scrolled to the form response"),p(o)}),[l,p,u,i,m,c]),E=r(((e={})=>{S(),b.current=requestAnimationFrame((()=>{b.current=null,L(e)}))}),[S,L]),C=r((()=>{u.current=!1,h(!0),v(!0)}),[u,h,v]),x=r((()=>{v(!1)}),[v]),I=r(((e={})=>H(e)),[H]),M=r(((e={})=>E(e)),[E]);return t((()=>{if(!n||!a)return;let e=s.current,r=i.current,t=null,o=[];const l=()=>{var o;if(!t)return;const n=e?Math.max(0,e.scrollHeight-e.clientHeight):null!==(o=null==r?void 0:r.getBoundingClientRect().height)&&void 0!==o?o:0,l=n>T.current;T.current=n,g(l),l&&(e?H({behavior:"auto"}):E({behavior:"auto"}))},c=new ResizeObserver(l);function u(){t&&(o.forEach((e=>c.unobserve(e))),o=[t,...Array.from(t.children)],o.forEach((e=>c.observe(e))))}const d=new MutationObserver((()=>{u(),l()}));let h=null;const v=()=>{var o;e=s.current,r=i.current;const n=null!=e?e:r;return!(!n||n===t)&&(d.disconnect(),c.disconnect(),t=n,T.current=e?Math.max(0,e.scrollHeight-e.clientHeight):null!==(o=null==r?void 0:r.getBoundingClientRect().height)&&void 0!==o?o:0,u(),d.observe(t,{childList:!0,subtree:!0}),e?H({behavior:"auto"}):E({behavior:"auto"}),!0)};return v()||(h=new MutationObserver((()=>{v()&&(null==h||h.disconnect())})),h.observe(document.body,{childList:!0,subtree:!0})),()=>{null==h||h.disconnect(),d.disconnect(),c.disconnect()}}),[n,a,H,E,s,i,g]),t((()=>{a&&(u.current=!1)}),[u,a]),t((()=>{const e=s.current,r=null!=e?e:window,t=()=>{if(w.current)return;const r=(()=>{if(e)return e.scrollHeight-e.scrollTop-e.clientHeight<=32;const r=i.current;return!r||r.getBoundingClientRect().bottom-window.innerHeight<=32})();u.current=!r,h(r)},o=()=>{w.current&&(w.current=!1,m(!1),f.current&&(clearTimeout(f.current),f.current=null),e?e.scrollTo({top:e.scrollTop,behavior:"auto"}):window.scrollTo({top:window.scrollY,behavior:"auto"}))};return r.addEventListener("scroll",t,{passive:!0}),r.addEventListener("wheel",o,{passive:!0}),r.addEventListener("touchmove",o,{passive:!0}),()=>{r.removeEventListener("scroll",t),r.removeEventListener("wheel",o),r.removeEventListener("touchmove",o)}}),[u,s,i,h,m]),t((()=>()=>{S(),f.current&&clearTimeout(f.current)}),[S]),{scrollContainerRef:s,scrollTargetRef:i,isScrollIncreasing:d,scrollStartSession:C,scrollEndSession:x,scrollToBottom:I,scrollToTarget:M}};export{n as useScroll};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../../../_virtual/_tslib.js";import{
|
|
1
|
+
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsx as r,jsxs as n}from"react/jsx-runtime";import{useState as t,useRef as s,useMemo as i,useEffect as o}from"react";import{usePickaxeMarkdownContext as l}from"./hooks/usePickaxeMarkdownContext.js";import{remarkSmartQuotes as a,rehypeCode as c,rehypeSanitize as p}from"./utils/custom-plugins.js";import m from"react-markdown";import d from"remark-gfm";import f from"remark-math";import h from"rehype-katex";import u from"rehype-raw";import{A as g}from"./Components/A/index.js";import x,{getFilePreviewInfo as w,shouldSuppressRichPreviewForUrl as b,shouldRenderFilePreview as j}from"./Components/A/FilePreview.js";import{P as v}from"./Components/P/index.js";import{Img as C}from"./Components/Img/index.js";import{Iframe as k}from"./Components/Iframe/index.js";import{Code as P}from"./Components/Code/index.js";import{H1 as R,H2 as $,H3 as y,H4 as O,H5 as S}from"./Components/Headings/index.js";import{Ol as U,Ul as N,Li as A}from"./Components/List/index.js";import{Table as E,Th as I,Tr as L,Td as M}from"./Components/Table/index.js";import{Hr as T,Br as H,Blockquote as _}from"./Components/Others/index.js";import{ActionCaption as B,ActionFinished as J,ActionError as W}from"./Components/Action/index.js";import{Artifact as q,ArtifactError as z}from"./Components/Artifact/index.js";import{Think as D}from"./Components/Others/Think.js";import F from"../../../../common/cn.js";const G=({className:G,style:K,children:Q,value:V,maxLines:X,maxChars:Y,multiLineBreaks:Z,onExpandClick:ee,filePreviewSeenRef:re,suppressedRichPreviewUrls:ne})=>{const{colors:te,rtl:se,disableHtml:ie,disableJs:oe,disableCss:le}=l(),[ae,ce]=t({width:0,height:0}),[pe,me]=t(null),de=s(null),fe=i((()=>{if(!V)return"";let e=V.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),Z&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[V,Z]);o((()=>{if(Y)return void me(fe.length>Y?fe.slice(0,Y)+'<span class="pxe-expand-btn">...</span>':null);if(!X)return void me(null);if(!de.current||!fe||pe)return;const e=de.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=X*r;if(!(ae.height>n))return;const t=Math.floor(ae.width/8),s=Math.floor(t*X);me(fe.slice(0,s)+'<span class="pxe-expand-btn">...</span>')}),[fe,X,Y,ae,pe]);const he=s(new Set);re||(he.current=new Set);const ue=null!=re?re:he,ge=s({colors:te,onExpandClick:ee,filePreviewSeenRef:ue,suppressedRichPreviewUrls:ne});ge.current={colors:te,onExpandClick:ee,filePreviewSeenRef:ue,suppressedRichPreviewUrls:ne};const xe=i((()=>({h1:R,h2:$,h3:y,h4:O,h5:S,p:e=>r(v,Object.assign({},e,{suppressedRichPreviewUrls:ge.current.suppressedRichPreviewUrls})),a:e=>r(g,Object.assign({},e,{filePreviewSeenRef:ge.current.filePreviewSeenRef,suppressedRichPreviewUrls:ge.current.suppressedRichPreviewUrls})),img:e=>{const{colors:n,filePreviewSeenRef:t,suppressedRichPreviewUrls:s}=ge.current,i="string"==typeof e.src?e.src:"",o=w(i);return o&&!b(o.url,s)?j(o,t)?r(x,{fileInfo:o,displayName:"string"==typeof e.alt?e.alt:void 0}):r("a",Object.assign({href:o.url,target:"_blank",rel:"noopener noreferrer",style:{color:n.accent}},{children:e.alt||o.fileName})):r(C,Object.assign({},e))},iframe:k,code:P,ol:U,ul:N,li:A,table:E,th:I,tr:L,td:M,hr:T,br:H,blockquote:_,span:n=>{var{children:t}=n,s=e(n,["children"]);const{colors:i,onExpandClick:o}=ge.current;return"pxe-expand-btn"===s.className?r("span",Object.assign({},s,{style:Object.assign({display:"inline",fontWeight:500,color:i.accent,marginLeft:".25rem",userSelect:"none"},o&&{cursor:"pointer"})},o&&{onClick:o},{children:t})):r("span",Object.assign({},s,{children:t}))},"action-caption":B,"action-finished":J,"action-error":W,artifact:q,"artifact-error":z,think:D})),[]);o((()=>{if(!de.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;ce({width:e,height:n})}}));return e.observe(de.current),()=>{e.disconnect()}}),[]);const we=pe||fe;return n("div",Object.assign({className:"pxe-markdown",ref:de,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},K)},se&&{dir:"rtl"},{children:[r(m,Object.assign({className:F("pxe-prose",G),components:xe,remarkPlugins:[d,[f,{singleDollarTextMath:!1}],a],rehypePlugins:[c,h,...ie?[]:[u],[p,{disableJs:oe,disableCss:le}]]},{children:we})),Q]}))};export{G as PickaxeMarkdownRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{useQuery as t}from"@tanstack/react-query";import{usePickaxeContext as
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{useQuery as t}from"@tanstack/react-query";import{usePickaxeContext as o}from"./usePickaxeContext.js";import{useResponseContext as s}from"./useResponseContext.js";import{pickaxeApi2 as r}from"../../common/api/pickaxe.js";import{normalizeHistoryMessages as i}from"../../common/chatMessages.js";const n=e=>e.filter(((t,o)=>"user"!==t.role||!(e=>"assistant"===(null==e?void 0:e.role)&&"scheduled_followup"===e.area)(e[o+1]))),a=()=>{const{pickaxeId:a,sessionId:c,pickaxe:m}=o(),{isGenerating:d,isSwitchedToChat:l}=s(),u="string"==typeof(null==m?void 0:m.intromessage)&&0===m.intromessage.trim().length;return t({queryKey:["form",a,"chat",c],queryFn:()=>e(void 0,void 0,void 0,(function*(){return t=a,o=c,e(void 0,void 0,void 0,(function*(){const e=yield r.get(`/conversation?pickaxeId=${t}&sessionId=${o}`),s=e.data;if(200!==e.status)throw new Error("[_getChat] Failed to fetch chat conversation "+s);return s}));var t,o})),select:e=>{const t=i(e.messages),o=u?t.filter((e=>"intromessage"!==e.area)):t;return Object.assign(Object.assign({},e),{messages:n(o)})},enabled:!!a&&!!c&&!l,refetchInterval:!!!(!a||!c||l||d)&&15e3,refetchIntervalInBackground:!1})};export{a as useConversation};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type { PickaxeHistoryMessage } from "../types/history";
|
|
1
|
+
import type { PickaxeHistoryMessage, PickaxeHistoryMessagePart } from "../types/history";
|
|
2
2
|
import type { MemoryStoredChatMessage } from "../types/response";
|
|
3
|
+
export declare const normalizeMessageParts: (parts: unknown, fallbackContent?: unknown) => PickaxeHistoryMessagePart[];
|
|
4
|
+
export declare const normalizeHistoryMessages: (messages: unknown) => PickaxeHistoryMessage[];
|
|
3
5
|
export declare const getUnpersistedMemoryMessages: (memoryMessages: MemoryStoredChatMessage[], persistedMessages: PickaxeHistoryMessage[]) => MemoryStoredChatMessage[];
|