llmpt 1.3.5 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,26 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## v1.3.5 (2026-06-16)
|
|
4
|
-
|
|
5
|
-
### 修复
|
|
6
|
-
- Response Assistant:非流式响应中 `message.tool_calls` 现在正确提取并显示在 Response 区域
|
|
7
|
-
- `tool_use` 块改为可折叠形式(默认收起),显示函数名 + 参数数量,展开后显示完整 JSON 参数;与 Messages Assistant 中 `MsgToolCallBlock` 行为对齐
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
3
|
## v1.3.4 (2026-06-16)
|
|
12
4
|
|
|
13
5
|
### 修复
|
|
14
|
-
- Response Assistant
|
|
15
|
-
-
|
|
16
|
-
- `ThinkingBlock` / `ThinkingSection` 展开时统一走 `compact` 路径(与 `TextPane` 行为对齐)
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## v1.3.3 (2026-06-16)
|
|
21
|
-
|
|
22
|
-
### 其他
|
|
23
|
-
- 版本号修正(内部版本,无功能变更)
|
|
6
|
+
- Response Assistant:非流式 OpenAI 响应中 `message.tool_calls` 现在正确提取并在 Response 区域显示
|
|
7
|
+
- `tool_use` 块(Anthropic 及上述 OpenAI 转换)改为可折叠形式,默认收起,显示函数名 + 参数数量,右侧淡显 call id,展开后显示完整 JSON 参数
|
|
24
8
|
|
|
25
9
|
---
|
|
26
10
|
|
|
@@ -12,7 +12,7 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,O
|
|
|
12
12
|
|
|
13
13
|
`),children:(0,K.jsx)(`div`,{style:{display:`grid`,gap:`4px`},children:f.map((e,t)=>(0,K.jsx)(De,{toolCall:e},t))})}),d.length>0&&(0,K.jsx)(Y,{title:`Tools Definition`,defaultOpen:!1,badge:`${d.length}`,copyText:JSON.stringify(d,null,2),children:(0,K.jsx)(Oe,{tools:d})}),(0,K.jsx)(Y,{title:`Raw JSON`,defaultOpen:!1,copyText:JSON.stringify(e,null,2),children:(0,K.jsx)(Q,{data:e})})]})}function _e(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e}ms`}function ve({usage:e,duration:t,ttfb:n,isStreaming:r}){let i=(e?.cachedTokens||0)+(e?.cacheReadTokens||0)+(e?.cacheWriteTokens||0)>0;return(0,K.jsx)(`div`,{className:`token-usage-bar`,children:(0,K.jsx)(`div`,{className:`token-bar`,children:r?(0,K.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:`6px`,fontSize:`11px`,color:`var(--text-tertiary)`},children:[`接收中 `,(0,K.jsxs)(`span`,{className:`streaming-dots`,children:[(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{})]})]}):e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`tok-group`,children:(0,K.jsxs)(`span`,{className:`tok-item`,children:[(0,K.jsx)(`span`,{className:`tok-label`,children:`合计`}),(0,K.jsx)(`span`,{className:`tok-val`,style:{color:`var(--text)`,fontSize:`12px`},children:e.totalTokens.toLocaleString()})]})}),(0,K.jsxs)(`span`,{className:`tok-group`,children:[(0,K.jsxs)(`span`,{className:`tok-item`,children:[(0,K.jsx)(`span`,{className:`tok-arrow`,style:{color:`var(--blue)`},children:`↑`}),(0,K.jsx)(`span`,{className:`tok-val`,children:e.promptTokens.toLocaleString()})]}),(0,K.jsxs)(`span`,{className:`tok-item`,children:[(0,K.jsx)(`span`,{className:`tok-arrow`,style:{color:`var(--green)`},children:`↓`}),(0,K.jsx)(`span`,{className:`tok-val`,children:e.completionTokens.toLocaleString()})]}),(e.reasoningTokens||0)>0&&(0,K.jsxs)(`span`,{className:`tok-item`,children:[(0,K.jsx)(`span`,{className:`tok-dot`,style:{background:`var(--indigo)`}}),(0,K.jsx)(`span`,{className:`tok-label`,children:`推理`}),(0,K.jsx)(`span`,{className:`tok-val`,children:e.reasoningTokens.toLocaleString()})]})]}),i&&(0,K.jsxs)(`span`,{className:`tok-group`,children:[(e.cachedTokens||0)>0&&(0,K.jsxs)(`span`,{className:`tok-item`,children:[(0,K.jsx)(`span`,{className:`tok-dot`,style:{background:`var(--cyan)`}}),(0,K.jsx)(`span`,{className:`tok-label`,children:`缓存命中`}),(0,K.jsx)(`span`,{className:`tok-val`,children:e.cachedTokens.toLocaleString()})]}),(e.cacheReadTokens||0)>0&&(0,K.jsxs)(`span`,{className:`tok-item`,children:[(0,K.jsx)(`span`,{className:`tok-dot`,style:{background:`var(--cyan)`}}),(0,K.jsx)(`span`,{className:`tok-label`,children:`缓存读`}),(0,K.jsx)(`span`,{className:`tok-val`,children:e.cacheReadTokens.toLocaleString()})]}),(e.cacheWriteTokens||0)>0&&(0,K.jsxs)(`span`,{className:`tok-item`,children:[(0,K.jsx)(`span`,{className:`tok-dot`,style:{background:`var(--amber)`}}),(0,K.jsx)(`span`,{className:`tok-label`,children:`缓存写`}),(0,K.jsx)(`span`,{className:`tok-val`,children:e.cacheWriteTokens.toLocaleString()})]})]}),(0,K.jsxs)(`span`,{className:`tok-group`,children:[n>0&&(0,K.jsxs)(`span`,{className:`tok-item`,children:[(0,K.jsx)(`span`,{className:`tok-label`,children:`首字`}),(0,K.jsx)(`span`,{className:`tok-val`,children:_e(n)})]}),t>0&&(0,K.jsxs)(`span`,{className:`tok-item`,children:[(0,K.jsx)(`span`,{className:`tok-label`,children:`耗时`}),(0,K.jsx)(`span`,{className:`tok-val`,children:_e(t)})]}),t>0&&(e.completionTokens||0)>0&&(0,K.jsxs)(`span`,{className:`tok-item`,children:[(0,K.jsx)(`span`,{className:`tok-label`,children:`速度`}),(0,K.jsxs)(`span`,{className:`tok-val`,children:[Math.round(e.completionTokens/(t/1e3)),` tok/s`]})]})]})]}):(0,K.jsx)(`span`,{style:{color:`var(--text-tertiary)`,fontSize:`11px`},children:`无 token 数据`})})})}function Y({title:e,defaultOpen:t,badge:n,copyText:r,children:i}){let[a,o]=(0,V.useState)(he[e]??t);return(0,K.jsxs)(`div`,{className:`section`,children:[(0,K.jsxs)(`div`,{className:`section-header`,onClick:()=>{let t=!a;o(t),he[e]=t},children:[(0,K.jsx)(`span`,{className:`chevron${a?` open`:``}`,children:`▶`}),(0,K.jsx)(`span`,{className:`title`,children:e}),n&&(0,K.jsx)(`span`,{className:`badge`,children:n}),r!==void 0&&r!==``&&(0,K.jsx)(Z,{getText:()=>r,className:`copy-btn`,stopPropagation:!0})]}),a&&(0,K.jsx)(`div`,{className:`section-body open`,children:i})]})}function ye({message:e,isStreaming:t}){let n=e.role,r=e.content,i=n===`assistant`,a=typeof r==`string`,[o,s]=(0,V.useState)(i?`markdown`:`raw`),c=()=>typeof r==`string`?r:Array.isArray(r)?r.map(e=>e.text||e.thinking||``).filter(Boolean).join(`
|
|
14
14
|
|
|
15
|
-
`):``,l=n===`user`?`user`:n===`assistant`?`assistant`:n===`system`||n===`developer`?`system`:n===`tool`?`tool_result`:``,u=e.tool_calls;e.tool_call_id;let d=a?r.trim().length>0:Array.isArray(r)&&r.length>0,f=a&&r.trim().length>0,[p,m]=(0,V.useState)(n===`tool`);return(0,K.jsxs)(`div`,{className:`msg ${l}`,children:[(0,K.jsxs)(`div`,{className:`msg-header-row`,children:[(0,K.jsxs)(`span`,{className:`msg-role msg-role-toggle`,onClick:()=>m(e=>!e),title:p?`展开`:`收起`,children:[(0,K.jsx)(`span`,{className:`msg-collapse-arrow${p?``:` open`}`,children:`▶`}),n.toUpperCase()]}),f&&(0,K.jsxs)(`div`,{className:`text-toggle-bar`,style:{marginLeft:`8px`,marginTop:0,display:p?`none`:void 0},children:[(0,K.jsx)(`button`,{className:`text-toggle-btn${o===`raw`?` active`:``}`,onClick:()=>s(`raw`),children:`原文`}),(0,K.jsx)(`button`,{className:`text-toggle-btn${o===`markdown`?` active`:``}`,onClick:()=>s(`markdown`),children:`渲染`})]}),(0,K.jsx)(`span`,{style:{marginLeft:`auto`},children:(0,K.jsx)(Z,{getText:c})})]}),!p&&(0,K.jsxs)(K.Fragment,{children:[a?(0,K.jsx)(we,{text:r,mode:o}):Array.isArray(r)?(0,K.jsx)(`div`,{children:r.map((e,n)=>(0,K.jsx)(xe,{block:e,isStreaming:t&&n===r.length-1},n))}):r?(0,K.jsx)(Q,{data:r}):null,u&&u.length>0&&(0,K.jsx)(`div`,{className:`msg-tool-calls`,children:u.map(e=>(0,K.jsx)(be,{toolCall:e},e.id))})]}),p&&(d||u&&u.length>0)&&(0,K.jsx)(`div`,{className:`msg-collapsed-hint`,children:[d?a?`${r.slice(0,60).replace(/\n/g,` `)}…`:`${r.length} 块`:``,u?.length?`${u.length} tool_call`:``].filter(Boolean).join(` · `)})]})}function be({toolCall:e}){let[t,n]=(0,V.useState)(!1),r=e.function.arguments;try{r=JSON.parse(e.function.arguments)}catch{}let i=typeof r==`object`&&r?Object.keys(r).length:0;return(0,K.jsxs)(`div`,{className:`tool-block`,children:[(0,K.jsxs)(`div`,{className:`tool-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsx)(`span`,{className:`tb-arrow${t?` open`:``}`,children:`▶`}),(0,K.jsx)(`span`,{className:`tb-name`,children:e.function.name}),!t&&i>0&&(0,K.jsxs)(`span`,{className:`tb-desc`,children:[`(`,i,` args)`]})]}),t&&(0,K.jsx)(`div`,{className:`tool-block-body open`,children:typeof r==`object`?(0,K.jsx)(Q,{data:r}):(0,K.jsx)(`pre`,{className:`text-raw`,children:String(r)})})]})}function xe({block:e,isStreaming:t}){let[n,r]=(0,V.useState)(`markdown`);if(e.type===`text`||e.type===`input_text`||e.type===`output_text`){let i=e.text||``;return(0,K.jsxs)(`div`,{className:`content-block`,children:[(0,K.jsx)(`div`,{className:`msg-header-row`,style:{marginBottom:`4px`},children:(0,K.jsxs)(`div`,{className:`text-toggle-bar`,style:{marginTop:0},children:[(0,K.jsx)(`button`,{className:`text-toggle-btn${n===`raw`?` active`:``}`,onClick:()=>r(`raw`),children:`原文`}),(0,K.jsx)(`button`,{className:`text-toggle-btn${n===`markdown`?` active`:``}`,onClick:()=>r(`markdown`),children:`渲染`})]})}),(0,K.jsx)(X,{text:i,mode:n,isStreaming:t})]})}return e.type===`thinking`?(0,K.jsx)(Te,{content:e.thinking||``}):e.type===`tool_use`?(0,K.jsx)(Se,{block:e}):e.type===`tool_result`?(0,K.jsxs)(`div`,{className:`content-block block-framed`,style:{borderColor:`var(--purple)`,background:`var(--purple-bg)`},children:[(0,K.jsxs)(`span`,{className:`tool-use-label`,style:{color:`var(--purple)`,background:`color-mix(in srgb, var(--purple) 15%, transparent)`},children:[`↩ tool_result: `,e.tool_use_id||``]}),(0,K.jsx)(`div`,{className:`content-block-text`,children:typeof e.text==`string`?e.text:(0,K.jsx)(Q,{data:e.text})})]}):(0,K.jsx)(Q,{data:e})}function Se({block:e}){let[t,n]=(0,V.useState)(!1),r=e.input&&typeof e.input==`object`?Object.keys(e.input).length:0;return(0,K.jsxs)(`div`,{className:`tool-block`,style:{margin:`4px 0`},children:[(0,K.jsxs)(`div`,{className:`tool-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsx)(`span`,{className:`tb-arrow${t?` open`:``}`,children:`▶`}),(0,K.jsxs)(`span`,{className:`tb-name`,children:[`⚙ `,e.name||`tool_use`]}),!t&&r>0&&(0,K.jsxs)(`span`,{className:`tb-desc`,children:[`(`,r,` args)`]}),e.id&&(0,K.jsx)(`span`,{className:`tb-desc`,style:{marginLeft:`auto`,opacity:.5,fontSize:`11px`},children:e.id})]}),t&&(0,K.jsx)(`div`,{className:`tool-block-body open`,children:(0,K.jsx)(Q,{data:e.input})})]})}function X({text:e,mode:t,isStreaming:n,sans:r,compact:i,className:a}){return e?(0,K.jsxs)(`div`,{className:`text-pane${a?` `+a:``}`,children:[(0,K.jsx)(`pre`,{className:`text-raw${r?` sans`:``}`,style:{display:t===`raw`?void 0:`none`},children:e}),(0,K.jsx)(`div`,{style:{display:t===`markdown`?void 0:`none`},children:i?(0,K.jsx)(`div`,{className:`text-raw sans`,style:{whiteSpace:`pre-wrap`},children:e}):(0,K.jsx)(me,{text:e,isStreaming:n})})]}):null}function Ce({text:e}){let[t,n]=(0,V.useState)(`raw`);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-toggle-bar`,style:{marginBottom:`6px`},children:[(0,K.jsx)(`button`,{className:`text-toggle-btn${t===`raw`?` active`:``}`,onClick:()=>n(`raw`),children:`原文`}),(0,K.jsx)(`button`,{className:`text-toggle-btn${t===`markdown`?` active`:``}`,onClick:()=>n(`markdown`),children:`渲染`})]}),(0,K.jsx)(X,{text:e,mode:t,sans:!0})]})}function we({text:e,mode:t}){return e?(0,K.jsx)(X,{text:e,mode:t}):null}function Te({content:e}){let[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(`raw`),a=e.slice(0,80).replace(/\n/g,` `);return(0,K.jsxs)(`div`,{className:`thinking-block content-block`,children:[(0,K.jsxs)(`div`,{className:`thinking-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsxs)(`span`,{className:`thinking-label`,children:[(0,K.jsx)(`span`,{className:`thinking-arrow`,children:t?`▼`:`▶`}),(0,K.jsx)(`span`,{children:`Thinking`})]}),t?(0,K.jsxs)(`div`,{className:`text-toggle-bar`,style:{marginTop:0,marginLeft:`4px`},onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{className:`text-toggle-btn${r===`raw`?` active`:``}`,onClick:()=>i(`raw`),children:`原文`}),(0,K.jsx)(`button`,{className:`text-toggle-btn${r===`markdown`?` active`:``}`,onClick:()=>i(`markdown`),children:`渲染`})]}):(0,K.jsxs)(`span`,{className:`thinking-preview`,children:[a,`…`]}),(0,K.jsx)(Z,{getText:()=>e,stopPropagation:!0,className:`copy-btn`})]}),t&&(0,K.jsx)(X,{text:e,mode:r,sans:!0})]})}function Ee({content:e}){let[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(`raw`),a=e.slice(0,80).replace(/\n/g,` `);return(0,K.jsxs)(`div`,{className:`thinking-block content-block`,style:{marginBottom:`8px`},children:[(0,K.jsxs)(`div`,{className:`thinking-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsxs)(`span`,{className:`thinking-label`,children:[(0,K.jsx)(`span`,{className:`thinking-arrow`,children:t?`▼`:`▶`}),(0,K.jsx)(`span`,{children:`Thinking`})]}),t?(0,K.jsxs)(`div`,{className:`text-toggle-bar`,style:{marginTop:0,marginLeft:`4px`},onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{className:`text-toggle-btn${r===`raw`?` active`:``}`,onClick:()=>i(`raw`),children:`原文`}),(0,K.jsx)(`button`,{className:`text-toggle-btn${r===`markdown`?` active`:``}`,onClick:()=>i(`markdown`),children:`渲染`})]}):(0,K.jsxs)(`span`,{className:`thinking-preview`,children:[a,`…`]}),(0,K.jsx)(Z,{getText:()=>e,stopPropagation:!0,className:`copy-btn`})]}),t&&(0,K.jsx)(X,{text:e,mode:r,sans:!0})]})}function De({toolCall:e}){let[t,n]=(0,V.useState)(!1),r=typeof e.arguments==`object`?Object.keys(e.arguments||{}).length:0;return(0,K.jsxs)(`div`,{className:`tool-block`,children:[(0,K.jsxs)(`div`,{className:`tool-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsx)(`span`,{className:`tb-arrow${t?` open`:``}`,children:`▶`}),(0,K.jsx)(`span`,{className:`tb-name`,children:e.name}),!t&&r>0&&(0,K.jsxs)(`span`,{className:`tb-desc`,children:[`(`,r,` args)`]})]}),t&&(0,K.jsxs)(`div`,{className:`tool-block-body open`,children:[(0,K.jsx)(Q,{data:e.arguments}),e.result!==void 0&&(0,K.jsxs)(`div`,{style:{marginTop:`10px`,paddingTop:`10px`,borderTop:`1px solid var(--border-light)`},children:[(0,K.jsx)(`div`,{style:{fontSize:`11px`,fontWeight:600,color:`var(--orange)`,marginBottom:`6px`,textTransform:`uppercase`},children:`Result`}),(0,K.jsx)(Q,{data:e.result})]})]})]})}function Oe({tools:e}){return(0,K.jsx)(`div`,{style:{display:`grid`,gap:`4px`},children:e.map((e,t)=>(0,K.jsx)(ke,{tool:e},t))})}function ke({tool:e}){let[t,n]=(0,V.useState)(!1),r=e.function||e,i=r.name||e.name||`unknown`,a=r.description||e.description||``,o=r.parameters||e.input_schema||e.parameters,s=o?.required||[],c=o?.properties||{};return(0,K.jsxs)(`div`,{className:`tool-block`,children:[(0,K.jsxs)(`div`,{className:`tool-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsx)(`span`,{className:`tb-arrow${t?` open`:``}`,children:`▶`}),(0,K.jsx)(`span`,{className:`tb-name`,children:i}),(0,K.jsx)(`span`,{className:`tb-desc`,children:a})]}),t&&(0,K.jsxs)(`div`,{className:`tool-block-body open`,children:[a&&(0,K.jsx)(`div`,{className:`tb-full-desc`,children:a}),Object.keys(c).length>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`tb-params-title`,children:`Parameters`}),Object.entries(c).map(([e,t])=>(0,K.jsxs)(`div`,{className:`tb-param`,children:[(0,K.jsxs)(`div`,{className:`tb-param-row1`,children:[(0,K.jsx)(`span`,{className:`tb-pname`,children:e}),t.type&&(0,K.jsx)(`span`,{className:`tb-ptype`,children:t.type}),s.includes(e)&&(0,K.jsx)(`span`,{className:`tb-prequired`,children:`required`})]}),t.description&&(0,K.jsx)(`div`,{className:`tb-pdesc`,children:t.description})]},e))]}):o?(0,K.jsx)(Q,{data:o}):null]})]})}function Z({getText:e,className:n=`copy-btn`,stopPropagation:i=!1}){let[a,o]=(0,V.useState)(!1);return(0,K.jsx)(`button`,{className:`${n}${a?` copied`:``}`,onClick:async t=>{i&&t.stopPropagation();try{await navigator.clipboard.writeText(e()),o(!0),setTimeout(()=>o(!1),1500)}catch{}},"data-tip":`复制`,children:a?(0,K.jsx)(r,{size:10}):(0,K.jsx)(t,{size:10})})}var Ae=0;function Q({data:e}){return Ae=0,(0,K.jsx)(`div`,{className:`json-view`,children:$(e,0)})}var je=new Set([`chunks`,`headers`,`tools`]);function $(e,t,n){if(t>50)return(0,K.jsx)(`span`,{className:`json-punct`,children:`…`});if(e===null)return(0,K.jsx)(`span`,{className:`jnull`,children:`null`});if(e===void 0)return(0,K.jsx)(`span`,{className:`jnull`,children:`undefined`});if(typeof e==`boolean`)return(0,K.jsx)(`span`,{className:`jb`,children:String(e)});if(typeof e==`number`)return(0,K.jsx)(`span`,{className:`jn`,children:e});if(typeof e==`string`)return(0,K.jsxs)(`span`,{className:`js`,children:[`"`,e.length>300?e.slice(0,300)+`…`:e,`"`]});if(typeof e!=`object`)return(0,K.jsx)(`span`,{children:String(e)});let r=Array.isArray(e),i=r?e.map((e,t)=>[t,e]):Object.entries(e),a=i.length;if(a===0)return(0,K.jsx)(`span`,{className:`json-punct`,children:r?`[]`:`{}`});if(a<=3&&t<2&&i.every(([,e])=>typeof e!=`object`||!e)){let e=i.map(([e,n],i)=>(0,K.jsxs)(`span`,{children:[!r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`jk`,children:[`"`,String(e),`"`]}),(0,K.jsx)(`span`,{className:`json-punct`,children:`: `})]}),$(n,t+1),i<a-1&&(0,K.jsx)(`span`,{className:`json-punct`,children:`, `})]},String(e)));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`json-punct`,children:r?`[`:`{`}),e,(0,K.jsx)(`span`,{className:`json-punct`,children:r?`]`:`}`})]})}let o=`jt`+ Ae++,s=`${a} ${r?`item`:`key`}${a===1?``:`s`}`,c=n!==void 0&&je.has(n),l=i.map(([e,n])=>(0,K.jsxs)(`div`,{className:`jt-line`,children:[!r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`jk`,children:[`"`,String(e),`"`]}),(0,K.jsx)(`span`,{className:`json-punct`,children:`: `})]}),$(n,t+1,String(e))]},String(e)));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`jt-toggle${c?``:` jt-open`}`,onClick:e=>Me(e,o),style:{cursor:`pointer`},children:c?`▶`:`▼`}),(0,K.jsx)(`span`,{className:`json-punct`,children:r?`[`:`{`}),(0,K.jsxs)(`span`,{className:`jt-summary${c?` jt-show`:``}`,id:`${o}s`,children:[`… `,s]}),(0,K.jsx)(`div`,{className:`jt-children${c?``:` jt-open`}`,id:o,children:l}),(0,K.jsx)(`div`,{className:`jt-close${c?` jt-hidden`:``}`,id:`${o}c`,children:(0,K.jsx)(`span`,{className:`json-punct`,children:r?`]`:`}`})})]})}function Me(e,t){e.stopPropagation();let n=document.getElementById(t),r=document.getElementById(t+`s`),i=document.getElementById(t+`c`),a=e.currentTarget;n&&(n.classList.contains(`jt-open`)?(n.classList.remove(`jt-open`),a.classList.remove(`jt-open`),a.textContent=`▶`,r?.classList.add(`jt-show`),i?.classList.add(`jt-hidden`)):(n.classList.add(`jt-open`),a.classList.add(`jt-open`),a.textContent=`▼`,r?.classList.remove(`jt-show`),i?.classList.remove(`jt-hidden`)))}function Ne(e){let t=e.request.body,n=[];if(typeof t.system==`string`&&t.system.trim())n.push(t.system);else if(Array.isArray(t.system)){let e=t.system.map(e=>typeof e==`string`?e:e?.type===`text`&&e.text||``).filter(Boolean).join(`
|
|
15
|
+
`):``,l=n===`user`?`user`:n===`assistant`?`assistant`:n===`system`||n===`developer`?`system`:n===`tool`?`tool_result`:``,u=e.tool_calls;e.tool_call_id;let d=a?r.trim().length>0:Array.isArray(r)&&r.length>0,f=a&&r.trim().length>0,[p,m]=(0,V.useState)(n===`tool`);return(0,K.jsxs)(`div`,{className:`msg ${l}`,children:[(0,K.jsxs)(`div`,{className:`msg-header-row`,children:[(0,K.jsxs)(`span`,{className:`msg-role msg-role-toggle`,onClick:()=>m(e=>!e),title:p?`展开`:`收起`,children:[(0,K.jsx)(`span`,{className:`msg-collapse-arrow${p?``:` open`}`,children:`▶`}),n.toUpperCase()]}),f&&(0,K.jsxs)(`div`,{className:`text-toggle-bar`,style:{marginLeft:`8px`,marginTop:0,display:p?`none`:void 0},children:[(0,K.jsx)(`button`,{className:`text-toggle-btn${o===`raw`?` active`:``}`,onClick:()=>s(`raw`),children:`原文`}),(0,K.jsx)(`button`,{className:`text-toggle-btn${o===`markdown`?` active`:``}`,onClick:()=>s(`markdown`),children:`渲染`})]}),(0,K.jsx)(`span`,{style:{marginLeft:`auto`},children:(0,K.jsx)(Z,{getText:c})})]}),!p&&(0,K.jsxs)(K.Fragment,{children:[a?(0,K.jsx)(we,{text:r,mode:o}):Array.isArray(r)?(0,K.jsx)(`div`,{children:r.map((e,n)=>(0,K.jsx)(xe,{block:e,isStreaming:t&&n===r.length-1},n))}):r?(0,K.jsx)(Q,{data:r}):null,u&&u.length>0&&(0,K.jsx)(`div`,{className:`msg-tool-calls`,children:u.map(e=>(0,K.jsx)(be,{toolCall:e},e.id))})]}),p&&(d||u&&u.length>0)&&(0,K.jsx)(`div`,{className:`msg-collapsed-hint`,children:[d?a?`${r.slice(0,60).replace(/\n/g,` `)}…`:`${r.length} 块`:``,u?.length?`${u.length} tool_call`:``].filter(Boolean).join(` · `)})]})}function be({toolCall:e}){let[t,n]=(0,V.useState)(!1),r=e.function.arguments;try{r=JSON.parse(e.function.arguments)}catch{}let i=typeof r==`object`&&r?Object.keys(r).length:0;return(0,K.jsxs)(`div`,{className:`tool-block`,children:[(0,K.jsxs)(`div`,{className:`tool-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsx)(`span`,{className:`tb-arrow${t?` open`:``}`,children:`▶`}),(0,K.jsx)(`span`,{className:`tb-name`,children:e.function.name}),!t&&i>0&&(0,K.jsxs)(`span`,{className:`tb-desc`,children:[`(`,i,` args)`]})]}),t&&(0,K.jsx)(`div`,{className:`tool-block-body open`,children:typeof r==`object`?(0,K.jsx)(Q,{data:r}):(0,K.jsx)(`pre`,{className:`text-raw`,children:String(r)})})]})}function xe({block:e,isStreaming:t}){let[n,r]=(0,V.useState)(`markdown`);if(e.type===`text`||e.type===`input_text`||e.type===`output_text`){let i=e.text||``;return(0,K.jsxs)(`div`,{className:`content-block`,children:[(0,K.jsx)(`div`,{className:`msg-header-row`,style:{marginBottom:`4px`},children:(0,K.jsxs)(`div`,{className:`text-toggle-bar`,style:{marginTop:0},children:[(0,K.jsx)(`button`,{className:`text-toggle-btn${n===`raw`?` active`:``}`,onClick:()=>r(`raw`),children:`原文`}),(0,K.jsx)(`button`,{className:`text-toggle-btn${n===`markdown`?` active`:``}`,onClick:()=>r(`markdown`),children:`渲染`})]})}),(0,K.jsx)(X,{text:i,mode:n,isStreaming:t})]})}return e.type===`thinking`?(0,K.jsx)(Te,{content:e.thinking||``}):e.type===`tool_use`?(0,K.jsx)(Se,{block:e}):e.type===`tool_result`?(0,K.jsxs)(`div`,{className:`content-block block-framed`,style:{borderColor:`var(--purple)`,background:`var(--purple-bg)`},children:[(0,K.jsxs)(`span`,{className:`tool-use-label`,style:{color:`var(--purple)`,background:`color-mix(in srgb, var(--purple) 15%, transparent)`},children:[`↩ tool_result: `,e.tool_use_id||``]}),(0,K.jsx)(`div`,{className:`content-block-text`,children:typeof e.text==`string`?e.text:(0,K.jsx)(Q,{data:e.text})})]}):(0,K.jsx)(Q,{data:e})}function Se({block:e}){let[t,n]=(0,V.useState)(!1),r=e.input&&typeof e.input==`object`?Object.keys(e.input).length:0;return(0,K.jsxs)(`div`,{className:`tool-block`,style:{margin:`4px 0`},children:[(0,K.jsxs)(`div`,{className:`tool-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsx)(`span`,{className:`tb-arrow${t?` open`:``}`,children:`▶`}),(0,K.jsxs)(`span`,{className:`tb-name`,children:[`⚙ `,e.name||`tool_use`]}),!t&&r>0&&(0,K.jsxs)(`span`,{className:`tb-desc`,children:[`(`,r,` args)`]}),e.id&&(0,K.jsx)(`span`,{style:{marginLeft:`auto`,opacity:.45,fontSize:`11px`,fontFamily:`var(--mono)`},children:e.id})]}),t&&(0,K.jsx)(`div`,{className:`tool-block-body open`,children:(0,K.jsx)(Q,{data:e.input})})]})}function X({text:e,mode:t,isStreaming:n,sans:r,compact:i,className:a}){return e?(0,K.jsxs)(`div`,{className:`text-pane${a?` `+a:``}`,children:[(0,K.jsx)(`pre`,{className:`text-raw${r?` sans`:``}`,style:{display:t===`raw`?void 0:`none`},children:e}),(0,K.jsx)(`div`,{style:{display:t===`markdown`?void 0:`none`},children:i?(0,K.jsx)(`div`,{className:`text-raw sans`,style:{whiteSpace:`pre-wrap`},children:e}):(0,K.jsx)(me,{text:e,isStreaming:n})})]}):null}function Ce({text:e}){let[t,n]=(0,V.useState)(`raw`);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-toggle-bar`,style:{marginBottom:`6px`},children:[(0,K.jsx)(`button`,{className:`text-toggle-btn${t===`raw`?` active`:``}`,onClick:()=>n(`raw`),children:`原文`}),(0,K.jsx)(`button`,{className:`text-toggle-btn${t===`markdown`?` active`:``}`,onClick:()=>n(`markdown`),children:`渲染`})]}),(0,K.jsx)(X,{text:e,mode:t,sans:!0})]})}function we({text:e,mode:t}){return e?(0,K.jsx)(X,{text:e,mode:t}):null}function Te({content:e}){let[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(`raw`),a=e.slice(0,80).replace(/\n/g,` `);return(0,K.jsxs)(`div`,{className:`thinking-block content-block`,children:[(0,K.jsxs)(`div`,{className:`thinking-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsxs)(`span`,{className:`thinking-label`,children:[(0,K.jsx)(`span`,{className:`thinking-arrow`,children:t?`▼`:`▶`}),(0,K.jsx)(`span`,{children:`Thinking`})]}),t?(0,K.jsxs)(`div`,{className:`text-toggle-bar`,style:{marginTop:0,marginLeft:`4px`},onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{className:`text-toggle-btn${r===`raw`?` active`:``}`,onClick:()=>i(`raw`),children:`原文`}),(0,K.jsx)(`button`,{className:`text-toggle-btn${r===`markdown`?` active`:``}`,onClick:()=>i(`markdown`),children:`渲染`})]}):(0,K.jsxs)(`span`,{className:`thinking-preview`,children:[a,`…`]}),(0,K.jsx)(Z,{getText:()=>e,stopPropagation:!0,className:`copy-btn`})]}),t&&(0,K.jsx)(X,{text:e,mode:r,sans:!0})]})}function Ee({content:e}){let[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(`raw`),a=e.slice(0,80).replace(/\n/g,` `);return(0,K.jsxs)(`div`,{className:`thinking-block content-block`,style:{marginBottom:`8px`},children:[(0,K.jsxs)(`div`,{className:`thinking-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsxs)(`span`,{className:`thinking-label`,children:[(0,K.jsx)(`span`,{className:`thinking-arrow`,children:t?`▼`:`▶`}),(0,K.jsx)(`span`,{children:`Thinking`})]}),t?(0,K.jsxs)(`div`,{className:`text-toggle-bar`,style:{marginTop:0,marginLeft:`4px`},onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{className:`text-toggle-btn${r===`raw`?` active`:``}`,onClick:()=>i(`raw`),children:`原文`}),(0,K.jsx)(`button`,{className:`text-toggle-btn${r===`markdown`?` active`:``}`,onClick:()=>i(`markdown`),children:`渲染`})]}):(0,K.jsxs)(`span`,{className:`thinking-preview`,children:[a,`…`]}),(0,K.jsx)(Z,{getText:()=>e,stopPropagation:!0,className:`copy-btn`})]}),t&&(0,K.jsx)(X,{text:e,mode:r,sans:!0})]})}function De({toolCall:e}){let[t,n]=(0,V.useState)(!1),r=typeof e.arguments==`object`?Object.keys(e.arguments||{}).length:0;return(0,K.jsxs)(`div`,{className:`tool-block`,children:[(0,K.jsxs)(`div`,{className:`tool-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsx)(`span`,{className:`tb-arrow${t?` open`:``}`,children:`▶`}),(0,K.jsx)(`span`,{className:`tb-name`,children:e.name}),!t&&r>0&&(0,K.jsxs)(`span`,{className:`tb-desc`,children:[`(`,r,` args)`]})]}),t&&(0,K.jsxs)(`div`,{className:`tool-block-body open`,children:[(0,K.jsx)(Q,{data:e.arguments}),e.result!==void 0&&(0,K.jsxs)(`div`,{style:{marginTop:`10px`,paddingTop:`10px`,borderTop:`1px solid var(--border-light)`},children:[(0,K.jsx)(`div`,{style:{fontSize:`11px`,fontWeight:600,color:`var(--orange)`,marginBottom:`6px`,textTransform:`uppercase`},children:`Result`}),(0,K.jsx)(Q,{data:e.result})]})]})]})}function Oe({tools:e}){return(0,K.jsx)(`div`,{style:{display:`grid`,gap:`4px`},children:e.map((e,t)=>(0,K.jsx)(ke,{tool:e},t))})}function ke({tool:e}){let[t,n]=(0,V.useState)(!1),r=e.function||e,i=r.name||e.name||`unknown`,a=r.description||e.description||``,o=r.parameters||e.input_schema||e.parameters,s=o?.required||[],c=o?.properties||{};return(0,K.jsxs)(`div`,{className:`tool-block`,children:[(0,K.jsxs)(`div`,{className:`tool-block-header`,onClick:()=>n(e=>!e),children:[(0,K.jsx)(`span`,{className:`tb-arrow${t?` open`:``}`,children:`▶`}),(0,K.jsx)(`span`,{className:`tb-name`,children:i}),(0,K.jsx)(`span`,{className:`tb-desc`,children:a})]}),t&&(0,K.jsxs)(`div`,{className:`tool-block-body open`,children:[a&&(0,K.jsx)(`div`,{className:`tb-full-desc`,children:a}),Object.keys(c).length>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`tb-params-title`,children:`Parameters`}),Object.entries(c).map(([e,t])=>(0,K.jsxs)(`div`,{className:`tb-param`,children:[(0,K.jsxs)(`div`,{className:`tb-param-row1`,children:[(0,K.jsx)(`span`,{className:`tb-pname`,children:e}),t.type&&(0,K.jsx)(`span`,{className:`tb-ptype`,children:t.type}),s.includes(e)&&(0,K.jsx)(`span`,{className:`tb-prequired`,children:`required`})]}),t.description&&(0,K.jsx)(`div`,{className:`tb-pdesc`,children:t.description})]},e))]}):o?(0,K.jsx)(Q,{data:o}):null]})]})}function Z({getText:e,className:n=`copy-btn`,stopPropagation:i=!1}){let[a,o]=(0,V.useState)(!1);return(0,K.jsx)(`button`,{className:`${n}${a?` copied`:``}`,onClick:async t=>{i&&t.stopPropagation();try{await navigator.clipboard.writeText(e()),o(!0),setTimeout(()=>o(!1),1500)}catch{}},"data-tip":`复制`,children:a?(0,K.jsx)(r,{size:10}):(0,K.jsx)(t,{size:10})})}var Ae=0;function Q({data:e}){return Ae=0,(0,K.jsx)(`div`,{className:`json-view`,children:$(e,0)})}var je=new Set([`chunks`,`headers`,`tools`]);function $(e,t,n){if(t>50)return(0,K.jsx)(`span`,{className:`json-punct`,children:`…`});if(e===null)return(0,K.jsx)(`span`,{className:`jnull`,children:`null`});if(e===void 0)return(0,K.jsx)(`span`,{className:`jnull`,children:`undefined`});if(typeof e==`boolean`)return(0,K.jsx)(`span`,{className:`jb`,children:String(e)});if(typeof e==`number`)return(0,K.jsx)(`span`,{className:`jn`,children:e});if(typeof e==`string`)return(0,K.jsxs)(`span`,{className:`js`,children:[`"`,e.length>300?e.slice(0,300)+`…`:e,`"`]});if(typeof e!=`object`)return(0,K.jsx)(`span`,{children:String(e)});let r=Array.isArray(e),i=r?e.map((e,t)=>[t,e]):Object.entries(e),a=i.length;if(a===0)return(0,K.jsx)(`span`,{className:`json-punct`,children:r?`[]`:`{}`});if(a<=3&&t<2&&i.every(([,e])=>typeof e!=`object`||!e)){let e=i.map(([e,n],i)=>(0,K.jsxs)(`span`,{children:[!r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`jk`,children:[`"`,String(e),`"`]}),(0,K.jsx)(`span`,{className:`json-punct`,children:`: `})]}),$(n,t+1),i<a-1&&(0,K.jsx)(`span`,{className:`json-punct`,children:`, `})]},String(e)));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`json-punct`,children:r?`[`:`{`}),e,(0,K.jsx)(`span`,{className:`json-punct`,children:r?`]`:`}`})]})}let o=`jt`+ Ae++,s=`${a} ${r?`item`:`key`}${a===1?``:`s`}`,c=n!==void 0&&je.has(n),l=i.map(([e,n])=>(0,K.jsxs)(`div`,{className:`jt-line`,children:[!r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`jk`,children:[`"`,String(e),`"`]}),(0,K.jsx)(`span`,{className:`json-punct`,children:`: `})]}),$(n,t+1,String(e))]},String(e)));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`jt-toggle${c?``:` jt-open`}`,onClick:e=>Me(e,o),style:{cursor:`pointer`},children:c?`▶`:`▼`}),(0,K.jsx)(`span`,{className:`json-punct`,children:r?`[`:`{`}),(0,K.jsxs)(`span`,{className:`jt-summary${c?` jt-show`:``}`,id:`${o}s`,children:[`… `,s]}),(0,K.jsx)(`div`,{className:`jt-children${c?``:` jt-open`}`,id:o,children:l}),(0,K.jsx)(`div`,{className:`jt-close${c?` jt-hidden`:``}`,id:`${o}c`,children:(0,K.jsx)(`span`,{className:`json-punct`,children:r?`]`:`}`})})]})}function Me(e,t){e.stopPropagation();let n=document.getElementById(t),r=document.getElementById(t+`s`),i=document.getElementById(t+`c`),a=e.currentTarget;n&&(n.classList.contains(`jt-open`)?(n.classList.remove(`jt-open`),a.classList.remove(`jt-open`),a.textContent=`▶`,r?.classList.add(`jt-show`),i?.classList.add(`jt-hidden`)):(n.classList.add(`jt-open`),a.classList.add(`jt-open`),a.textContent=`▼`,r?.classList.remove(`jt-show`),i?.classList.remove(`jt-hidden`)))}function Ne(e){let t=e.request.body,n=[];if(typeof t.system==`string`&&t.system.trim())n.push(t.system);else if(Array.isArray(t.system)){let e=t.system.map(e=>typeof e==`string`?e:e?.type===`text`&&e.text||``).filter(Boolean).join(`
|
|
16
16
|
|
|
17
17
|
`);e.trim()&&n.push(e)}let r=e.request.body.messages||[];for(let e of r)if(e.role===`system`||e.role===`developer`){let t=typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>e.text||``).filter(Boolean).join(`
|
|
18
18
|
|
package/dist/web/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>LLM Proxy Trace</title>
|
|
7
7
|
|
|
8
8
|
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233b82f6' stroke-width='2'><circle cx='12' cy='12' r='10'/><path d='M12 6v6l4 2'/></svg>" />
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-DhD0ta31.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-QTnfLwEv.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/markdown-DsSlw-Z4.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-BnH7jZBV.js">
|