totem-llm 0.12.0 → 0.13.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "totem-llm",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Totem LLM – Your Private AI. Run a self-hosted AI assistant locally on Linux, macOS, or Windows.",
5
5
  "main": "bin/totem-llm.js",
6
6
  "type": "module",
@@ -3,7 +3,10 @@ const {
3
3
  } = require("../models/externalCommunicationConnector");
4
4
  const { TelegramBotService } = require("../utils/telegramBot");
5
5
  const { validatedRequest } = require("../utils/middleware/validatedRequest");
6
- const { isSingleUserMode } = require("../utils/middleware/multiUserProtected");
6
+ const {
7
+ flexUserRoleValid,
8
+ ROLES,
9
+ } = require("../utils/middleware/multiUserProtected");
7
10
  const { reqBody } = require("../utils/http");
8
11
  const { EventLogs } = require("../models/eventLogs");
9
12
  const { Workspace } = require("../models/workspace");
@@ -15,7 +18,7 @@ function telegramEndpoints(app) {
15
18
 
16
19
  app.get(
17
20
  "/telegram/config",
18
- [validatedRequest, isSingleUserMode],
21
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
19
22
  async (_request, response) => {
20
23
  try {
21
24
  const connector = await ExternalCommunicationConnector.get("telegram");
@@ -73,7 +76,7 @@ function telegramEndpoints(app) {
73
76
  */
74
77
  app.post(
75
78
  "/telegram/connect",
76
- [validatedRequest, isSingleUserMode],
79
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
77
80
  async (request, response) => {
78
81
  try {
79
82
  const { bot_token, default_workspace = null } = reqBody(request);
@@ -158,7 +161,7 @@ function telegramEndpoints(app) {
158
161
 
159
162
  app.post(
160
163
  "/telegram/disconnect",
161
- [validatedRequest, isSingleUserMode],
164
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
162
165
  async (_request, response) => {
163
166
  try {
164
167
  const service = new TelegramBotService();
@@ -175,7 +178,7 @@ function telegramEndpoints(app) {
175
178
 
176
179
  app.get(
177
180
  "/telegram/status",
178
- [validatedRequest, isSingleUserMode],
181
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
179
182
  async (_request, response) => {
180
183
  try {
181
184
  const connector = await ExternalCommunicationConnector.get("telegram");
@@ -193,7 +196,7 @@ function telegramEndpoints(app) {
193
196
 
194
197
  app.get(
195
198
  "/telegram/pending-users",
196
- [validatedRequest, isSingleUserMode],
199
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
197
200
  async (_request, response) => {
198
201
  try {
199
202
  const service = new TelegramBotService();
@@ -209,7 +212,7 @@ function telegramEndpoints(app) {
209
212
 
210
213
  app.get(
211
214
  "/telegram/approved-users",
212
- [validatedRequest, isSingleUserMode],
215
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
213
216
  async (_request, response) => {
214
217
  try {
215
218
  const connector = await ExternalCommunicationConnector.get("telegram");
@@ -224,7 +227,7 @@ function telegramEndpoints(app) {
224
227
 
225
228
  app.post(
226
229
  "/telegram/approve-user",
227
- [validatedRequest, isSingleUserMode],
230
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
228
231
  async (request, response) => {
229
232
  try {
230
233
  const { chatId } = reqBody(request);
@@ -246,7 +249,7 @@ function telegramEndpoints(app) {
246
249
 
247
250
  app.post(
248
251
  "/telegram/deny-user",
249
- [validatedRequest, isSingleUserMode],
252
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
250
253
  async (request, response) => {
251
254
  try {
252
255
  const { chatId } = reqBody(request);
@@ -268,7 +271,7 @@ function telegramEndpoints(app) {
268
271
 
269
272
  app.post(
270
273
  "/telegram/revoke-user",
271
- [validatedRequest, isSingleUserMode],
274
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
272
275
  async (request, response) => {
273
276
  try {
274
277
  const { chatId } = reqBody(request);
@@ -290,7 +293,7 @@ function telegramEndpoints(app) {
290
293
 
291
294
  app.post(
292
295
  "/telegram/update-config",
293
- [validatedRequest, isSingleUserMode],
296
+ [validatedRequest, flexUserRoleValid([ROLES.admin])],
294
297
  async (request, response) => {
295
298
  try {
296
299
  const { voice_response_mode } = reqBody(request);
@@ -14,6 +14,7 @@ process.on("message", async (payload) => {
14
14
  const {
15
15
  botToken,
16
16
  chatId,
17
+ messageThreadId,
17
18
  workspaceSlug,
18
19
  threadSlug,
19
20
  message,
@@ -46,6 +47,7 @@ process.on("message", async (payload) => {
46
47
  await streamResponse({
47
48
  ctx,
48
49
  chatId,
50
+ messageThreadId,
49
51
  workspace,
50
52
  thread,
51
53
  message,
@@ -1,3 +1,3 @@
1
- import{r as c,j as e,p,C as h,c as d,W as I,ag as w,a6 as v,aL as S,aG as C,s as A,v as L,aN as T,a2 as F,i as N}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{r as H}from"./files-202b5d45.js";import{p as P}from"./purify-5067c4b9.js";import{s as U}from"./index-a675b600.js";import{A as b}from"./agentFlows-e4124dd3.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./index-0b8978d7.js";import"./truncate-e484143c.js";import"./XCircle-edfe554c.js";import"./moment-49fc1b76.js";import"./File-b92df2f3.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";import"./react-beautiful-dnd.esm-51607d6e.js";import"./mcpServers-d6808fa0.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./Trans-11790b69.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-6f49fa27.js";import"./index-e7e7c547.js";import"./WarningCircle-27467274.js";import"./index-8ba96f42.js";import"./Hammer-05b5ccc7.js";function z({settings:t,setSettings:l,setStep:s}){const[n,a]=c.useState(t.itemId),i=()=>{if(!n)return d("Please enter an item ID","error");l(r=>({...r,itemId:n})),s(x.itemId.next())};return e.jsx("div",{className:"flex-[2] flex flex-col gap-y-[18px] mt-10",children:e.jsx("div",{className:"bg-theme-bg-secondary rounded-xl flex-1 p-6",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-2 max-w-[700px]",children:[e.jsx("h2",{className:"text-base text-theme-text-primary font-semibold",children:"Import an item from the community hub"}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-theme-text-secondary text-sm",children:[e.jsx("p",{children:"The community hub is a place where you can find, share, and import agent-skills, system prompts, slash commands, and more!"}),e.jsx("p",{children:"These items are created by the AnythingLLM team and community, and are a great way to get started with AnythingLLM as well as extend AnythingLLM in a way that is customized to your needs."}),e.jsxs("p",{children:["There are both ",e.jsx("b",{children:"private"})," and ",e.jsx("b",{children:"public"})," items in the community hub. Private items are only visible to you, while public items are visible to everyone."]}),e.jsxs("p",{className:"p-4 bg-yellow-800/30 light:bg-orange-100 light:text-orange-500 light:border-orange-500 rounded-lg border border-yellow-500 text-yellow-500",children:["If you are pulling in a private item, make sure it is"," ",e.jsx("b",{children:"shared with a team"})," you belong to, and you have added a"," ",e.jsx("a",{href:p.communityHub.authentication(),className:"underline text-yellow-100 light:text-orange-500 font-semibold",children:"Connection Key."})]})]}),e.jsx("div",{className:"flex flex-col gap-y-2 mt-4",children:e.jsx("div",{className:"w-full flex flex-col gap-y-4",children:e.jsxs("div",{className:"flex flex-col w-full",children:[e.jsx("label",{className:"text-theme-text-primary text-sm font-semibold block mb-3",children:"Community Hub Item Import ID"}),e.jsx("input",{type:"text",value:n,onChange:r=>a(r.target.value),placeholder:"allm-community-id:agent-skill:1234567890",className:"border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"})]})})}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:i,children:"Continue with import →"})]})})})}function E({item:t,setStep:l}){const[s,n]=c.useState(null),[a,i]=c.useState([]);c.useEffect(()=>{async function o(){const m=await I.all();i(m),n(m[0].slug)}o()},[]);async function r(){d("Applying system prompt to workspace...","info");const{error:o}=await f.applyItem(t.importId,{workspaceSlug:s});if(o)return d(`Failed to apply system prompt. ${o}`,"error",{clear:!0});d("System prompt applied to workspace.","success",{clear:!0}),l(x.completed.key)}return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review System Prompt "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:[e.jsx("p",{children:"System prompts are used to guide the behavior of the AI agents and can be applied to any existing workspace."}),e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-semibold",children:"Provided system prompt:"}),e.jsx("div",{className:"w-full text-theme-text-primary text-md flex flex-col max-h-[calc(300px)] overflow-y-auto",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-mono bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md text-sm whitespace-pre-line",children:t.prompt})})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-theme-text-primary text-sm font-semibold block mb-3",children:"Apply to Workspace"}),e.jsx("select",{name:"destinationWorkspaceSlug",required:!0,onChange:o=>n(o.target.value),className:"border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:e.jsx("optgroup",{label:"Available workspaces",children:a.map(o=>e.jsx("option",{value:o.slug,children:o.name},o.id))})})]})]}),s&&e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:r,children:"Apply system prompt to workspace"})]})}function M({item:t,setStep:l}){async function s(){try{const{error:n}=await f.applyItem(t.importId);if(n)throw new Error(n);d(`Slash command ${t.command} imported successfully!`,"success"),l(x.completed.key)}catch(n){console.error(n),d(`Failed to import slash command. ${n.message}`,"error")}}return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review Slash Command "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:[e.jsxs("p",{children:["Slash commands are used to prefill information into a prompt while chatting with a AnythingLLM workspace.",e.jsx("br",{}),e.jsx("br",{}),"The slash command will be available during chatting by simply invoking it with"," ",e.jsx("code",{className:"font-mono bg-zinc-900 light:bg-slate-200 px-1 py-0.5 rounded-md text-sm",children:t.command})," ","like you would any other command."]}),e.jsxs("div",{className:"flex flex-col gap-y-2 mt-2",children:[e.jsx("div",{className:"w-full text-theme-text-primary text-md gap-x-2 flex items-center",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary w-fit font-mono bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md text-sm whitespace-pre-line",children:t.command})}),e.jsx("div",{className:"w-full text-theme-text-primary text-md flex flex-col gap-y-2",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-mono bg-zinc-900 light:bg-slate-200 p-4 rounded-md text-sm whitespace-pre-line max-h-[calc(200px)] overflow-y-auto",children:t.prompt})})]})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:s,children:"Import slash command"})]})}function $({item:t,setSettings:l,setStep:s}){return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"w-full flex items-center gap-x-2",children:[e.jsx(w,{size:24,className:"text-red-500"}),e.jsx("h2",{className:"text-base text-red-500 font-semibold",children:"Unsupported item"})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 text-sm",children:[e.jsx("p",{children:"We found an item in the community hub, but we don't know what it is or it is not yet supported for import into AnythingLLM."}),e.jsxs("p",{children:["The item ID is: ",e.jsx("b",{children:t.id}),e.jsx("br",{}),"The item type is: ",e.jsx("b",{children:t.itemType})]}),e.jsx("p",{children:"Please contact support via email if you need help importing this item."})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:()=>{l({itemId:null,item:null}),s(x.itemId.key)},children:"Try another item"})]})}function D({item:t,settings:l,setStep:s}){const[n,a]=c.useState(!1);async function i(){try{a(!0);const{error:r}=await f.importBundleItem(l.itemId);if(r)throw new Error(r);d("Agent skill imported successfully!","success"),s(x.completed.key)}catch(r){console.error(r),d(`Failed to import agent skill. ${r.message}`,"error")}finally{a(!1)}}return c.useEffect(()=>{U()},[]),e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsx("div",{className:"border border-white/10 light:border-orange-500/20 my-2 flex flex-col md:flex-row md:items-center gap-x-2 text-theme-text-primary light:text-orange-600 mb-4 bg-orange-800/30 light:bg-orange-500/10 rounded-lg px-4 py-2",children:e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(w,{size:25}),e.jsxs("h1",{className:"text-lg font-semibold",children:[" ","Only import agent skills you trust"," "]})]}),e.jsx("p",{className:"text-sm",children:"Agent skills can execute code on your AnythingLLM instance, so only import agent skills from sources you trust. You should also review the code before importing. If you are unsure about what a skill does - don't import it!"})]})}),e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review Agent Skill "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]}),e.jsxs("div",{className:"flex gap-x-1",children:[t.verified?e.jsx("p",{className:"text-green-500 text-xs font-mono",children:"Verified code"}):e.jsx("p",{className:"text-red-500 text-xs font-mono",children:"This skill is not verified."}),e.jsx("a",{href:"https://docs.anythingllm.com/community-hub/faq#verification",target:"_blank",className:"text-xs font-mono text-blue-500 hover:underline",rel:"noreferrer",children:"Learn more →"})]})]}),e.jsx("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:e.jsxs("p",{children:["Agent skills unlock new capabilities for your AnythingLLM workspace via"," ",e.jsx("code",{className:"font-mono bg-zinc-900 light:bg-slate-200 px-1 py-0.5 rounded-md text-sm",children:"@agent"})," ","skills that can do specific tasks when invoked."]})}),e.jsx(W,{item:t}),e.jsxs(h,{disabled:n,className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:i,children:[n?e.jsx(v,{size:16,className:"animate-spin"}):null,n?"Importing...":"Import agent skill"]})]})}function W({item:t}){const l=t.manifest.files||[],[s,n]=c.useState(0),[a,i]=c.useState(l[s]);function r(){s>0&&n(s-1)}function o(){s<l.length-1&&n(s+1)}function m(u){switch(u.name.split(".").pop()){case"js":return"javascript";case"json":return"json";case"md":return"markdown";default:return"text"}}return c.useEffect(()=>{l.length>0&&i((l==null?void 0:l[s])||l[0])},[s]),a?e.jsx("div",{className:"flex flex-col gap-y-2",children:e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("button",{type:"button",className:`border-none bg-black/70 light:bg-slate-200 rounded-md p-1 text-white/60 light:text-theme-text-secondary text-xs font-mono ${s===0?"opacity-50 cursor-not-allowed":""}`,onClick:r,children:e.jsx(S,{size:16})}),e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:[a.name," (",s+1," of ",l.length," files)"]}),e.jsx("button",{type:"button",className:`border-none bg-black/70 light:bg-slate-200 rounded-md p-1 text-white/60 light:text-theme-text-secondary text-xs font-mono ${s===l.length-1?"opacity-50 cursor-not-allowed":""}`,onClick:o,children:e.jsx(C,{size:16})})]}),e.jsx("span",{className:"whitespace-pre-line flex flex-col gap-y-1 text-sm leading-[20px] max-h-[500px] overflow-y-auto hljs text-theme-text-primary",dangerouslySetInnerHTML:{__html:P.sanitize(H(`\`\`\`${m(a)}
1
+ import{r as c,j as e,p,C as h,c as d,W as I,ag as w,a6 as v,aL as S,aG as C,s as A,v as L,aN as T,a2 as F,i as N}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{r as H}from"./files-202b5d45.js";import{p as P}from"./purify-5067c4b9.js";import{s as U}from"./index-44382a03.js";import{A as b}from"./agentFlows-e4124dd3.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./index-0b8978d7.js";import"./truncate-e484143c.js";import"./XCircle-edfe554c.js";import"./moment-49fc1b76.js";import"./File-b92df2f3.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";import"./react-beautiful-dnd.esm-51607d6e.js";import"./mcpServers-d6808fa0.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./Trans-11790b69.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-6f49fa27.js";import"./index-e7e7c547.js";import"./WarningCircle-27467274.js";import"./index-8ba96f42.js";import"./Hammer-05b5ccc7.js";function z({settings:t,setSettings:l,setStep:s}){const[n,a]=c.useState(t.itemId),i=()=>{if(!n)return d("Please enter an item ID","error");l(r=>({...r,itemId:n})),s(x.itemId.next())};return e.jsx("div",{className:"flex-[2] flex flex-col gap-y-[18px] mt-10",children:e.jsx("div",{className:"bg-theme-bg-secondary rounded-xl flex-1 p-6",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-2 max-w-[700px]",children:[e.jsx("h2",{className:"text-base text-theme-text-primary font-semibold",children:"Import an item from the community hub"}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-theme-text-secondary text-sm",children:[e.jsx("p",{children:"The community hub is a place where you can find, share, and import agent-skills, system prompts, slash commands, and more!"}),e.jsx("p",{children:"These items are created by the AnythingLLM team and community, and are a great way to get started with AnythingLLM as well as extend AnythingLLM in a way that is customized to your needs."}),e.jsxs("p",{children:["There are both ",e.jsx("b",{children:"private"})," and ",e.jsx("b",{children:"public"})," items in the community hub. Private items are only visible to you, while public items are visible to everyone."]}),e.jsxs("p",{className:"p-4 bg-yellow-800/30 light:bg-orange-100 light:text-orange-500 light:border-orange-500 rounded-lg border border-yellow-500 text-yellow-500",children:["If you are pulling in a private item, make sure it is"," ",e.jsx("b",{children:"shared with a team"})," you belong to, and you have added a"," ",e.jsx("a",{href:p.communityHub.authentication(),className:"underline text-yellow-100 light:text-orange-500 font-semibold",children:"Connection Key."})]})]}),e.jsx("div",{className:"flex flex-col gap-y-2 mt-4",children:e.jsx("div",{className:"w-full flex flex-col gap-y-4",children:e.jsxs("div",{className:"flex flex-col w-full",children:[e.jsx("label",{className:"text-theme-text-primary text-sm font-semibold block mb-3",children:"Community Hub Item Import ID"}),e.jsx("input",{type:"text",value:n,onChange:r=>a(r.target.value),placeholder:"allm-community-id:agent-skill:1234567890",className:"border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"})]})})}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:i,children:"Continue with import →"})]})})})}function E({item:t,setStep:l}){const[s,n]=c.useState(null),[a,i]=c.useState([]);c.useEffect(()=>{async function o(){const m=await I.all();i(m),n(m[0].slug)}o()},[]);async function r(){d("Applying system prompt to workspace...","info");const{error:o}=await f.applyItem(t.importId,{workspaceSlug:s});if(o)return d(`Failed to apply system prompt. ${o}`,"error",{clear:!0});d("System prompt applied to workspace.","success",{clear:!0}),l(x.completed.key)}return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review System Prompt "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:[e.jsx("p",{children:"System prompts are used to guide the behavior of the AI agents and can be applied to any existing workspace."}),e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-semibold",children:"Provided system prompt:"}),e.jsx("div",{className:"w-full text-theme-text-primary text-md flex flex-col max-h-[calc(300px)] overflow-y-auto",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-mono bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md text-sm whitespace-pre-line",children:t.prompt})})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-theme-text-primary text-sm font-semibold block mb-3",children:"Apply to Workspace"}),e.jsx("select",{name:"destinationWorkspaceSlug",required:!0,onChange:o=>n(o.target.value),className:"border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:e.jsx("optgroup",{label:"Available workspaces",children:a.map(o=>e.jsx("option",{value:o.slug,children:o.name},o.id))})})]})]}),s&&e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:r,children:"Apply system prompt to workspace"})]})}function M({item:t,setStep:l}){async function s(){try{const{error:n}=await f.applyItem(t.importId);if(n)throw new Error(n);d(`Slash command ${t.command} imported successfully!`,"success"),l(x.completed.key)}catch(n){console.error(n),d(`Failed to import slash command. ${n.message}`,"error")}}return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review Slash Command "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:[e.jsxs("p",{children:["Slash commands are used to prefill information into a prompt while chatting with a AnythingLLM workspace.",e.jsx("br",{}),e.jsx("br",{}),"The slash command will be available during chatting by simply invoking it with"," ",e.jsx("code",{className:"font-mono bg-zinc-900 light:bg-slate-200 px-1 py-0.5 rounded-md text-sm",children:t.command})," ","like you would any other command."]}),e.jsxs("div",{className:"flex flex-col gap-y-2 mt-2",children:[e.jsx("div",{className:"w-full text-theme-text-primary text-md gap-x-2 flex items-center",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary w-fit font-mono bg-zinc-900 light:bg-slate-200 px-2 py-1 rounded-md text-sm whitespace-pre-line",children:t.command})}),e.jsx("div",{className:"w-full text-theme-text-primary text-md flex flex-col gap-y-2",children:e.jsx("p",{className:"text-white/60 light:text-theme-text-secondary font-mono bg-zinc-900 light:bg-slate-200 p-4 rounded-md text-sm whitespace-pre-line max-h-[calc(200px)] overflow-y-auto",children:t.prompt})})]})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:s,children:"Import slash command"})]})}function $({item:t,setSettings:l,setStep:s}){return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"w-full flex items-center gap-x-2",children:[e.jsx(w,{size:24,className:"text-red-500"}),e.jsx("h2",{className:"text-base text-red-500 font-semibold",children:"Unsupported item"})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 text-sm",children:[e.jsx("p",{children:"We found an item in the community hub, but we don't know what it is or it is not yet supported for import into AnythingLLM."}),e.jsxs("p",{children:["The item ID is: ",e.jsx("b",{children:t.id}),e.jsx("br",{}),"The item type is: ",e.jsx("b",{children:t.itemType})]}),e.jsx("p",{children:"Please contact support via email if you need help importing this item."})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:()=>{l({itemId:null,item:null}),s(x.itemId.key)},children:"Try another item"})]})}function D({item:t,settings:l,setStep:s}){const[n,a]=c.useState(!1);async function i(){try{a(!0);const{error:r}=await f.importBundleItem(l.itemId);if(r)throw new Error(r);d("Agent skill imported successfully!","success"),s(x.completed.key)}catch(r){console.error(r),d(`Failed to import agent skill. ${r.message}`,"error")}finally{a(!1)}}return c.useEffect(()=>{U()},[]),e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsx("div",{className:"border border-white/10 light:border-orange-500/20 my-2 flex flex-col md:flex-row md:items-center gap-x-2 text-theme-text-primary light:text-orange-600 mb-4 bg-orange-800/30 light:bg-orange-500/10 rounded-lg px-4 py-2",children:e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(w,{size:25}),e.jsxs("h1",{className:"text-lg font-semibold",children:[" ","Only import agent skills you trust"," "]})]}),e.jsx("p",{className:"text-sm",children:"Agent skills can execute code on your AnythingLLM instance, so only import agent skills from sources you trust. You should also review the code before importing. If you are unsure about what a skill does - don't import it!"})]})}),e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Review Agent Skill "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]}),e.jsxs("div",{className:"flex gap-x-1",children:[t.verified?e.jsx("p",{className:"text-green-500 text-xs font-mono",children:"Verified code"}):e.jsx("p",{className:"text-red-500 text-xs font-mono",children:"This skill is not verified."}),e.jsx("a",{href:"https://docs.anythingllm.com/community-hub/faq#verification",target:"_blank",className:"text-xs font-mono text-blue-500 hover:underline",rel:"noreferrer",children:"Learn more →"})]})]}),e.jsx("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:e.jsxs("p",{children:["Agent skills unlock new capabilities for your AnythingLLM workspace via"," ",e.jsx("code",{className:"font-mono bg-zinc-900 light:bg-slate-200 px-1 py-0.5 rounded-md text-sm",children:"@agent"})," ","skills that can do specific tasks when invoked."]})}),e.jsx(W,{item:t}),e.jsxs(h,{disabled:n,className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:i,children:[n?e.jsx(v,{size:16,className:"animate-spin"}):null,n?"Importing...":"Import agent skill"]})]})}function W({item:t}){const l=t.manifest.files||[],[s,n]=c.useState(0),[a,i]=c.useState(l[s]);function r(){s>0&&n(s-1)}function o(){s<l.length-1&&n(s+1)}function m(u){switch(u.name.split(".").pop()){case"js":return"javascript";case"json":return"json";case"md":return"markdown";default:return"text"}}return c.useEffect(()=>{l.length>0&&i((l==null?void 0:l[s])||l[0])},[s]),a?e.jsx("div",{className:"flex flex-col gap-y-2",children:e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("button",{type:"button",className:`border-none bg-black/70 light:bg-slate-200 rounded-md p-1 text-white/60 light:text-theme-text-secondary text-xs font-mono ${s===0?"opacity-50 cursor-not-allowed":""}`,onClick:r,children:e.jsx(S,{size:16})}),e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:[a.name," (",s+1," of ",l.length," files)"]}),e.jsx("button",{type:"button",className:`border-none bg-black/70 light:bg-slate-200 rounded-md p-1 text-white/60 light:text-theme-text-secondary text-xs font-mono ${s===l.length-1?"opacity-50 cursor-not-allowed":""}`,onClick:o,children:e.jsx(C,{size:16})})]}),e.jsx("span",{className:"whitespace-pre-line flex flex-col gap-y-1 text-sm leading-[20px] max-h-[500px] overflow-y-auto hljs text-theme-text-primary",dangerouslySetInnerHTML:{__html:P.sanitize(H(`\`\`\`${m(a)}
2
2
  ${m(a)==="markdown"?a.content.replace(/```/g,"~~~"):a.content}
3
3
  \`\`\``))}})]})}):null}function R({item:t,setStep:l}){const s=A(t.flow,{steps:[]}),[n,a]=c.useState(!1);async function i(){try{a(!0);const{success:r,error:o,flow:m}=await b.saveFlow(t.name,s);if(!r)throw new Error(o);m!=null&&m.uuid&&await b.toggleFlow(m.uuid,!0),d("Agent flow imported successfully!","success"),l(x.completed.key)}catch(r){console.error(r),d(`Failed to import agent flow. ${r.message}`,"error")}finally{a(!1)}}return e.jsxs("div",{className:"flex flex-col mt-4 gap-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsxs("h2",{className:"text-base text-theme-text-primary font-semibold",children:['Import Agent Flow "',t.name,'"']}),t.creatorUsername&&e.jsxs("p",{className:"text-white/60 light:text-theme-text-secondary text-xs font-mono",children:["Created by"," ",e.jsxs("a",{href:p.communityHub.profile(t.creatorUsername),target:"_blank",className:"hover:text-blue-500 hover:underline",rel:"noreferrer",children:["@",t.creatorUsername]})]})]}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-white/80 light:text-theme-text-secondary text-sm",children:[e.jsx("p",{children:"Agent flows allow you to create reusable sequences of actions that can be triggered by your agent."}),e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("p",{className:"font-semibold",children:"Flow Details:"}),e.jsxs("p",{children:["Description: ",t.description]}),e.jsxs("p",{className:"font-semibold",children:["Steps (",s.steps.length,"):"]}),e.jsx("ul",{className:"list-disc pl-6",children:s.steps.map((r,o)=>e.jsx("li",{children:r.type},o))})]})]}),e.jsxs(h,{disabled:n,className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:i,children:[n?e.jsx(v,{size:16,className:"animate-spin"}):null,n?"Importing...":"Import agent flow"]})]})}const j={"agent-skill":D,"system-prompt":E,"slash-command":M,"agent-flow":R,unknown:$};function _({importId:t,updateSettings:l}){const[s,n]=c.useState(null),[a,i]=c.useState(!1),[r,o]=c.useState(null);return c.useEffect(()=>{async function m(){if(!t)return;i(!0),await new Promise(g=>setTimeout(g,2e3));const{error:u,item:y}=await f.getItemFromImportId(t);u&&o(u),n(y),l(g=>({...g,item:y})),i(!1)}m()},[t]),{item:s,loading:a,error:r}}function O({settings:t,setSettings:l,setStep:s}){const{item:n,loading:a,error:i}=_({importId:t.itemId,updateSettings:l}),r=j[n==null?void 0:n.itemType]||j.unknown;return e.jsx("div",{className:"flex-[2] flex flex-col gap-y-[18px] mt-10",children:e.jsx("div",{className:"bg-theme-bg-secondary rounded-xl flex-1 p-6",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-2 max-w-[700px]",children:[e.jsx("h2",{className:"text-base text-theme-text-primary font-semibold",children:"Review item"}),a&&e.jsx("div",{className:"flex h-[200px] w-full rounded-lg animate-pulse",children:e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-theme-text-secondary",children:"Pulling item details from community hub..."})})}),!a&&i&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-y-2 mt-8",children:[e.jsx("p",{className:"text-red-500",children:"An error occurred while fetching the item. Please try again later."}),e.jsx("p",{className:"text-red-500/80 text-sm font-mono",children:i})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:()=>{l({itemId:null,item:null}),s(x.itemId.key)},children:"Try another item"})]}),!a&&!i&&n&&e.jsx(r,{item:n,settings:t,setSettings:l,setStep:s})]})})})}function q({settings:t,setSettings:l,setStep:s}){return e.jsx("div",{className:"flex-[2] flex flex-col gap-y-[18px] mt-10",children:e.jsx("div",{className:"bg-theme-bg-secondary rounded-xl flex-1 p-6",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-2 max-w-[700px]",children:[e.jsx("h2",{className:"text-base text-theme-text-primary font-semibold",children:"Community Hub Item Imported"}),e.jsxs("div",{className:"flex flex-col gap-y-[25px] text-theme-text-secondary text-sm",children:[e.jsxs("p",{children:['The "',t.item.name,'" ',t.item.itemType," has been imported successfully! It is now available in your AnythingLLM instance."]}),t.item.itemType==="agent-flow"&&e.jsxs(L,{to:p.settings.agentSkills(),className:"text-theme-text-primary hover:text-blue-500 hover:underline",children:['View "',t.item.name,'" in Agent Skills']}),e.jsxs("p",{children:["Any changes you make to this ",t.item.itemType," will not be reflected in the community hub. You can now modify as needed."]})]}),e.jsx(h,{className:"text-dark-text w-full mt-[18px] h-[34px] hover:bg-accent",onClick:()=>{l({item:null,itemId:null}),s(x.itemId.key)},children:"Import another item"})]})})})}const k={itemId:{key:"itemId",name:"1. Paste in Item ID",next:()=>"validation",component:({settings:t,setSettings:l,setStep:s})=>e.jsx(z,{settings:t,setSettings:l,setStep:s})},validation:{key:"validation",name:"2. Review item",next:()=>"completed",component:({settings:t,setSettings:l,setStep:s})=>e.jsx(O,{settings:t,setSettings:l,setStep:s})},completed:{key:"completed",name:"3. Completed",component:({settings:t,setSettings:l,setStep:s})=>e.jsx(q,{settings:t,setSettings:l,setStep:s})}};function B({setStep:t,children:l}){const s=T(),[n,a]=c.useState({itemId:null,item:null});return c.useEffect(()=>{function i(){s.get("id")&&(a({itemId:s.get("id")}),t(k.itemId.next()))}i()},[]),e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(F,{}),e.jsx("div",{style:{height:N?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] w-full h-full overflow-y-scroll p-4 md:p-0",children:l(n,a,t)})]})}const x=k;function G({setStep:t,currentStep:l}){const s=Object.keys(x).indexOf(l);return e.jsx("div",{className:`bg-white/5 light:bg-white text-theme-text-primary rounded-xl py-1 px-4 shadow-lg ${N?"w-full":"min-w-[360px] w-fit"}`,children:Object.entries(x).map(([n,a],i)=>{const r=l===n,o=i===Object.keys(x).length-1,m=s===Object.keys(x).length-1||i<s;return e.jsxs("div",{className:["py-3 flex items-center justify-between transition-all duration-300",r?"rounded-t-xl":"",o?"":"border-b border-white/10 light:border-[#026AA2]/10"].join(" "),children:[m||r?e.jsx("button",{onClick:()=>t(n),className:"border-none hover:underline text-sm font-medium text-theme-text-primary",children:a.name}):e.jsx("div",{className:"text-sm text-theme-text-secondary font-medium",children:a.name}),e.jsx("div",{className:"flex items-center gap-x-2",children:m?e.jsx("div",{className:"w-[14px] h-[14px] rounded-full border border-[#32D583] flex items-center justify-center",children:e.jsx("div",{className:"w-[5.6px] h-[5.6px] rounded-full bg-[#6CE9A6]"})}):e.jsx("div",{className:`w-[14px] h-[14px] rounded-full border border-theme-text-primary ${r?"animate-pulse":"opacity-50"}`})})]},n)})})}function we(){const[t,l]=c.useState("itemId"),s=x.hasOwnProperty(t)?x[t]:x.itemId;return e.jsx(B,{setStep:l,children:(n,a,i)=>e.jsxs("div",{className:"flex flex-col w-full px-1 md:px-6 2xl:pr-[86px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10",children:[e.jsx("div",{className:"items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:"Import a Community Item"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary",children:"Import items from the AnythingLLM Community Hub to enhance your instance with community-created prompts, skills, and commands."})]}),e.jsxs("div",{className:"flex-1 flex flex-col 2xl:flex-row h-full",children:[e.jsx("div",{className:"flex flex-col gap-y-[18px] mt-10 w-full 2xl:w-[360px] 2xl:flex-shrink-0",children:e.jsx(G,{setStep:i,currentStep:t})}),e.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto pb-[200px] 2xl:h-screen no-scroll",children:e.jsx("div",{className:"2xl:ml-8",children:s.component({settings:n,setSettings:a,setStep:i})})})]})]})})}export{we as default};