UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 10.3 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{au as t,eu as n,kc as r}from"./control-ui-connection-Bfj9beF_.js";import{BA as i,dj as a,fs as o,jA as s,mj as c,pj as l,ps as u,zA as d}from"./control-ui-boot-shared-DFTSUQQ0.js";import{B as f,C as p,F as m,O as h,Rt as ee,U as te,d as g,f as _,g as v,j as y,l as b,s as ne,u as re,x}from"./solid-runtime-C416s-HC.js";import{ll as S,ml as ie,pl as ae,sl as oe}from"./control-ui-boot-chat-DewxEbIm.js";import{$ as C,at as w,et as se,it as T,ot as ce,st as le}from"./control-ui-boot-chat-styles-CEPkk0Pv.js";import{n as ue,r as de,t as fe}from"./tabs-B8AO2cOS.js";import{a as pe,t as E}from"./chat-diff-render.solid-B4cx69we.js";import{n as me,t as he}from"./tool-call-view-C9KvEIPV.js";import{a as ge,i as _e,n as ve,r as ye,t as D}from"./chat-command-highlight.solid-C89LTmsq.js";import{i as O,n as k,o as A,r as j,s as M,t as N}from"./tool-output-CG6hIsPO.js";function P(e){if(typeof e==`string`)return r(e,Z);if(e==null||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return r(JSON.stringify(e),Z)}catch{return Object.prototype.toString.call(e)}}function F(e){var t=I();return g(t,y(p,{get each(){return e.args},children:e=>(()=>{var t=L(),n=t.firstChild,r=n.firstChild,i=n.nextSibling;return g(n,()=>e[0],r),g(i,()=>P(e[1])),t})()})),t}function be(e){return y(h,{get when(){return _(()=>!!e.path)()?e.onOpen:e.path},get fallback(){var t=z();return g(t,()=>e.label),t},get children(){var t=R();return t._$$click=()=>e.path&&e.onOpen?.({path:e.path}),g(t,()=>e.label),b(()=>c(`chat.toolCards.openFile`),e=>{v(t,`title`,e)}),t}})}function xe(e){var t=V(),n=t.firstChild.firstChild.nextSibling;return g(n,y(D,{get command(){return e.command}})),g(t,y(h,{get when(){return e.output!==void 0},get children(){var t=B(),n=t.firstChild;return g(n,()=>e.output),t}}),null),t}function Se(e){let t=[`diff`,`raw`],n=()=>`${e.messageKey}:${e.card.id}`,r=m(()=>e.isError||e.outcome===`skipped`?`raw`:`diff`),[i,a]=f(r),[o,s]=f(()=>[r()]);var l=H(),u=l.firstChild,d=u.nextSibling;return g(l,y(ue,{get ariaLabel(){return c(`chat.toolCards.viewMode`)},get active(){return i()},activation:`auto`,onSelect:e=>{s(t=>t.includes(e)?t:[...t,e]),a(e)},get items(){return t.map(e=>({value:e,label:c(`chat.toolCards.${e}`),id:`${n()}-${e}-tab`,panelId:`${n()}-${e}-panel`}))}}),u),g(l,y(p,{each:t,children:t=>y(fe,{get id(){return`${n()}-${t}-panel`},get tabId(){return`${n()}-${t}-tab`},get active(){return i()===t},get children(){return y(h,{get when(){return o().includes(t)},get children(){return t===`diff`?y(E,{get lines(){return e.diff},get outcome(){return e.outcome},get file(){return e.file}}):y(w,{get label(){return _(()=>!!e.isError)()?c(`chat.toolCards.toolError`):void 0},get text(){return e.card.outputText}})}})}})}),d),l}function Ce(e){return e.map(e=>`${e.kind===`add`?`+`:e.kind===`del`?`-`:` `}${e.text}`).join(` `)}function we(e,t){let n={kind:`tool-output`,card:e,sessionKey:t.sessionKey,agentId:t.agentId},i=ae(e),a=O(e),o=k(i),s=Math.max(o?.length??0,e.outputText?.length??0)>N,c={...i,outputText:s&&t.onOpenSidebar&&!a?r(o??``,N):o},l=me({name:c.name,args:c.args,details:c.details}),u=ge({name:c.name,args:c.args}),d=l.kind===`read`||l.kind===`search`||l.kind===`fetch`,f=d?u.detail:ye(u),p=c.preview;return{card:c,view:l,outputText:o,outputIsLong:s,unavailable:a,detail:f,summarizedKind:d,sidebarActionContent:p?.kind===`canvas`&&p.render===`url`&&p.viewId&&p.url?{kind:`canvas`,docId:p.viewId,entryUrl:p.url,...p.title?{title:p.title}:{},...p.preferredHeight?{preferredHeight:p.preferredHeight}:{},...p.sandbox?{sandbox:p.sandbox}:{},...c.outputText?{rawText:c.outputText}:{}}:n,outputDetails:n,variant:l.kind===`command`&&(l.command||l.code)&&!c.preview?`command`:(l.kind===`edit`||l.kind===`write`)&&l.diff?.length?`diff`:`generic`,isError:S(c),outcome:ie(c,t.runActive),workspaceFilePath:se(c,l)}}function Te(e){let t=()=>e.state.view.code?n(e.state.card.args)?.code===e.state.view.code?`code`:`input`:`command`,r=m(()=>Object.entries(n(e.state.card.args)??{}).filter(([e])=>e!==t()));return[y(h,{get when(){return e.state.view.code},get fallback(){return y(xe,{get command(){return e.state.view.command},get output(){return e.state.card.outputText}})},get children(){return[y(h,{get when(){return t()!==`input`},get children(){return y(w,{get label(){return c(`chat.toolCards.toolInput`)},get text(){return e.state.view.code}})}}),y(h,{get when(){return e.state.card.outputText!==void 0},get children(){return y(w,{get text(){return e.state.card.outputText}})}}),y(h,{get when(){return t()===`input`},get children(){var t=U(),n=t.firstChild;return g(n,()=>c(`chat.toolCards.toolInput`)),g(t,y(w,{get text(){return e.state.view.code}}),null),t}})]}}),y(h,{get when(){return r().length>0},get children(){return y(F,{get args(){return r()}})}})]}function Ee(e){let n=m(()=>t(e.state.card.args)?Object.entries(e.state.card.args).filter(([t])=>!Q[e.state.view.kind]?.has(t)):null);return[y(h,{get when(){return _(()=>!!e.state.card.inputText?.trim())()?!e.state.summarizedKind||!!n()?.length:!!e.state.card.inputText?.trim()},get children(){return y(h,{get when(){return _(()=>!!(n()&&n().length>0))()?n().length<=X:n()&&n().length>0},get fallback(){return y(w,{get label(){return c(`chat.toolCards.toolInput`)},get text(){return e.state.card.inputText}})},get children(){return y(F,{get args(){return n()}})}})}}),y(h,{get when(){return _(()=>e.state.card.outputText!==void 0)()&&e.state.card.preview?.kind===`canvas`},get fallback(){return y(h,{get when(){return e.state.card.outputText!==void 0||e.state.isError},get children(){return y(w,{get label(){return _(()=>!!e.state.isError)()?c(`chat.toolCards.toolError`):void 0},get text(){return e.state.card.outputText??c(`chat.toolCards.noOutputFailed`)}})}})},get children(){return y(T,{get text(){return e.state.card.outputText}})}})]}function De(e){let t=m(()=>we(e.card,e.options)),n=()=>y(h,{get when(){return e.options.onOpenSidebar},get children(){var n=W(),r=n.firstChild,i=r.firstChild;return n._$owner=ee(),r._$$click=()=>e.options.onOpenSidebar?.(t().sidebarActionContent),g(i,y(d,{name:`panelRightOpen`})),b(()=>({e:c(`chat.toolCards.openDetails`),t:c(`chat.toolCards.openDetails`)}),({e,t},i)=>{e!==i?.e&&(n.content=e),t!==i?.t&&v(r,`aria-label`,t)}),n}});return y(h,{get when(){return t().variant},keyed:!0,children:r=>(()=>{var i=q(),a=i.firstChild,s=a.nextSibling,l=s.nextSibling,u=l.nextSibling,d=u.nextSibling,f=d.nextSibling;return i.classList.toggle(`chat-tool-card--flush`,r===`command`),g(i,y(h,{when:r===`command`,get fallback(){return y(h,{get when(){return r===`diff`||t().detail||e.options.onOpenSidebar},get children(){var i=J(),a=i.firstChild,s=a.firstChild,l=s.nextSibling;return g(i,y(h,{get when(){return r===`diff`||t().detail&&t().view.kind===`read`},get fallback(){return y(h,{get when(){return t().detail},get children(){var e=z();return g(e,()=>t().detail),e}})},get children(){return y(be,{get label(){return r===`diff`?t().workspaceFilePath??t().view.target??``:t().detail},get path(){return t().workspaceFilePath},get onOpen(){return e.options.onOpenWorkspaceFile}})}}),a),g(a,y(h,{get when(){return r===`diff`&&t().view.diff?.length},get children(){return y(o,{get text(){return Ce(t().view.diff)},get idleLabel(){return c(`common.copy`)}})}}),s),g(a,n,l),i}})},get children(){var e=G();return g(e,n),e}}),a),g(i,r===`command`?y(Te,{get state(){return t()}}):r===`diff`?y(h,{get when(){return t().card.outputText!==void 0},get fallback(){return y(E,{get lines(){return t().view.diff},get outcome(){return t().outcome},get file(){return t().view.fileOperations?.[0]??{path:t().view.target??``}}})},get children(){return y(Se,{get card(){return t().card},get messageKey(){return e.options.messageKey},get diff(){return t().view.diff},get outcome(){return t().outcome},get isError(){return t().isError},get file(){return t().view.fileOperations?.[0]??{path:t().view.target??``}}})}}):y(Ee,{get state(){return t()}}),s),g(i,y(h,{get when(){return _(()=>t().outputText!==e.card.outputText&&e.card.outputText!==void 0)()?!(t().outputIsLong&&e.options.onOpenSidebar):t().outputText!==e.card.outputText&&e.card.outputText!==void 0},get children(){return y(T,{get text(){return e.card.outputText}})}}),l),g(i,y(h,{get when(){return t().unavailable},get fallback(){return y(h,{get when(){return _(()=>!!(t().outputIsLong||t().card.outputTruncated))()?e.options.onOpenSidebar:t().outputIsLong||t().card.outputTruncated},get children(){var n=Y();return n._$$click=()=>e.options.onOpenSidebar?.(t().outputDetails),g(n,()=>c(`chat.toolCards.showFullOutput`)),n}})},get children(){var e=K();return g(e,()=>c(`chat.toolCards.fullOutputUnavailable`)),e}}),u),g(i,y(h,{get when(){return t().card.catalogTruncated},get children(){var e=K();return g(e,()=>c(`chat.catalogOutputTruncated`)),e}}),d),g(i,y(ce,{get outcome(){return t().outcome},get exitCode(){return t().card.exitCode}}),f),b(()=>!!t().isError,e=>{i.classList.toggle(`chat-tool-card--error`,e)}),i})()})}var I,L,R,z,B,V,H,U,W,G,K,q,J,Y,X,Z,Q;function $(){return($=e((()=>{re(),te(),u(),i(),s(),de(),A(),he(),oe(),_e(),j(),a(),ve(),pe(),le(),C(),I=x(`<div class=chat-tool-kv>`),L=x(`<div class=chat-tool-kv__row><span class=chat-tool-kv__key>:</span><span class=chat-tool-kv__value>`),R=x(`<button class="chat-tool-card__detail chat-tool-card__detail-link"type=button>`),z=x(`<div class=chat-tool-card__detail>`),B=x(`<pre class=chat-tool-term__out><code>`),V=x(`<div class=chat-tool-term><div class=chat-tool-term__cmd><span class=chat-tool-term__prompt>$</span><code>`),H=x(`<div class=chat-tool-card__modes><!><!>`),U=x(`<details class=chat-tool-card__input><summary>`),W=x(`<openclaw-tooltip><button class=chat-tool-card__action-btn type=button><span class=chat-tool-card__action-icon>`,1),G=x(`<div class=chat-tool-card__actions>`),K=x(`<p role=status>`),q=x(`<div class=chat-tool-card><!><!><!><!><!><!>`),J=x(`<div class=chat-tool-card__header><div class=chat-tool-card__actions><!><!>`),Y=x(`<button class="btn btn--sm"type=button>`),l(M),X=12,Z=400,Q={read:new Set([`path`,`file_path`,`filePath`,`notebook_path`]),search:new Set([`pattern`,`query`,`glob`,`path`]),fetch:new Set([`url`])},ne([`click`])})))()}$();export{De as ExpandedToolCardContent};