totem-llm 0.4.0 → 0.5.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/README.md CHANGED
@@ -1,113 +1,124 @@
1
- # Totem LLM - Your Private AI
1
+ <div align="center">
2
2
 
3
- Totem LLM is a sovereign AI solution, aimed at optimizing for consumer hardware and ensuring data privacy. It is designed to run efficiently on consumer-grade hardware, such as laptops and desktops, without the need for cloud-based processing. This allows users to have full control over their data and AI interactions, without relying on third-party services.
3
+ # Totem LLM
4
4
 
5
- While local AI is the core focus, Totem LLM supports both local and cloud-based LLM providers, giving users the flexibility to choose based on their needs and preferences. The system is built with a modular architecture, allowing for easy integration of new features and providers over time.
5
+ <p align="center">
6
+ <img src="images/totem_logo.png" alt="Description of image" width="100">
7
+ </p>
6
8
 
7
- ## Install Quick Start Package
8
9
 
9
- ### Prerequisites
10
+ ### Your Mind Leads
10
11
 
11
- - [Node.js](https://nodejs.org/) v18 or later
12
- - [Ollama](https://ollama.com/) (recommended) or an [OpenRouter](https://openrouter.ai/) API key
12
+ [![Node.js](https://img.shields.io/badge/Node.js-v18+-green?logo=node.js&logoColor=white)](https://nodejs.org/)
13
+ [![License](https://img.shields.io/badge/License-MIT-blue)](LICENSE)
14
+ [![Platform](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-lightgrey)](https://github.com/fred-terzi/totem-llm)
13
15
 
14
- ### 1. Install the package
15
16
 
16
- Search for `terminal` in your applications and open it. Then run:
17
+ **A sovereign AI solution for consumer hardware. Keep your data private, run locally, stay in control.**
17
18
 
18
- ```bash
19
- npm install -g totem-llm
20
- ```
19
+ </div>
21
20
 
22
- This downloads Totem LLM and installs all server and collector dependencies automatically.
21
+ ---
23
22
 
24
- ### 2. Start Totem LLM
23
+ ## 🚀 Key Features
25
24
 
26
- ```bash
27
- totem-llm start
28
- ```
25
+ | Feature | Description |
26
+ |---------|-------------|
27
+ | **Privacy First** | All data stays on your machine. |
28
+ | **Consumer Hardware** | Optimized for consumer-grade devices. |
29
+ | **Local & Cloud** | Choose local models via Ollama or use cloud providers (OpenRouter). |
30
+ | **Easy Setup** | One-line install with automatic dependency resolution. |
29
31
 
30
- On first run this performs one-time setup (creates `~/totem-llm/`, migrates the database) then launches the server and document collector. Open [http://localhost:8686](http://localhost:8686) to access the UI.
32
+ ---
31
33
 
32
- ### 3. Install to Desktop (optional)
34
+ ## 📋 About
33
35
 
34
- In the browser, click the install icon in the address bar (or use the browser menu) to install Totem LLM as a desktop application. This creates a standalone app with its own window and taskbar/dock icon.
36
+ Totem LLM is a sovereign AI solution, aimed at optimizing for consumer hardware and ensuring data privacy. It is designed to run efficiently on consumer-grade hardware, such as laptops and desktops, without the need for cloud-based processing. This allows users to have full control over their data and AI interactions, without relying on third-party services.
35
37
 
36
- ### Options
38
+ While local AI is the core focus, Totem LLM supports both local and cloud-based LLM providers, giving users the flexibility to choose based on their needs and preferences. The system is built with a modular architecture, allowing for easy integration of new features and providers over time.
37
39
 
38
- ```
39
- totem-llm --no-collector Start without the document collector
40
- totem-llm --port=8080 Override the server port (default: 8686)
41
- totem-llm setup Run first-time setup without starting
42
- totem-llm --help Show all options
43
- ```
40
+ ## ⚙️ Requirements
44
41
 
45
- > **Storage**: All data is kept in `~/totem-llm/` by default. Override with `TOTEM_STORAGE_DIR=/your/path totem-llm start`.
42
+ Before installing Totem LLM, first install the below prerequisites:
46
43
 
47
- ### Troubleshooting
44
+ - **[Node.js](https://nodejs.org/)** v18 or later
45
+ - **[Ollama](https://ollama.com/)** (recommended for local models) *OR*
46
+ - **[OpenRouter](https://openrouter.ai/)** API key (for cloud models)
48
47
 
49
- **npm not found after node.js install**:
48
+ ---
50
49
 
51
- Common on windows, you may need to run `npm.cmd` instead of just `npm`
50
+ ## 🎯 Quick Start
52
51
 
53
- **totem-llm command not found after install**:
52
+ ### 1️⃣ Install the Package
54
53
 
55
- Run `npx.cmd totem-llm start` instead of `totem-llm start`, or add the npm global bin directory to your PATH.
54
+ Open your terminal and run:
56
55
 
57
- > **Windows (PowerShell)**: If you see `cannot be loaded because running scripts is disabled`, run this once in PowerShell then retry:
58
- > ```powershell
59
- > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
60
- > ```
61
- > Alternatively, use **Command Prompt** (`cmd.exe`) where `totem-llm.cmd` runs without any policy change.
56
+ ```bash
57
+ npm install -g totem-llm
58
+ ```
62
59
 
63
- ---
60
+ This automatically downloads Totem LLM and installs all dependencies (server, collector, frontend).
61
+
62
+ ### 2️⃣ Start Totem LLM
64
63
 
65
- ## Quick Start (Build from Source)
64
+ ```bash
65
+ totem-llm start
66
+ ```
66
67
 
67
- ### Prerequisites
68
+ **First run:** Creates `~/totem-llm/` directory, migrates database, then launches services.
68
69
 
69
- - [Node.js](https://nodejs.org/) v18 or later
70
- - [Yarn](https://yarnpkg.com/) v1.x (`npm install -g yarn`)
71
- - [Ollama](https://ollama.com/) (recommended local LLM provider) or an [OpenRouter](https://openrouter.ai/) API key
72
- - Linux build machine - current build relies on `cp` command with `--reflink` option for efficient file copying. Building on non-Linux platforms may require additional setup (e.g. WSL on Windows).
70
+ **Access:** Open [http://localhost:8686](http://localhost:8686) in your browser.
71
+
72
+ ### 3️⃣ Optional: Install as Desktop App
73
+
74
+ In the browser UI, click the **install icon** in the address bar (or use your browser menu) to add Totem LLM to your desktop. This is a link to the web GUI, but with its own window and taskbar/dock icon for easy access.
75
+
76
+ ---
73
77
 
74
- ### 1. Clone the repository
78
+ ## 📚 Command Reference
75
79
 
76
80
  ```bash
77
- git clone https://github.com/fred-terzi/totem-llm.git
78
- cd totem-llm
81
+ totem-llm start # Start server and collector
82
+ totem-llm --no-collector # Start server only (skip document ingestion)
83
+ totem-llm --port=8080 # Use custom server port
84
+ totem-llm setup # Run first-time setup without starting
85
+ totem-llm --help # Show all available commands
79
86
  ```
80
87
 
81
- ### 2. Install dependencies and initialise the database
88
+ ### Environment Variables
82
89
 
83
90
  ```bash
84
- yarn setup
91
+ # Override default storage location (default: ~/totem-llm)
92
+ export TOTEM_STORAGE_DIR=/your/custom/path
93
+ totem-llm start
85
94
  ```
86
95
 
87
- This installs dependencies for all three packages (`server`, `collector`, `frontend`), copies the example `.env` files, generates the Prisma client, and runs database migrations.
96
+ ---
88
97
 
89
- ### 3. Configure environment variables
98
+ ## 🛠️ Troubleshooting
90
99
 
91
- Open `server/.env.development` and set at minimum:
100
+ | Issue | Solution |
101
+ |-------|----------|
102
+ | **npm not found** (Windows) | Run `npm.cmd` instead of `npm` |
103
+ | **totem-llm command not found** | Run `npx.cmd totem-llm start` or add npm global bin to PATH |
104
+ | **PowerShell script execution error** | Run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser` once, then retry |
105
+ | **Alternative on Windows** | Use **Command Prompt** (`cmd.exe`) instead of PowerShell |
92
106
 
93
- ```env
94
- STORAGE_DIR="/absolute/path/to/your/storage"
95
- ```
96
107
 
97
- All other settings (LLM provider, embedding model, etc.) can be changed later through the UI.
108
+ ## 🙏 Acknowledgments
98
109
 
99
- ### 4. Start in development mode
110
+ Totem LLM is built on the foundation of **[AnythingLLM](https://github.com/Mintplex-Labs/anything-llm)** by Mintplex Labs. We are deeply grateful for their excellent work.
100
111
 
101
- ```bash
102
- yarn dev:all
103
- ```
112
+ ---
104
113
 
105
- This starts the server (port `8686`), collector (port `8888`), and frontend dev server (port `5173`) concurrently. Open [http://localhost:5173](http://localhost:5173) to access the UI.
114
+ ## 📄 License
106
115
 
107
- > Alternatively, run each service in its own terminal: `yarn dev:server`, `yarn dev:collector`, `yarn dev:frontend`.
116
+ Totem LLM is released under the **MIT License** — see [LICENSE](LICENSE) for details.
108
117
 
109
- ## Thanks
118
+ ## 📞 Support
110
119
 
111
- Massive thank you and appreciation to AnythingLLM. Totem LLM is a fork of AnythingLLM, and we are grateful for the foundation they have provided. We will continue to build on their work and contribute back to the community.
120
+ - 🐛 **Report Issues** → [GitHub Issues](https://github.com/fred-terzi/totem-llm/issues)
121
+ - 💬 **Discussions** → [GitHub Discussions](https://github.com/fred-terzi/totem-llm/discussions)
122
+
123
+ ---
112
124
 
113
- https://github.com/Mintplex-Labs/anything-llm
package/lib/formatter.js CHANGED
@@ -187,10 +187,8 @@ export function startupBanner(version, environment) {
187
187
 
188
188
  return (
189
189
  colorize(banner, "cyan") +
190
- `\n ${colorize("Your Private AI", "brightCyan", "bold")}\n` +
191
- ` ${colorize("v" + version, "dim")}\n` +
192
- (environment ? ` Environment: ${colorize(environment, "yellow")}\n` : "") +
193
- "\n"
190
+ `\n ${colorize("Your Mind Leads", "brightCyan", "bold")}\n` +
191
+ ` ${colorize("v" + version, "dim")}\n`
194
192
  );
195
193
  }
196
194
 
package/lib/launcher.js CHANGED
@@ -17,6 +17,19 @@ import {
17
17
  divider,
18
18
  } from "./formatter.js";
19
19
 
20
+ /**
21
+ * Create a simple progress bar for terminal output.
22
+ * @param {number} percent Progress percentage (0-100)
23
+ * @param {number} width Bar width in characters (default 30)
24
+ * @returns {string} Formatted progress bar
25
+ */
26
+ function createProgressBar(percent, width = 30) {
27
+ const filled = Math.round((width * percent) / 100);
28
+ const empty = width - filled;
29
+ const bar = "█".repeat(filled) + "░".repeat(empty);
30
+ return `[${bar}] ${percent}%`;
31
+ }
32
+
20
33
  /**
21
34
  * Spawn a Node.js service and prefix every log line with a fixed-width label.
22
35
  * Also writes all logs to a session log file.
@@ -91,13 +104,18 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
91
104
  process.stdout.write("\n");
92
105
  process.stdout.write(startupBanner(appVersion, "production"));
93
106
 
94
- // Display service configuration
95
- process.stdout.write(
96
- section("Services", [
97
- `${info("Server")} running on port ${urlStyle(serverPort)}`,
98
- collectorPort ? `${info("Collector")} running on port ${urlStyle(collectorPort)}` : warning("Collector disabled"),
99
- ])
100
- );
107
+ // Display loading progress
108
+ process.stdout.write(section("Starting Services", []));
109
+ let progressPercent = 0;
110
+ const progressInterval = setInterval(() => {
111
+ if (progressPercent < 80) {
112
+ progressPercent += Math.random() * 25;
113
+ if (progressPercent > 80) progressPercent = 80;
114
+ process.stdout.write(
115
+ `\r${info("Loading")} ${createProgressBar(Math.floor(progressPercent))}`
116
+ );
117
+ }
118
+ }, 300);
101
119
 
102
120
  // Display UI access information
103
121
  process.stdout.write(
@@ -132,6 +150,13 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
132
150
  collectorProc = spawnService(nodeExe, collectorDir, env, "[collector]", sessionLogFile);
133
151
  }
134
152
 
153
+ // Complete the progress bar
154
+ progressPercent = 100;
155
+ process.stdout.write(
156
+ `\r${success("Ready")} ${createProgressBar(100)}\n\n`
157
+ );
158
+ clearInterval(progressInterval);
159
+
135
160
  // ── Graceful shutdown ────────────────────────────────────────────────────
136
161
  let shuttingDown = false;
137
162
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "totem-llm",
3
- "version": "0.4.0",
3
+ "version": "0.5.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",
@@ -1 +1 @@
1
- import{d as c,j as s,e as d,f as g,i as f,l as S,r as a,W as i,L as x}from"../index.js";import{W as h}from"./index-45bcde52.js";import{a as w}from"./index-ed14fe75.js";import"./files-40998f84.js";import"./purify-17c89583.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./truncate-dd7b0c29.js";import"./mcpServers-9495fe60.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./File-b92df2f3.js";import"./XCircle-edfe554c.js";import"./Trans-308f36d6.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-14be6ea8.js";import"./agentFlows-e4124dd3.js";import"./index-36acf56a.js";import"./communityHub-aba61686.js";import"./WarningCircle-27467274.js";import"./index-8ba96f42.js";import"./Hammer-05b5ccc7.js";import"./react-beautiful-dnd.esm-149a7a55.js";import"./moment-49fc1b76.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";function Q(){const{loading:t,requiresAuth:r,mode:e}=c();return t?s.jsx(d,{}):r!==!1?s.jsx(s.Fragment,{children:r!==null&&s.jsx(g,{mode:e})}):s.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-zinc-950 light:bg-slate-50 flex",children:[!f&&s.jsx(w,{}),s.jsx(j,{})]})}function j(){const{slug:t}=S(),[r,e]=a.useState(null),[n,m]=a.useState(null);return a.useEffect(()=>{async function p(){if(!t)return;const o=await i.bySlug(t);if(!o){e(null),m(t);return}const[l,{showAgentCommand:u}]=await Promise.all([i.getSuggestedMessages(t),i.agentCommandAvailable(t)]);e({...o,suggestedMessages:l,showAgentCommand:u}),m(t),localStorage.setItem(x,JSON.stringify({slug:o.slug,name:o.name}))}p()},[t]),s.jsx(h,{loading:n!==t,workspace:r})}export{Q as default};
1
+ import{d as c,j as s,e as d,f as g,i as f,l as S,r as a,W as i,L as x}from"../index.js";import{W as h}from"./index-df53cf14.js";import{a as w}from"./index-ed14fe75.js";import"./files-40998f84.js";import"./purify-17c89583.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./truncate-dd7b0c29.js";import"./mcpServers-9495fe60.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./File-b92df2f3.js";import"./XCircle-edfe554c.js";import"./Trans-308f36d6.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-14be6ea8.js";import"./agentFlows-e4124dd3.js";import"./index-36acf56a.js";import"./communityHub-aba61686.js";import"./WarningCircle-27467274.js";import"./index-8ba96f42.js";import"./Hammer-05b5ccc7.js";import"./react-beautiful-dnd.esm-149a7a55.js";import"./moment-49fc1b76.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";function Q(){const{loading:t,requiresAuth:r,mode:e}=c();return t?s.jsx(d,{}):r!==!1?s.jsx(s.Fragment,{children:r!==null&&s.jsx(g,{mode:e})}):s.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-zinc-950 light:bg-slate-50 flex",children:[!f&&s.jsx(w,{}),s.jsx(j,{})]})}function j(){const{slug:t}=S(),[r,e]=a.useState(null),[n,m]=a.useState(null);return a.useEffect(()=>{async function p(){if(!t)return;const o=await i.bySlug(t);if(!o){e(null),m(t);return}const[l,{showAgentCommand:u}]=await Promise.all([i.getSuggestedMessages(t),i.agentCommandAvailable(t)]);e({...o,suggestedMessages:l,showAgentCommand:u}),m(t),localStorage.setItem(x,JSON.stringify({slug:o.slug,name:o.name}))}p()},[t]),s.jsx(h,{loading:n!==t,workspace:r})}export{Q as default};
@@ -1,3 +1,3 @@
1
- import{r as c,j as e,p,C as h,c as d,W as I,af as w,a5 as v,aK as S,aF as C,s as A,v as L,aM as F,a1 as T,i as N}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{r as H}from"./files-40998f84.js";import{p as P}from"./purify-17c89583.js";import{s as M}from"./index-45bcde52.js";import{A as b}from"./agentFlows-e4124dd3.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./index-ed14fe75.js";import"./truncate-dd7b0c29.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-149a7a55.js";import"./mcpServers-9495fe60.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./Trans-308f36d6.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-14be6ea8.js";import"./index-36acf56a.js";import"./WarningCircle-27467274.js";import"./index-8ba96f42.js";import"./Hammer-05b5ccc7.js";function U({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 z({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 E({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(()=>{M()},[]),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,af as w,a5 as v,aK as S,aF as C,s as A,v as L,aM as F,a1 as T,i as N}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{r as H}from"./files-40998f84.js";import{p as P}from"./purify-17c89583.js";import{s as M}from"./index-df53cf14.js";import{A as b}from"./agentFlows-e4124dd3.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./index-ed14fe75.js";import"./truncate-dd7b0c29.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-149a7a55.js";import"./mcpServers-9495fe60.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./Trans-308f36d6.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-14be6ea8.js";import"./index-36acf56a.js";import"./WarningCircle-27467274.js";import"./index-8ba96f42.js";import"./Hammer-05b5ccc7.js";function U({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 z({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 E({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(()=>{M()},[]),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":z,"slash-command":E,"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(U,{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=F(),[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(T,{}),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 V({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(V,{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};