totem-llm 0.15.0 → 0.15.1
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/lib/setup.js +1 -0
- package/package.json +1 -1
- package/server/endpoints/importChatgpt.js +68 -0
- package/server/index.js +3 -1
- package/server/prisma/migrations/20260825181511_add_import_fields/migration.sql +5 -0
- package/server/prisma/schema.prisma +2 -0
- package/server/public/assets/{index-b7caf9b8.js → index-5762e495.js} +1 -1
- package/server/public/assets/index-7ca9b2d0.js +1 -0
- package/server/public/assets/{index-05fbc3ea.js → index-beeec877.js} +1 -1
- package/server/public/assets/{index-648278d2.js → index-ca517fb2.js} +1 -1
- package/server/public/index.css +1 -1
- package/server/public/index.js +31 -31
- package/server/utils/chatgptImport/index.js +206 -0
- package/server/utils/chatgptImport/parser.js +167 -0
- package/server/utils/chatgptImport/validator.js +122 -0
package/lib/setup.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const { validatedRequest } = require("../utils/middleware/validatedRequest");
|
|
2
|
+
const { flexUserRoleValid, ROLES } = require("../utils/middleware/multiUserProtected");
|
|
3
|
+
const { userFromSession, reqBody } = require("../utils/http");
|
|
4
|
+
const { importChatgptExport, getImportPreview } = require("../utils/chatgptImport");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
|
|
7
|
+
function defaultImportDir() {
|
|
8
|
+
return path.join(process.env.STORAGE_DIR || path.join(require("os").homedir(), "totem-llm"), "chatgpt-import");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function importChatgptEndpoints(app) {
|
|
12
|
+
if (!app) return;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* GET /api/import/chatgpt/preview
|
|
16
|
+
* Returns metadata about the export at the given directory path.
|
|
17
|
+
*/
|
|
18
|
+
app.get(
|
|
19
|
+
"/import/chatgpt/preview",
|
|
20
|
+
[validatedRequest, flexUserRoleValid([ROLES.all])],
|
|
21
|
+
async (request, response) => {
|
|
22
|
+
try {
|
|
23
|
+
const dirPath = request.query.dirPath || defaultImportDir();
|
|
24
|
+
|
|
25
|
+
const result = await getImportPreview(dirPath);
|
|
26
|
+
if (!result.success) {
|
|
27
|
+
return response.status(400).json({ ...result, dir: defaultImportDir() });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
response.status(200).json({ ...result, dir: defaultImportDir() });
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.error(e.message, e);
|
|
33
|
+
response.sendStatus(500).end();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* POST /api/import/chatgpt
|
|
40
|
+
* Imports a ChatGPT export from the given directory path.
|
|
41
|
+
* Body: { dirPath: string, workspaceName?: string }
|
|
42
|
+
*/
|
|
43
|
+
app.post(
|
|
44
|
+
"/import/chatgpt",
|
|
45
|
+
[validatedRequest, flexUserRoleValid([ROLES.all])],
|
|
46
|
+
async (request, response) => {
|
|
47
|
+
try {
|
|
48
|
+
const user = await userFromSession(request, response);
|
|
49
|
+
const body = reqBody(request);
|
|
50
|
+
|
|
51
|
+
const dirPath = body.dirPath || defaultImportDir();
|
|
52
|
+
|
|
53
|
+
const result = await importChatgptExport(dirPath, user?.id || null);
|
|
54
|
+
|
|
55
|
+
if (!result.success) {
|
|
56
|
+
return response.status(400).json(result);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
response.status(200).json({ success: true, summary: result.summary });
|
|
60
|
+
} catch (e) {
|
|
61
|
+
console.error(e.message, e);
|
|
62
|
+
response.sendStatus(500).end();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = { importChatgptEndpoints };
|
package/server/index.js
CHANGED
|
@@ -9,7 +9,7 @@ if (!process.env.STORAGE_DIR) {
|
|
|
9
9
|
process.env.STORAGE_DIR = path.join(os.homedir(), "totem-llm");
|
|
10
10
|
}
|
|
11
11
|
// Ensure all required storage subdirectories exist
|
|
12
|
-
for (const sub of ["documents", "vector-cache", "models", "direct-uploads", "generated-files", "comkey", "tmp", "assets"]) {
|
|
12
|
+
for (const sub of ["documents", "vector-cache", "models", "direct-uploads", "generated-files", "comkey", "tmp", "assets", "chatgpt-import"]) {
|
|
13
13
|
mkdirSync(path.join(process.env.STORAGE_DIR, sub), { recursive: true });
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -55,6 +55,7 @@ const {
|
|
|
55
55
|
} = require("./endpoints/utils/googleAgentSkillEndpoints");
|
|
56
56
|
const { memoryEndpoints } = require("./endpoints/memory");
|
|
57
57
|
const { featureEndpoints } = require("./endpoints/features");
|
|
58
|
+
const { importChatgptEndpoints } = require("./endpoints/importChatgpt");
|
|
58
59
|
const { httpLogger } = require("./middleware/httpLogger");
|
|
59
60
|
const app = express();
|
|
60
61
|
const apiRouter = express.Router();
|
|
@@ -115,6 +116,7 @@ outlookAgentEndpoints(apiRouter);
|
|
|
115
116
|
googleAgentSkillEndpoints(apiRouter);
|
|
116
117
|
memoryEndpoints(apiRouter);
|
|
117
118
|
featureEndpoints(apiRouter);
|
|
119
|
+
importChatgptEndpoints(apiRouter);
|
|
118
120
|
// Externally facing embedder endpoints
|
|
119
121
|
embeddedEndpoints(apiRouter);
|
|
120
122
|
|
|
@@ -119,6 +119,7 @@ model workspaces {
|
|
|
119
119
|
name String
|
|
120
120
|
slug String @unique
|
|
121
121
|
vectorTag String?
|
|
122
|
+
importedFrom String? // Provenance marker: "chatgpt" | null
|
|
122
123
|
createdAt DateTime @default(now())
|
|
123
124
|
openAiTemp Float?
|
|
124
125
|
openAiHistory Int @default(20)
|
|
@@ -151,6 +152,7 @@ model workspace_threads {
|
|
|
151
152
|
id Int @id @default(autoincrement())
|
|
152
153
|
name String
|
|
153
154
|
slug String @unique
|
|
155
|
+
externalId String? // Original ID from import source (e.g. ChatGPT conversation_id) for dedup
|
|
154
156
|
workspace_id Int
|
|
155
157
|
user_id Int?
|
|
156
158
|
createdAt DateTime @default(now())
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as c,j as e,p,C as h,c as d,W as I,ah as w,a7 as v,aM as S,aH as C,s as A,v as L,aO as T,a3 as F,i as N}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{r as H}from"./files-0c641c94.js";import{p as P}from"./purify-7f82b96b.js";import{s as M}from"./index-05fbc3ea.js";import{A as b}from"./agentFlows-e4124dd3.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./index-c9a0d9d0.js";import"./truncate-24ce7b97.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-cf34cce5.js";import"./mcpServers-560f2092.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./Trans-06928aa5.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-88aa26af.js";import"./index-bd540023.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,ah as w,a7 as v,aM as S,aH as C,s as A,v as L,aO as T,a3 as F,i as N}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{r as H}from"./files-0c641c94.js";import{p as P}from"./purify-7f82b96b.js";import{s as M}from"./index-beeec877.js";import{A as b}from"./agentFlows-e4124dd3.js";/* empty css */import"./Check-7e83fb0d.js";import"./Copy-d323e545.js";import"./index-c9a0d9d0.js";import"./truncate-24ce7b97.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-cf34cce5.js";import"./mcpServers-560f2092.js";import"./admin-04b020fe.js";import"./Database-f1a76329.js";import"./Trans-06928aa5.js";import"./Brain-24e386d5.js";import"./Browser-1820fad0.js";import"./index-88aa26af.js";import"./index-bd540023.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 O({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":O,unknown:$};function R({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 _({settings:t,setSettings:l,setStep:s}){const{item:n,loading:a,error:i}=R({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(_,{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 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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as N,r as l,j as e,a3 as w,i as k,A as f,m as y}from"../index.js";const j="border-none h-9 px-5 rounded-lg bg-zinc-50 text-zinc-950 light:bg-slate-900 light:text-white text-sm font-medium hover:bg-zinc-200 light:hover:bg-slate-800 transition-colors disabled:opacity-40 disabled:pointer-events-none";function S(){const{t}=N(),[d,D]=l.useState(null),[a,c]=l.useState(null),[m,p]=l.useState(!1),[x,h]=l.useState(!1),[r,n]=l.useState(null),[u,i]=l.useState(null);async function g(){p(!0),i(null),n(null);try{const s=await fetch(`${f}/import/chatgpt/preview`,{method:"GET",headers:y()}),o=await s.json();s.ok?(D(o.dir||null),c(o.metadata||null)):(c(null),i(o.error||t("importData.notFoundTitle")))}catch(s){console.error(s),c(null),i(s.message)}finally{p(!1)}}async function v(){h(!0),i(null);try{const s=await fetch(`${f}/import/chatgpt`,{method:"POST",headers:y(),body:JSON.stringify({})}),o=await s.json();s.ok?n(o.summary||null):(n(null),i(o.error||t("importData.notFoundTitle")))}catch(s){console.error(s),n(null),i(s.message)}finally{h(!1)}}l.useEffect(()=>{g()},[]);const b=a!=null&&a.earliestDate&&(a!=null&&a.latestDate)?`${new Date(a.earliestDate).toLocaleDateString()} – ${new Date(a.latestDate).toLocaleDateString()}`:null;return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(w,{}),e.jsx("div",{style:{height:k?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2",children:[e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:t("importData.title","Import Data")}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary mt-2",children:t("importData.description","Bring your ChatGPT history into Totem LLM. Save an exported copy of your conversations, then import it below.")})]}),e.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 max-w-xl",children:[e.jsx("p",{className:"text-sm leading-[20px] text-theme-text-primary font-medium",children:t("importData.howItWorksTitle","How to import your ChatGPT history")}),e.jsxs("ol",{className:"list-decimal list-inside text-xs leading-[18px] text-theme-text-secondary space-y-2",children:[e.jsx("li",{children:t("importData.stepExport")}),e.jsx("li",{children:t("importData.stepDownload")}),e.jsxs("li",{children:[t("importData.stepUnzip"),e.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-0.5 pl-4",children:[e.jsx("li",{children:t("importData.unzipMac")}),e.jsx("li",{children:t("importData.unzipWin")}),e.jsx("li",{children:t("importData.unzipLinux")})]})]}),e.jsx("li",{children:t("importData.stepMove")}),e.jsx("li",{children:t("importData.stepPreviewImport")})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-y-2",children:[e.jsx("p",{className:"text-sm leading-[20px] text-theme-text-primary font-medium",children:t("importData.importDirTitle","Where to put your export")}),e.jsx("p",{className:"text-xs leading-[18px] text-theme-text-secondary",children:t("importData.importDirHint","The folder must contain files like conversations-000.json and export_manifest.json. Drop or extract the unzipped export here, then click Preview:")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"rounded-md bg-black/20 light:bg-slate-100 border border-white/10 light:border-slate-300 px-3 py-2 text-xs leading-[18px] break-all flex-1",children:d||"…"}),d&&e.jsx("button",{type:"button",onClick:()=>{var s;return(s=navigator.clipboard)==null?void 0:s.writeText(d)},className:"shrink-0 border-none h-[34px] px-3 rounded-md bg-zinc-200 light:bg-slate-800 text-xs font-medium hover:bg-zinc-300 light:hover:bg-slate-700 transition-colors",children:t("importData.copyPath","Copy path")})]})]}),e.jsxs("div",{className:"flex items-center gap-x-3 mt-2",children:[e.jsx("button",{type:"button",onClick:g,disabled:m||x,className:j,children:m?t("importData.checking","Checking for an export…"):a?t("importData.recheckButton","Re-check"):t("importData.previewButton","Preview")}),e.jsx("button",{type:"button",onClick:v,disabled:!a||m||x,className:j,children:x?t("importData.importing","Importing…"):t("importData.importButton","Import")})]}),u&&e.jsxs("div",{className:"mt-4 flex flex-col gap-y-2 rounded-lg border border-red-500/30 bg-red-500/10 p-4",children:[e.jsx("p",{className:"text-sm font-semibold text-red-400",children:t("importData.notFoundTitle","No export found yet")}),e.jsx("p",{className:"text-xs leading-[18px] text-theme-text-secondary break-all",children:u}),e.jsxs("div",{className:"mt-2 flex flex-col gap-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-theme-text-primary",children:t("importData.troubleTitle","Nothing showing up after clicking Preview?")}),e.jsxs("ul",{className:"list-disc list-inside text-xs leading-[18px] text-theme-text-secondary space-y-0.5 pl-2",children:[e.jsx("li",{children:t("importData.troubleHint1")}),e.jsx("li",{children:t("importData.troubleHint2")})]})]})]}),a&&!r&&e.jsxs("div",{className:"mt-4 flex flex-col gap-y-2 rounded-lg border border-white/10 light:border-slate-300 p-4",children:[e.jsx("p",{className:"text-sm font-semibold text-theme-text-primary",children:t("importData.readyTitle","Export detected")}),e.jsxs("div",{className:"flex flex-wrap gap-x-6 gap-y-1 text-xs leading-[18px] text-theme-text-secondary",children:[e.jsxs("span",{children:[t("importData.conversationsLabel","Conversations"),":"," ",e.jsx("strong",{children:a.totalConversations})]}),e.jsxs("span",{children:[t("importData.messagesLabel","Messages"),":"," ",e.jsx("strong",{children:a.totalMessages})]}),b&&e.jsxs("span",{children:[t("importData.dateRangeLabel","Date range"),":"," ",e.jsx("strong",{children:b})]})]})]}),r&&e.jsxs("div",{className:"mt-4 flex flex-col gap-y-2 rounded-lg border border-emerald-500/30 bg-emerald-500/10 p-4",children:[e.jsx("p",{className:"text-sm font-semibold text-emerald-400",children:t("importData.successTitle","Import complete")}),e.jsxs("div",{className:"flex flex-wrap gap-x-6 gap-y-1 text-xs leading-[18px] text-theme-text-secondary",children:[e.jsxs("span",{children:[r.threadsImported," ",t("importData.summaryThreads","threads imported")]}),e.jsxs("span",{children:[r.chatsImported," ",t("importData.summaryChats","chats created")]}),e.jsxs("span",{children:[r.skipped," ",t("importData.summarySkipped","already skipped")]})]}),Array.isArray(r.errors)&&r.errors.length>0&&e.jsx("p",{className:"text-xs text-amber-400",children:t("importData.errorsLabel","{{count}} conversation(s) failed to import",{count:r.errors.length})})]})]})]})})]})}export{S as default};
|