openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 5.06 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Kl as t,Ll as n,Ml as r,Oc as i,Ul as a,kl as o,tu as s}from"./control-ui-connection-Bfj9beF_.js";import{vh as c,yh as l}from"./control-ui-boot-shared-DFTSUQQ0.js";import{C as u,U as d,d as f,f as p,j as m,l as h,o as g,u as _,x as v}from"./solid-runtime-C416s-HC.js";import{Dl as y,Fl as b,Il as x,Ol as S}from"./control-ui-boot-chat-DewxEbIm.js";import{bt as C,xt as w}from"./control-ui-boot-chat-styles-CEPkk0Pv.js";import{t as T}from"./control-ui-boot-shared-DsegYo6K.js";import{i as E,r as D}from"./tool-call-view-C9KvEIPV.js";function O(e,n={},r=0){if(!(r>L)&&e!=null){if(typeof e==`string`){let n=e.trim();if(!n)return;let r=t(n.split(/\r?\n/,1)[0])??``;return r?r.length>160?`${i(r,0,79)}…${i(r,-80)}`:r:void 0}if(typeof e==`boolean`)return!e&&!n.includeFalsy?void 0:e?`true`:`false`;if(typeof e==`number`)return!Number.isFinite(e)||e===0&&!n.includeFalsy?void 0:String(e);if(Array.isArray(e)){let t=[];for(let i of e){let e=O(i,n,r+1);if(e){if(t.length===3)return`${t.join(`, `)}…`;t.push(e)}}return t.length>0?t.join(`, `):void 0}}}function k(e,t){let n=e;for(let e of t.split(`.`)){if(!e||!n||typeof n!=`object`)return;n=n[e]}return n}function A(e){for(let n of[e.path,e.file_path,e.filePath]){let e=t(n);if(e)return e}}function j(e){let t=A(e);if(!t)return;let r=n(e.offset,{min:1}),i=n(e.limit,{min:1});return r!==void 0&&i!==void 0?`${i===1?`line`:`lines`} ${r}-${r+i-1} from ${t}`:r===void 0?i===void 0?`from ${t}`:`first ${i} ${i===1?`line`:`lines`} of ${t}`:`from line ${r} in ${t}`}function M(e,n){let r=A(n)??t(n.url);if(!r)return;if(e===`attach`)return`from ${r}`;let i=e===`edit`?`in`:`to`,a=typeof n.content==`string`?n.content:typeof n.newText==`string`?n.newText:typeof n.new_string==`string`?n.new_string:void 0;return a?`${i} ${r} (${a.length} chars)`:`${i} ${r}`}function N(e){let t=P(e),n=o(e.count)??o(e.max_results)??o(e.num_results)??o(e.limit)??o(e.top_k);if(t.length===0)return;let r=t.slice(0,3).map(e=>`"${e}"`),i=t.length>r.length?`${r.join(`, `)}…`:r.join(`, `);return n===void 0?`for ${i}`:`for ${i} (top ${Math.floor(n)})`}function P(e){let n=new Set,r=e=>{let r=t(e);r&&n.add(r)};r(e.query),r(e.q),r(e.search),r(e.input),r(e.objective);for(let t of[`search_query`,`image_query`,`queries`,`search_queries`]){let n=e[t];if(Array.isArray(n))for(let e of n){if(typeof e==`string`){r(e);continue}let t=s(e);t&&(r(t.query),r(t.q),r(t.search))}}return[...n]}function F(e){let n=t(e.url);if(!n)return;let r=t(e.extractMode),i=o(e.maxChars),a=[r?`mode ${r}`:``,i===void 0?``:`max ${Math.floor(i)} chars`].filter(Boolean).join(`, `);return a?`from ${n} (${a})`:`from ${n}`}function I(e){if(x(e.toolKey))return;let{toolKey:n,args:r,meta:i}=e,a=s(r),o=t(a?.action),{spec:c,fallbackDetailKeys:l,detailMode:u,toolDetailMode:d,detailCoerce:f,detailFormatKey:p}=e,m=c&&o?c.actions?.[o]:void 0,h;(n===`exec`||n===`bash`||n===`shell`)&&(h=E(r,{detailMode:d})),a&&!h&&(n===`read`?h=j(a):n===`write`||n===`edit`||n===`attach`?h=M(n,a):n===`web_search`?h=N(a):n===`web_fetch`&&(h=F(a)));let g=m?.detailKeys??c?.detailKeys??l??[];if(!h&&g.length>0){let e=[];for(let t of g){let n=O(k(r,t),f);if(n){if(u===`first`){h=n;break}e.push({label:p?p(t):t,value:n})}}if(e.length===1)h=e.at(0)?.value;else if(e.length>1){let t=T(e,e=>`${e.label}:${e.value}`),n=[];for(let e=0;e<t.length&&e<8;e+=1){let r=t[e];r&&n.push(`${r.label} ${r.value}`)}h=n.join(`, `)}}return!h&&i&&(h=i),h}var L;function R(){return(R=e((()=>{r(),b(),D(),L=64})))()}function z(e){return e.replace(/^\/(?:Users|home)\/[^/]+(\/|$)/,`~$1`).replace(/^[A-Za-z]:\\Users\\[^\\]+(\\|$)/i,`~$1`)}function B(e){let t=S({name:e.name,args:e.args}),{name:n,label:r,icon:i}=w(t.name),o=a(n),s=U[o],c=I({toolKey:o,args:t.args,spec:s,fallbackDetailKeys:H.detailKeys,detailMode:`first`,toolDetailMode:e.detailMode,detailCoerce:{includeFalsy:!0}});return c&&=z(c),{name:n,icon:i,label:r,detail:c}}function V(e){return e.detail?`with ${e.detail}`:void 0}var H,U;function W(){return(W=e((()=>{c(),y(),R(),C(),H=l.fallback,U=l.tools})))()}function G(e){let t=[],n=0,r=!0;for(;n<e.length;){let i=e.charAt(n),a=n,o;if(/\s/.test(i)){for(;a<e.length&&/\s/.test(e.charAt(a));)a++;o=`ws`}else if(i===`'`||i===`"`){for(a+=1;a<e.length&&e.charAt(a)!==i;)a+=e.charAt(a)===`\\`?2:1;a=Math.min(a+1,e.length),o=`str`,r=!1}else if(Y.has(i)){for(;a<e.length&&Y.has(e.charAt(a));)a++;o=`op`,r=!0}else{for(;a<e.length&&!/\s/.test(e.charAt(a))&&!Y.has(e.charAt(a))&&e.charAt(a)!==`'`&&e.charAt(a)!==`"`;)a++;let t=e.slice(n,a);o=r?`name`:t.startsWith(`-`)?`flag`:/^\d+(?:[.,]\d+)?$/.test(t)?`num`:`plain`,r=!1}t.push({text:e.slice(n,a),cls:o}),n=a}return t}function K(e){return p(()=>p(()=>e.command.length>J)()?e.command:m(u,{get each(){return G(e.command)},children:e=>e.cls===`ws`||e.cls===`plain`?e.text:(()=>{var t=q();return f(t,()=>e.text),h(()=>`chat-cmd--${e.cls}`,(e,n)=>{g(t,e,n)}),t})()}))}var q,J,Y;function X(){return(X=e((()=>{_(),d(),q=v(`<span>`),J=2e3,Y=new Set([`|`,`;`,`&`,`<`,`>`])})))()}export{B as a,W as i,X as n,V as r,K as t};