totem-llm 0.3.3 → 0.3.5

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
@@ -27,7 +27,7 @@ This downloads Totem LLM and installs all server and collector dependencies auto
27
27
  totem-llm start
28
28
  ```
29
29
 
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:3001](http://localhost:3001) to access the UI.
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.
31
31
 
32
32
  ### 3. Install to Desktop (optional)
33
33
 
@@ -37,7 +37,7 @@ In the browser, click the install icon in the address bar (or use the browser me
37
37
 
38
38
  ```
39
39
  totem-llm --no-collector Start without the document collector
40
- totem-llm --port=8080 Override the server port (default: 3001)
40
+ totem-llm --port=8080 Override the server port (default: 8686)
41
41
  totem-llm setup Run first-time setup without starting
42
42
  totem-llm --help Show all options
43
43
  ```
@@ -102,7 +102,7 @@ All other settings (LLM provider, embedding model, etc.) can be changed later th
102
102
  yarn dev:all
103
103
  ```
104
104
 
105
- This starts the server (port `3001`), collector (port `8888`), and frontend dev server (port `5173`) concurrently. Open [http://localhost:5173](http://localhost:5173) to access the UI.
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.
106
106
 
107
107
  > Alternatively, run each service in its own terminal: `yarn dev:server`, `yarn dev:collector`, `yarn dev:frontend`.
108
108
 
package/bin/totem-llm.js CHANGED
@@ -75,7 +75,7 @@ Commands:
75
75
 
76
76
  Options:
77
77
  --no-collector Start without the document collector (skips Puppeteer/ffmpeg)
78
- --port=<port> Override the server port (default: 3001)
78
+ --port=<port> Override the server port (default: 8686)
79
79
  --version, -v Print Totem LLM version and exit
80
80
  --force (setup only) Regenerate configuration even if it already exists
81
81
 
package/lib/launcher.js CHANGED
@@ -1,18 +1,21 @@
1
1
  import { spawn } from "child_process";
2
2
  import { join } from "path";
3
+ import { appendFileSync, mkdirSync, writeFileSync } from "fs";
3
4
  import { getEnv } from "./config.js";
4
5
  import { getPackageVersion } from "./version.js";
5
6
 
6
7
  /**
7
8
  * Spawn a Node.js service and prefix every log line with a fixed-width label.
9
+ * Also writes all logs to a session log file.
8
10
  *
9
11
  * @param {string} nodeExe Absolute path to the Node binary (process.execPath)
10
12
  * @param {string} cwd Working directory for the child process
11
13
  * @param {object} env Environment variables to pass to the child
12
14
  * @param {string} label Log prefix, e.g. "[server] "
15
+ * @param {string} logFile Path to the session log file
13
16
  * @returns {{ process: import('child_process').ChildProcess }}
14
17
  */
15
- function spawnService(nodeExe, cwd, env, label) {
18
+ function spawnService(nodeExe, cwd, env, label, logFile) {
16
19
  const child = spawn(nodeExe, ["index.js"], {
17
20
  cwd,
18
21
  env,
@@ -22,17 +25,19 @@ function spawnService(nodeExe, cwd, env, label) {
22
25
  const pad = label.padEnd(13);
23
26
  let buf = "";
24
27
 
25
- function flush(stream, chunk) {
28
+ function flush(chunk) {
26
29
  buf += chunk.toString();
27
30
  const lines = buf.split("\n");
28
31
  buf = lines.pop(); // keep any incomplete trailing line
29
32
  for (const line of lines) {
30
- if (line.trim()) stream.write(`${pad} ${line}\n`);
33
+ if (line.trim()) {
34
+ appendFileSync(logFile, `${pad} ${line}\n`);
35
+ }
31
36
  }
32
37
  }
33
38
 
34
- child.stdout.on("data", (c) => flush(process.stdout, c));
35
- child.stderr.on("data", (c) => flush(process.stderr, c));
39
+ child.stdout.on("data", (c) => flush(c));
40
+ child.stderr.on("data", (c) => flush(c));
36
41
 
37
42
  return child;
38
43
  }
@@ -52,27 +57,43 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
52
57
  appVersion = getPackageVersion(packageRoot) ?? "unknown";
53
58
  } catch {}
54
59
 
55
- const serverPort = env.SERVER_PORT ?? "3001";
60
+ const serverPort = env.SERVER_PORT ?? "8686";
56
61
  const collectorPort = env.COLLECTOR_PORT ?? "8888";
57
62
  const nodeExe = process.execPath; // cross-platform: always the right Node binary
58
63
 
59
64
  const serverDir = join(packageRoot, "server");
60
65
  const collectorDir = join(packageRoot, "collector");
61
66
 
62
- console.log("Starting Totem LLM…");
63
- console.log(` Version → ${appVersion}`);
64
- console.log(` Server → http://localhost:${serverPort}`);
65
- if (!noCollector) {
66
- console.log(` Collector → http://localhost:${collectorPort}`);
67
- }
68
- console.log(` Storage → ${env.STORAGE_DIR}`);
69
- console.log("\nPress Ctrl+C to stop.\n");
70
-
71
- const serverProc = spawnService(nodeExe, serverDir, env, "[server]");
67
+ // Initialize session log file - clear on each startup
68
+ const logsDir = join(packageRoot, "logs");
69
+ mkdirSync(logsDir, { recursive: true });
70
+ const sessionLogFile = join(logsDir, "totem-session.log");
71
+ writeFileSync(sessionLogFile, `${"=".repeat(80)}\nSession started: ${new Date().toISOString()}\n${"=".repeat(80)}\n`);
72
+
73
+ process.stdout.write(`
74
+ ████████╗ ██████╗ ████████╗███████╗███╗ ███╗ ██╗ ██╗ ███╗ ███╗
75
+ ╚══██╔══╝██╔═══██╗╚══██╔══╝██╔════╝████╗ ████║ ██║ ██║ ████╗ ████║
76
+ ██║ ██║ ██║ ██║ █████╗ ██╔████╔██║ ██║ ██║ ██╔████╔██║
77
+ ██║ ██║ ██║ ██║ ██╔══╝ ██║╚██╔╝██║ ██║ ██║ ██║╚██╔╝██║
78
+ ██║ ╚██████╔╝ ██║ ███████╗██║ ╚═╝ ██║ ███████╗███████╗██║ ╚═╝ ██║
79
+ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚══════╝╚══════╝╚═╝ ╚═╝
80
+
81
+ Your Private AI
82
+
83
+
84
+ Starting Totem LLM…\n
85
+ ============================================================================\n
86
+ Logs → ${sessionLogFile}\n
87
+ LAUNCH UI HERE (ctrl + click)--> http://localhost:${serverPort}/\n
88
+
89
+ Press Ctrl+C to stop.\n
90
+ `);
91
+
92
+ const serverProc = spawnService(nodeExe, serverDir, env, "[server]", sessionLogFile);
72
93
 
73
94
  let collectorProc = null;
74
95
  if (!noCollector) {
75
- collectorProc = spawnService(nodeExe, collectorDir, env, "[collector]");
96
+ collectorProc = spawnService(nodeExe, collectorDir, env, "[collector]", sessionLogFile);
76
97
  }
77
98
 
78
99
  // ── Graceful shutdown ────────────────────────────────────────────────────
@@ -82,7 +103,10 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
82
103
  if (shuttingDown) return;
83
104
  shuttingDown = true;
84
105
 
85
- console.log(`\nShutting down (${signal})…`);
106
+ const shutdownMsg = `\nShutting down (${signal})…`;
107
+ process.stdout.write(`${shutdownMsg}\n`);
108
+ appendFileSync(sessionLogFile, `${shutdownMsg}\n`);
109
+
86
110
  serverProc.kill("SIGTERM");
87
111
  if (collectorProc) collectorProc.kill("SIGTERM");
88
112
 
@@ -102,7 +126,9 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
102
126
  // Exit this process when the server exits unexpectedly
103
127
  serverProc.on("close", (code) => {
104
128
  if (!shuttingDown && code !== null && code !== 0) {
105
- console.error(`[server] exited unexpectedly with code ${code}`);
129
+ const errMsg = `[server] exited unexpectedly with code ${code}`;
130
+ process.stderr.write(`${errMsg}\n`);
131
+ appendFileSync(sessionLogFile, `${errMsg}\n`);
106
132
  shutdown("server-exit");
107
133
  setTimeout(() => process.exit(1), 500);
108
134
  }
@@ -111,9 +137,9 @@ export async function launch({ packageRoot, noCollector = false, port } = {}) {
111
137
  if (collectorProc) {
112
138
  collectorProc.on("close", (code) => {
113
139
  if (!shuttingDown && code !== null && code !== 0) {
114
- console.error(
115
- `[collector] exited with code ${code} — document ingestion unavailable`
116
- );
140
+ const errMsg = `[collector] exited with code ${code} — document ingestion unavailable`;
141
+ process.stderr.write(`${errMsg}\n`);
142
+ appendFileSync(sessionLogFile, `${errMsg}\n`);
117
143
  }
118
144
  });
119
145
  }
package/lib/setup.js CHANGED
@@ -28,7 +28,7 @@ function buildEnvFile(storageDir) {
28
28
  "# Edit this file to configure your instance, then restart.",
29
29
  "",
30
30
  `STORAGE_DIR="${storageDir}"`,
31
- "SERVER_PORT=3001",
31
+ "SERVER_PORT=8686",
32
32
  "COLLECTOR_PORT=8888",
33
33
  "",
34
34
  "# Security secrets (auto-generated — do not share these)",
@@ -143,7 +143,6 @@ export async function setup({ packageRoot, force = false }) {
143
143
  const featuresConfigSrc = join(__dirname, '..', 'config', 'totem.features.json');
144
144
  if (!existsSync(featuresConfigDest) && existsSync(featuresConfigSrc)) {
145
145
  copyFileSync(featuresConfigSrc, featuresConfigDest);
146
- console.log(` Feature flags config saved to: ${featuresConfigDest}`);
147
146
  } else if (existsSync(featuresConfigDest)) {
148
147
  console.log(` Feature flags config found: ${featuresConfigDest}`);
149
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "totem-llm",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
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",
package/server/.env CHANGED
@@ -1,4 +1,4 @@
1
- SERVER_PORT=3001
1
+ SERVER_PORT=8686
2
2
  DATABASE_URL="file:../storage/anythingllm.db"
3
3
  JWT_SECRET="my-random-string-for-seeding" # Please generate random string at least 12 chars long.
4
4
  # JWT_EXPIRY="30d" # (optional) https://docs.anythingllm.com/configuration#custom-ttl-for-sessions
package/server/index.js CHANGED
@@ -82,7 +82,7 @@ app.use(
82
82
  );
83
83
 
84
84
  if (!!process.env.ENABLE_HTTPS) {
85
- bootSSL(app, process.env.SERVER_PORT || 3001);
85
+ bootSSL(app, process.env.SERVER_PORT || 8686);
86
86
  } else {
87
87
  require("@mintplex-labs/express-ws").default(app); // load WebSockets in non-SSL mode.
88
88
  }
@@ -187,4 +187,4 @@ app.all("*", function (_, response) {
187
187
 
188
188
  // In non-https mode we need to boot at the end since the server has not yet
189
189
  // started and is `.listen`ing.
190
- if (!process.env.ENABLE_HTTPS) bootHTTP(app, process.env.SERVER_PORT || 3001);
190
+ if (!process.env.ENABLE_HTTPS) bootHTTP(app, process.env.SERVER_PORT || 8686);
@@ -100,7 +100,7 @@ const MobileDevice = {
100
100
  let baseUrl = "/api/mobile";
101
101
  if (process.env.NODE_ENV === "production") baseUrl = "/api/mobile";
102
102
  else
103
- baseUrl = `http://${ip.address()}:${process.env.SERVER_PORT || 3001}/api/mobile`;
103
+ baseUrl = `http://${ip.address()}:${process.env.SERVER_PORT || 8686}/api/mobile`;
104
104
 
105
105
  const tempToken = this.registerTempToken(user);
106
106
  baseUrl = `${baseUrl}?t=${tempToken}`;
@@ -36,7 +36,7 @@ function mergeStringField(target, source, fieldName, validator = null) {
36
36
  const SystemSettings = {
37
37
  /** A default system prompt that is used when no other system prompt is set or available to the function caller. */
38
38
  saneDefaultSystemPrompt:
39
- "You are Totem LLM. You are an AI that prioritizes consistent behavior with your history.",
39
+ "You are Totem LLM. You are an AI that prioritizes consistent behavior with your history. The current date and time is {datetime}.",
40
40
  protectedFields: ["multi_user_mode", "hub_api_key", "onboarding_complete"],
41
41
  publicFields: [
42
42
  "footer_data",
@@ -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-9a279a2e.js";import{a as w}from"./index-6bd7928a.js";import"./files-676613ed.js";import"./purify-eb750cf4.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./truncate-06273256.js";import"./mcpServers-1686e782.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./File-b92df2f3.js";import"./XCircle-edfe554c.js";import"./Trans-820f1dad.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-dcc00e8c.js";import"./agentFlows-e4124dd3.js";import"./index-3cb59d82.js";import"./communityHub-aba61686.js";import"./WarningCircle-27467274.js";import"./index-8ba96f42.js";import"./Hammer-05b5ccc7.js";import"./react-beautiful-dnd.esm-bb85eef1.js";import"./moment-75486807.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-e035f9fa.js";import{a as w}from"./index-6bd7928a.js";import"./files-676613ed.js";import"./purify-eb750cf4.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./truncate-06273256.js";import"./mcpServers-1686e782.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./File-b92df2f3.js";import"./XCircle-edfe554c.js";import"./Trans-820f1dad.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-671239cd.js";import"./agentFlows-e4124dd3.js";import"./index-3cb59d82.js";import"./communityHub-aba61686.js";import"./WarningCircle-27467274.js";import"./index-8ba96f42.js";import"./Hammer-05b5ccc7.js";import"./react-beautiful-dnd.esm-bb85eef1.js";import"./moment-75486807.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,ae as w,a4 as v,aJ as S,aE as C,s as A,v as L,aL as T,a1 as F,i as N}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{r as H}from"./files-676613ed.js";import{p as P}from"./purify-eb750cf4.js";import{s as E}from"./index-9a279a2e.js";import{A as b}from"./agentFlows-e4124dd3.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./index-6bd7928a.js";import"./truncate-06273256.js";import"./XCircle-edfe554c.js";import"./moment-75486807.js";import"./File-b92df2f3.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";import"./react-beautiful-dnd.esm-bb85eef1.js";import"./mcpServers-1686e782.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./Trans-820f1dad.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-dcc00e8c.js";import"./index-3cb59d82.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 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(()=>{E()},[]),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,ae as w,a4 as v,aJ as S,aE as C,s as A,v as L,aL as T,a1 as F,i as N}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{r as H}from"./files-676613ed.js";import{p as P}from"./purify-eb750cf4.js";import{s as E}from"./index-e035f9fa.js";import{A as b}from"./agentFlows-e4124dd3.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./index-6bd7928a.js";import"./truncate-06273256.js";import"./XCircle-edfe554c.js";import"./moment-75486807.js";import"./File-b92df2f3.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";import"./react-beautiful-dnd.esm-bb85eef1.js";import"./mcpServers-1686e782.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./Trans-820f1dad.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-671239cd.js";import"./index-3cb59d82.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 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(()=>{E()},[]),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":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(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=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 J({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(J,{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};