openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 5.1 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Eu as t,Fu as n,Mu as r,Wu as i,or as a,vu as o,xu as s}from"./_4____________________________.js";import{mg as c,pg as l}from"./_2_____________________________.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"./_6____________________.js";import{Xo as y,Zo as b,_i as x,ao as S,fo as C,gi as w,oo as T,po as E}from"./control-ui-boot-chat-styles-DMRbEm40.js";import{t as ee}from"./_3_____________________________.js";import{a as te,i as D,o as O,r as k}from"./tool-call-view-XnwTV4mS.js";function A(e,t={},r=0){if(!(r>z)&&e!=null){if(typeof e==`string`){let t=e.trim();if(!t)return;let r=n(t.split(/\r?\n/,1)[0])??``;return r?r.length>160?`${a(r,0,79)}…${a(r,-80)}`:r:void 0}if(typeof e==`boolean`)return!e&&!t.includeFalsy?void 0:e?`true`:`false`;if(typeof e==`number`)return!Number.isFinite(e)||e===0&&!t.includeFalsy?void 0:String(e);if(Array.isArray(e)){let n=[];for(let i of e){let e=A(i,t,r+1);if(e){if(n.length===3)return`${n.join(`, `)}…`;n.push(e)}}return n.length>0?n.join(`, `):void 0}}}function j(e,t){let n=e;for(let e of t.split(`.`)){if(!e||!n||typeof n!=`object`)return;n=n[e]}return n}function M(e){for(let t of[e.path,e.file_path,e.filePath]){let e=n(t);if(e)return e}}function N(e){let n=M(e);if(!n)return;let r=t(e.offset,{min:1}),i=t(e.limit,{min:1});return r!==void 0&&i!==void 0?`${i===1?`line`:`lines`} ${r}-${r+i-1} from ${n}`:r===void 0?i===void 0?`from ${n}`:`first ${i} ${i===1?`line`:`lines`} of ${n}`:`from line ${r} in ${n}`}function P(e,t){let r=M(t)??n(t.url);if(!r)return;if(e===`attach`)return`from ${r}`;let i=e===`edit`?`in`:`to`,a=typeof t.content==`string`?t.content:typeof t.newText==`string`?t.newText:typeof t.new_string==`string`?t.new_string:void 0;return a?`${i} ${r} (${a.length} chars)`:`${i} ${r}`}function F(e){let t=I(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 I(e){let t=new Set,r=e=>{let r=n(e);r&&t.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=i(e);t&&(r(t.query),r(t.q),r(t.search))}}return[...t]}function L(e){let t=n(e.url);if(!t)return;let r=n(e.extractMode),i=o(e.maxChars),a=[r?`mode ${r}`:``,i===void 0?``:`max ${Math.floor(i)} chars`].filter(Boolean).join(`, `);return a?`from ${t} (${a})`:`from ${t}`}function R(e){if(E(e.toolKey))return;let{toolKey:t,args:r,meta:a}=e,o=i(r),s=n(o?.action),{spec:c,fallbackDetailKeys:l,detailMode:u,toolDetailMode:d,detailCoerce:f,detailFormatKey:p}=e,m=c&&s?c.actions?.[s]:void 0,h;(t===`exec`||t===`bash`||t===`shell`)&&(h=D(r,{detailMode:d})),o&&!h&&(t===`read`?h=N(o):t===`write`||t===`edit`||t===`attach`?h=P(t,o):t===`web_search`?h=F(o):t===`web_fetch`&&(h=L(o)));let g=m?.detailKeys??c?.detailKeys??l??[];if(!h&&g.length>0){let e=[];for(let t of g){let n=A(j(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=ee(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&&a&&(h=a),h}var z;function B(){return(B=e((()=>{s(),C(),k(),z=64})))()}function V(e){return e.replace(/^\/(?:Users|home)\/[^/]+(\/|$)/,`~$1`).replace(/^[A-Za-z]:\\Users\\[^\\]+(\\|$)/i,`~$1`)}function H(e){let t=b({name:e.name,args:e.args}),{name:n,label:i,icon:a}=T(t.name),o=r(n),s=G[o],c=R({toolKey:o,args:t.args,spec:s,fallbackDetailKeys:W.detailKeys,detailMode:`first`,toolDetailMode:e.detailMode,detailCoerce:{includeFalsy:!0}});return c&&=V(c),{name:n,icon:a,label:i,detail:c}}function U(e){return e.detail?`with ${e.detail}`:void 0}var W,G;function K(){return(K=e((()=>{l(),y(),B(),S(),W=c.fallback,G=c.tools})))()}function q(e){return w(O(e).command||e)}function J(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(Q.has(i)){for(;a<e.length&&Q.has(e.charAt(a));)a++;o=`op`,r=!0}else{for(;a<e.length&&!/\s/.test(e.charAt(a))&&!Q.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 Y(e){return p(()=>p(()=>e.command.length>Z)()?e.command:m(u,{get each(){return J(e.command)},children:e=>e.cls===`ws`||e.cls===`plain`?e.text:(()=>{var t=X();return f(t,()=>e.text),h(()=>`chat-cmd--${e.cls}`,(e,n)=>{g(t,e,n)}),t})()}))}var X,Z,Q;function $(){return($=e((()=>{_(),d(),te(),x(),X=v(`<span>`),Z=2e3,Q=new Set([`|`,`;`,`&`,`<`,`>`])})))()}export{K as a,U as i,$ as n,H as o,q as r,Y as t};