diff --git a/README.md b/README.md index d268e15a6..b685c1689 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ [![Feishu](https://img.shields.io/badge/Feishu-Group-00D4AA?style=flat-square&logo=feishu&logoColor=white)](./Communication.md) [![WeChat](https://img.shields.io/badge/WeChat-Group-07C160?style=flat-square&logo=wechat&logoColor=white)](https://github.com/HKUDS/DeepTutor/issues/78) -[Features](#-key-features) · [Get Started](#-get-started) · [Explore](#-explore-deeptutor) · [CLI](#%EF%B8%8F-deeptutor-cli--agent-native-interface) · [Multi-User](#-multi-user--shared-deployments) · [Community](#-community) +[Features](#-key-features) · [Get Started](#-get-started) · [Explore](#-explore-deeptutor) · [CLI](#%EF%B8%8F-deeptutor-cli--agent-native-interface) · [Community](#-community) @@ -147,23 +147,13 @@ ## ✨ Key Features -DeepTutor is organized around an agent-native runtime: a shared ChatOrchestrator routes every turn into capabilities, a ToolRegistry exposes single-shot tools when the model needs them, and a CapabilityRegistry lets deeper workflows take over the turn when the task needs structure. +DeepTutor is an agent-native learning workspace: Chat, Solve, Quiz, Research, Visualize, and Mastery Path run on one extensible tutoring runtime. -
-DeepTutor system architecture -
- -**One learning workspace** - -- **Chat as the default loop** — casual tutoring, source-grounded Q&A, Deep Solve, Deep Question, Deep Research, Visualize, and Auto Mode all share the same session context and source inventory. -- **Learning surfaces that stay connected** — Co-Writer drafts, Book pages, Knowledge Bases, Space assets, and Memory are separate workspaces, but they feed the same agent runtime instead of becoming isolated apps. -- **Partners for persistent companionship** — IM-connected companions now run on the same chat agent loop as the main product, with their own synthetic workspace and assigned library. - -**Tools, memory, and control** - -- **Composable tools** — RAG, source reading, memory read/write, notebooks, URL fetch, GitHub lookup, ask-user pauses, sandboxed execution, and optional brainstorm/web/paper/reason tools can be mounted according to context and settings. -- **Three-layer memory** — L1 traces, L2 per-surface summaries, and L3 cross-surface synthesis make personalization inspectable rather than hidden behind a black box. -- **Unified settings and CLI** — model catalogs, embeddings, search, network, MCP servers, tools, capabilities, and deployment settings are editable from the web UI and scriptable from `deeptutor`. +- **Multiple learning modes, one tutor runtime** — move between flexible chat, step-by-step solving, auto-validated quiz generation, multi-agent research, visual explanation, and mastery-based tutoring without switching systems. +- **Connected learning workspace** — Knowledge Bases, Book pages, Co-Writer drafts, Space assets, notebooks, and Memory give the tutor reusable context instead of scattering learning materials across isolated tools. +- **Extensible tool and skill ecosystem** — DeepTutor can use built-in tools, MCP tools, built-in skills, and community skills from ClawHub, so the tutor can grow with new workflows instead of being limited to a fixed feature set. +- **Inspectable long-term memory** — L1 traces, L2 surface summaries, and L3 cross-surface synthesis make personalization visible, editable, and traceable. +- **Persistent Partners** — IM-connected companions run on the same DeepTutor agent loop, each with its own soul, channels, workspace, and assigned library. --- @@ -413,6 +403,10 @@ Project-root `.env` is **not** read as an application config file. For a minimal The README tour follows the product surfaces in the order you will most often meet them: Chat, Partner, Co-Writer, Book, Knowledge, Space, Memory, and Settings. The screenshots below come from the reorganized `assets/figs` tree; archived legacy images are intentionally not used here. +
+DeepTutor system architecture +
+
💬 Chat — The Agent Loop You Actually Use @@ -458,6 +452,10 @@ The channel layer is schema-driven and can connect to IM platforms such as Feish
✍️ Co-Writer — Selection-Aware Markdown Drafting +
+DeepTutor Co-Writer workspace +
+ Co-Writer is a split-view Markdown workspace for reports, tutorials, notes, and long-form learning artifacts. Documents autosave, render a live preview, and can be saved back into notebooks when the draft becomes reusable context. Select text and ask DeepTutor to rewrite, expand, or shorten it. The edit agent keeps a trace of tool calls and can ground an edit in a knowledge base or web evidence, so Co-Writer behaves more like an editor with retrieval than a detached text box. @@ -537,6 +535,31 @@ Most settings use a draft-and-apply flow so users can test providers before comm
+
+👥 Multi-User — Shared Deployments · optional auth, isolated per-user workspaces + +
+DeepTutor multi-user admin workspace +
+ +Authentication is **off by default** — DeepTutor runs single-user. Turn it on and one `data/` tree hosts an admin workspace, isolated per-user workspaces, and partner workspaces side by side: + +```text +data/ +├── user/ # Admin workspace + global settings +├── users// # Per-user scope: chat history, memory, notebooks, KBs +├── partners//workspace/ # Partner (synthetic-user) scope +└── system/ # auth/users.json · grants/.json · audit/usage.jsonl +``` + +The **first registered user becomes admin** and owns model catalogs, provider credentials, shared knowledge bases, skills, and per-user grants. Everyone else gets an isolated workspace and a redacted Settings page — admin-assigned models, KBs, and skills show up as scoped, read-only options, never as raw API keys. + +**Enable it:** turn auth on in `data/user/settings/auth.json`, restart `deeptutor start`, register the first admin at `/register`, then add users from `/admin/users` and assign models, KBs, skills, tool/MCP policy, and code-execution access through grants. + +> PocketBase stays a single-user integration — keep `integrations.pocketbase_url` blank for multi-user deployments unless you've wired up an external user store. + +
+ --- ## ⌨️ DeepTutor CLI — Agent-Native Interface @@ -578,37 +601,6 @@ The CLI-only distribution is present in `packaging/deeptutor-cli`; in this check --- -## 👥 Multi-User — Shared Deployments - -
-DeepTutor multi-user admin workspace -
- -Authentication is optional and off by default. When enabled, DeepTutor becomes a shared deployment with one admin workspace, per-user workspaces, partner workspaces, and system state under one `data/` tree. - -```text -data/ -├── user/ # Admin workspace and settings -├── users// # Non-admin user scope -│ ├── user/chat_history.db -│ ├── user/settings/interface.json -│ ├── user/workspace/{chat,co-writer,book,memory,notebook,...} -│ └── knowledge_bases/... -├── partners//workspace/ # Partner synthetic-user scope -└── system/ - ├── auth/users.json - ├── grants/.json - └── audit/usage.jsonl -``` - -The first registered user becomes admin and can configure model catalogs, provider credentials, knowledge bases, skills, and user grants. Non-admin users get isolated chat history, memory, notebooks, personal knowledge bases, and a redacted Settings page; admin-assigned resources appear as scoped, read-only options rather than exposing API keys or provider internals. - -For a local trial, set `data/user/settings/auth.json` to enable auth, restart `deeptutor start`, register the first admin at `/register`, then create users from `/admin/users` and assign models, KBs, skills, tool policy, MCP policy, and code-execution access through grants. - -PocketBase mode remains a single-user integration in this tree; multi-user deployments should keep `integrations.pocketbase_url` blank and use the default JSON/SQLite auth and session stores unless an external user store has been explicitly designed for the deployment. - ---- - ## 🧩 Ecosystem — Hub Skills, One Command Away DeepTutor skills speak the same language as the wider Agent-Skills ecosystem: a directory holding a `SKILL.md` playbook (YAML frontmatter + markdown) plus optional reference files. That makes external skill registries a native source for the skill library — [ClawHub](https://clawhub.ai/) is wired in out of the box: diff --git a/assets/figs/webui/cowriter.png b/assets/figs/webui/cowriter.png new file mode 100644 index 000000000..e093a63bc Binary files /dev/null and b/assets/figs/webui/cowriter.png differ diff --git a/deeptutor/agents/notebook/prompts/en/summarize_agent.yaml b/deeptutor/agents/notebook/prompts/en/summarize_agent.yaml index 99085bae5..eefabd634 100644 --- a/deeptutor/agents/notebook/prompts/en/summarize_agent.yaml +++ b/deeptutor/agents/notebook/prompts/en/summarize_agent.yaml @@ -22,6 +22,7 @@ user_template: | # Per-record-type hints injected into `user_template` as `{record_hint}`. record_hints: chat: "A full chat transcript; focus on the question, conclusion, and next actions." + tutorbot: "A conversation with a Partner (a named AI assistant); focus on what was asked, the Partner's conclusion, and any next actions." guided_learning: "A guided learning record; focus on topic, knowledge structure, and partial/final output." co_writer: "A Co-Writer markdown draft authored by the user; focus on the document's topic, structure, current completion state, and what makes it worth revisiting." default: "Summarize the most reusable information in this record." diff --git a/deeptutor/agents/notebook/prompts/zh/summarize_agent.yaml b/deeptutor/agents/notebook/prompts/zh/summarize_agent.yaml index 4d9ca87db..766395317 100644 --- a/deeptutor/agents/notebook/prompts/zh/summarize_agent.yaml +++ b/deeptutor/agents/notebook/prompts/zh/summarize_agent.yaml @@ -23,6 +23,7 @@ user_template: | # 各记录类型的提示语,会被注入到 user_template 的 {record_hint}。 record_hints: chat: "一段完整聊天历史,重点提炼问题、结论与后续行动。" + tutorbot: "一段与 Partner(具名 AI 助手)的对话,重点提炼提出的问题、Partner 给出的结论与后续行动。" guided_learning: "一段引导式学习记录,重点提炼学习主题、知识点结构与阶段性产出。" co_writer: "一份用户在 Co-Writer 中撰写的 Markdown 草稿,重点提炼文档主题、结构骨架、当前完成度,以及后续值得回顾的部分。" default: "请总结此记录中最值得复用的信息。" diff --git a/web/app/(workspace)/partners/[partnerId]/page.tsx b/web/app/(workspace)/partners/[partnerId]/page.tsx index ce7920950..76ec581f1 100644 --- a/web/app/(workspace)/partners/[partnerId]/page.tsx +++ b/web/app/(workspace)/partners/[partnerId]/page.tsx @@ -5,12 +5,14 @@ * Header carries identity + run state; everything else lives in the tabs. */ -import { Suspense, useCallback, useEffect, useState } from "react"; +import { Suspense, useCallback, useEffect, useMemo, useState } from "react"; import Link from "next/link"; import { useParams, useRouter, useSearchParams } from "next/navigation"; import { ArrowLeft, Archive, + BookmarkPlus, + Download, Loader2, MessageCircle, Play, @@ -27,11 +29,16 @@ import { stopPartner, type PartnerInfo, } from "@/lib/partners-api"; +import { downloadChatMarkdown, type ExportableMessage } from "@/lib/chat-export"; import PartnerAvatar from "@/components/partners/PartnerAvatar"; import PartnerChat from "@/components/partners/PartnerChat"; import PartnerChannels from "@/components/partners/PartnerChannels"; import PartnerConfigure from "@/components/partners/PartnerConfigure"; import PartnerArchives from "@/components/partners/PartnerArchives"; +import SaveToNotebookModal, { + type NotebookSaveMessage, + type NotebookSavePayload, +} from "@/components/notebook/SaveToNotebookModal"; type Tab = "chat" | "configure" | "channels" | "archive"; @@ -52,6 +59,13 @@ function PartnerDetail() { const [loading, setLoading] = useState(true); const [lifecycleBusy, setLifecycleBusy] = useState(false); const [toast, setToast] = useState(""); + // Conversation transcripts lifted from the Chat / Archive tabs so the header + // can export whichever surface is active. + const [chatMessages, setChatMessages] = useState([]); + const [archiveMessages, setArchiveMessages] = useState( + [], + ); + const [showSaveModal, setShowSaveModal] = useState(false); useEffect(() => { if (!toast) return; @@ -59,6 +73,59 @@ function PartnerDetail() { return () => clearTimeout(timer); }, [toast]); + const exportMessages = useMemo(() => { + if (tab === "chat") return chatMessages; + if (tab === "archive") return archiveMessages; + return []; + }, [tab, chatMessages, archiveMessages]); + + const canExport = exportMessages.length > 0; + + const exportTitle = useMemo(() => { + const firstUser = exportMessages + .find((msg) => msg.role === "user") + ?.content.trim(); + return firstUser?.slice(0, 80) || partner?.name || "Conversation"; + }, [exportMessages, partner?.name]); + + const savePayload = useMemo(() => { + if (!partner || !canExport) return null; + return { + recordType: "tutorbot", + title: exportTitle, + // The transcript / userQuery are rebuilt inside the modal from the + // user's selected subset; these are just fallbacks. + userQuery: "", + output: "", + metadata: { + source: "partner", + partner_id: partnerId, + partner_name: partner.name, + }, + }; + }, [partner, canExport, exportTitle, partnerId]); + + const saveMessages = useMemo( + () => + exportMessages + .filter( + (msg) => + msg.role === "user" || + msg.role === "assistant" || + msg.role === "system", + ) + .map((msg) => ({ + role: msg.role as NotebookSaveMessage["role"], + content: msg.content, + })), + [exportMessages], + ); + + const handleDownload = useCallback(() => { + if (!exportMessages.length) return; + downloadChatMarkdown(exportMessages, { title: exportTitle }); + }, [exportMessages, exportTitle]); + const load = useCallback(async () => { try { setPartner(await getPartner(partnerId)); @@ -195,6 +262,30 @@ function PartnerDetail() { ))} + {(tab === "chat" || tab === "archive") && ( + <> + + + + )}