UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

2 lines (1 loc) 1.83 kB
var m=Object.defineProperty;var t=(e,o)=>m(e,"name",{value:o,configurable:!0});import{updateToolCallInMessage as g}from"./tool-execution.js";import{IS_PROD as T}from"jodit/esm/core/constants.js";async function L(e,o,n,i,f){const s=n.getPendingToolCalls().find(c=>c.id===e);if(!s)return console.error("Tool call not found:",e),null;const l=i.grantPermission(s.name,o),r=n.getCurrentConversation();return r&&(r.permissions.push(l),await f.save(r)),n.removePendingToolCall(e),{...s,status:"approved"}}t(L,"handleToolApproval");async function x(e,o,n,i){const a=n.getPendingToolCalls().find(d=>d.id===o);if(!a)return;let s=n.getCurrentConversation();if(!s)return;const l=s.messages.findIndex(d=>{var u;return(u=d.toolCalls)===null||u===void 0?void 0:u.find(p=>p.id===o)});if(l===-1)return;const r=s.messages[l],c={...a,result:{error:"Tool call denied by user."},status:"denied"},C=g(r,c),v=[...s.messages];v[l]=C,s={...s,messages:v,updated:Date.now()},n.setCurrentConversation(s),await i.save(s),e.e.fire("toolCallDenied.ai-assistant-pro",a),n.removePendingToolCall(o)}t(x,"handleToolDenial");async function P(e,o,n){try{n.setLoading(!0);const i=await o.get(e);if(!i)throw new Error("Conversation not found: "+e);n.setCurrentConversation({...i})}catch(i){T||console.warn(i)}finally{n.setLoading(!1)}}t(P,"handleConversationSelect");async function D(e,o){o.setView("conversationList");try{o.setLoading(!0);const n=await e.list().catch(()=>[]);o.setConversations(n)}finally{o.setLoading(!1)}}t(D,"handleBackToList");async function S(e,o,n){n.setLoading(!0);try{const i=await o.list(e||void 0);n.setConversations(i),n.setView("conversationList")}finally{n.setLoading(!1)}}t(S,"handleConversationSearch");export{D as handleBackToList,S as handleConversationSearch,P as handleConversationSelect,L as handleToolApproval,x as handleToolDenial};